@polka-codes/cli 0.9.88 → 0.9.89
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/index.js +2042 -357
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -16483,10 +16483,28 @@ var init_zod = __esm(() => {
|
|
|
16483
16483
|
init_external();
|
|
16484
16484
|
});
|
|
16485
16485
|
|
|
16486
|
+
// ../core/src/config/memory.ts
|
|
16487
|
+
function resolveHomePath(path) {
|
|
16488
|
+
if (path.startsWith("~")) {
|
|
16489
|
+
return `${process.env.HOME}${path.slice(1)}`;
|
|
16490
|
+
}
|
|
16491
|
+
return path;
|
|
16492
|
+
}
|
|
16493
|
+
var memoryConfigSchema;
|
|
16494
|
+
var init_memory = __esm(() => {
|
|
16495
|
+
init_zod();
|
|
16496
|
+
memoryConfigSchema = exports_external.object({
|
|
16497
|
+
enabled: exports_external.boolean().optional().default(true),
|
|
16498
|
+
type: exports_external.enum(["sqlite", "memory"]).optional().default("sqlite"),
|
|
16499
|
+
path: exports_external.string().optional().default("~/.config/polka-codes/memory.sqlite")
|
|
16500
|
+
}).strict().optional();
|
|
16501
|
+
});
|
|
16502
|
+
|
|
16486
16503
|
// ../core/src/config.ts
|
|
16487
16504
|
var ruleSchema, providerConfigSchema, providerModelSchema, scriptSchema, mcpServerConfigSchema, agentContinuousImprovementSchema, agentDiscoverySchema, agentSafetySchema, agentHealthCheckSchema, agentApprovalSchema, agentSchema, configSchema;
|
|
16488
16505
|
var init_config = __esm(() => {
|
|
16489
16506
|
init_zod();
|
|
16507
|
+
init_memory();
|
|
16490
16508
|
ruleSchema = exports_external.union([
|
|
16491
16509
|
exports_external.string(),
|
|
16492
16510
|
exports_external.object({ path: exports_external.string() }).strict(),
|
|
@@ -16618,7 +16636,8 @@ var init_config = __esm(() => {
|
|
|
16618
16636
|
mcpServers: exports_external.record(exports_external.string(), mcpServerConfigSchema).optional(),
|
|
16619
16637
|
rules: exports_external.array(ruleSchema).optional().or(exports_external.string()).optional(),
|
|
16620
16638
|
excludeFiles: exports_external.array(exports_external.string()).optional(),
|
|
16621
|
-
agent: agentSchema
|
|
16639
|
+
agent: agentSchema,
|
|
16640
|
+
memory: memoryConfigSchema
|
|
16622
16641
|
}).strict().nullish();
|
|
16623
16642
|
});
|
|
16624
16643
|
|
|
@@ -16671,6 +16690,8 @@ var init_node_provider = () => {};
|
|
|
16671
16690
|
var init_fs = __esm(() => {
|
|
16672
16691
|
init_node_provider();
|
|
16673
16692
|
});
|
|
16693
|
+
// ../core/src/memory/index.ts
|
|
16694
|
+
var init_memory2 = () => {};
|
|
16674
16695
|
|
|
16675
16696
|
// ../core/src/skills/constants.ts
|
|
16676
16697
|
var SKILL_LIMITS, IGNORED_DIRECTORIES, SUSPICIOUS_PATTERNS, SKILL_ERROR_MESSAGES, SOURCE_ICONS;
|
|
@@ -24611,15 +24632,39 @@ var toolInfo6, handler6 = async (provider, args) => {
|
|
|
24611
24632
|
if (!provider.readFile) {
|
|
24612
24633
|
return createProviderErrorResponse("read file");
|
|
24613
24634
|
}
|
|
24614
|
-
const
|
|
24635
|
+
const parsed = toolInfo6.parameters.safeParse(args);
|
|
24636
|
+
if (!parsed.success) {
|
|
24637
|
+
return {
|
|
24638
|
+
success: false,
|
|
24639
|
+
message: {
|
|
24640
|
+
type: "error-text",
|
|
24641
|
+
value: `Invalid arguments for readFile: ${parsed.error.message}`
|
|
24642
|
+
}
|
|
24643
|
+
};
|
|
24644
|
+
}
|
|
24645
|
+
const { path: paths, offset, limit, includeIgnored } = parsed.data;
|
|
24615
24646
|
const resp = [];
|
|
24616
24647
|
for (const path of paths) {
|
|
24617
24648
|
const fileContent = await provider.readFile(path, includeIgnored ?? false);
|
|
24618
24649
|
if (!fileContent) {
|
|
24619
24650
|
resp.push(createFileElement("read_file_file_content", path, undefined, { file_not_found: "true" }));
|
|
24620
|
-
|
|
24621
|
-
resp.push(createFileElement("read_file_file_content", path, fileContent));
|
|
24651
|
+
continue;
|
|
24622
24652
|
}
|
|
24653
|
+
let lines = fileContent.split(`
|
|
24654
|
+
`);
|
|
24655
|
+
const start = offset ?? 0;
|
|
24656
|
+
const end = limit ? start + limit : lines.length;
|
|
24657
|
+
if (offset !== undefined || limit !== undefined) {
|
|
24658
|
+
lines = lines.slice(start, end);
|
|
24659
|
+
}
|
|
24660
|
+
const lineOffset = offset ?? 0;
|
|
24661
|
+
const numberedContent = lines.map((line, i) => {
|
|
24662
|
+
const lineNumber = lineOffset + i + 1;
|
|
24663
|
+
const paddedNumber = String(lineNumber).padStart(6, " ");
|
|
24664
|
+
return `${paddedNumber}→${line}`;
|
|
24665
|
+
}).join(`
|
|
24666
|
+
`);
|
|
24667
|
+
resp.push(createFileElement("read_file_file_content", path, numberedContent));
|
|
24623
24668
|
}
|
|
24624
24669
|
return {
|
|
24625
24670
|
success: true,
|
|
@@ -24635,14 +24680,40 @@ var init_readFile = __esm(() => {
|
|
|
24635
24680
|
init_utils();
|
|
24636
24681
|
toolInfo6 = {
|
|
24637
24682
|
name: "readFile",
|
|
24638
|
-
description:
|
|
24683
|
+
description: `Request to read the contents of one or multiple files at the specified paths.
|
|
24684
|
+
|
|
24685
|
+
When to use:
|
|
24686
|
+
- Examining file contents you don't know
|
|
24687
|
+
- Analyzing code, reviewing text files, extracting configuration info
|
|
24688
|
+
- Reading multiple files at once (use comma-separated paths)
|
|
24689
|
+
- Understanding file structure before editing
|
|
24690
|
+
|
|
24691
|
+
When NOT to use:
|
|
24692
|
+
- For file existence checks: Use listFiles instead
|
|
24693
|
+
- For searching within files: Use grep instead
|
|
24694
|
+
- For file name searches: Use searchFiles instead
|
|
24695
|
+
- Prefer this tool over executeCommand with cat/head/tail
|
|
24696
|
+
|
|
24697
|
+
Features:
|
|
24698
|
+
- Supports comma-separated paths for multiple files
|
|
24699
|
+
- Line numbers included for easy reference
|
|
24700
|
+
- Optional offset/limit for partial file reading
|
|
24701
|
+
- Automatically handles different file types
|
|
24702
|
+
|
|
24703
|
+
IMPORTANT:
|
|
24704
|
+
- Line numbers are included for easy reference
|
|
24705
|
+
- Use offset/limit for large files to read specific sections`,
|
|
24639
24706
|
parameters: exports_external.object({
|
|
24640
24707
|
path: exports_external.preprocess((val) => {
|
|
24641
24708
|
if (!val)
|
|
24642
24709
|
return [];
|
|
24643
|
-
|
|
24644
|
-
|
|
24710
|
+
if (Array.isArray(val)) {
|
|
24711
|
+
return val.filter((s) => typeof s === "string" && s.length > 0);
|
|
24712
|
+
}
|
|
24713
|
+
return val.split(",").filter((s) => s.length > 0);
|
|
24645
24714
|
}, exports_external.array(exports_external.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" }),
|
|
24715
|
+
offset: exports_external.number().optional().describe("Skip first N lines (for partial file reading)").meta({ usageValue: "100" }),
|
|
24716
|
+
limit: exports_external.number().optional().describe("Read at most N lines (for partial file reading)").meta({ usageValue: "50" }),
|
|
24646
24717
|
includeIgnored: exports_external.preprocess(preprocessBoolean, exports_external.boolean().nullish().default(false)).describe("Whether to include ignored files. Use true to include files ignored by .gitignore.").meta({ usageValue: "true or false (optional)" })
|
|
24647
24718
|
}).meta({
|
|
24648
24719
|
examples: [
|
|
@@ -24657,6 +24728,14 @@ var init_readFile = __esm(() => {
|
|
|
24657
24728
|
input: {
|
|
24658
24729
|
path: "src/main.js,src/index.js"
|
|
24659
24730
|
}
|
|
24731
|
+
},
|
|
24732
|
+
{
|
|
24733
|
+
description: "Read partial file (lines 100-150)",
|
|
24734
|
+
input: {
|
|
24735
|
+
path: "src/large-file.ts",
|
|
24736
|
+
offset: 100,
|
|
24737
|
+
limit: 50
|
|
24738
|
+
}
|
|
24660
24739
|
}
|
|
24661
24740
|
]
|
|
24662
24741
|
})
|
|
@@ -24933,7 +25012,43 @@ var init_replaceInFile = __esm(() => {
|
|
|
24933
25012
|
init_zod();
|
|
24934
25013
|
toolInfo9 = {
|
|
24935
25014
|
name: "replaceInFile",
|
|
24936
|
-
description:
|
|
25015
|
+
description: `Request to replace sections of content in an existing file using
|
|
25016
|
+
SEARCH/REPLACE blocks.
|
|
25017
|
+
|
|
25018
|
+
When to use:
|
|
25019
|
+
- Making targeted changes to specific parts of a file
|
|
25020
|
+
- Replacing variable names, function signatures, imports
|
|
25021
|
+
- Fixing bugs in existing code
|
|
25022
|
+
- When you know the exact content to replace
|
|
25023
|
+
|
|
25024
|
+
When NOT to use:
|
|
25025
|
+
- For creating new files: Use writeToFile instead
|
|
25026
|
+
- For completely replacing file contents: Use writeToFile instead
|
|
25027
|
+
- When you don't know the exact content: Read file first
|
|
25028
|
+
|
|
25029
|
+
SEARCH/REPLACE FORMAT:
|
|
25030
|
+
<<<<<<< SEARCH
|
|
25031
|
+
[exact content to find]
|
|
25032
|
+
=======
|
|
25033
|
+
[new content to replace with]
|
|
25034
|
+
>>>>>>> REPLACE
|
|
25035
|
+
|
|
25036
|
+
Critical rules:
|
|
25037
|
+
1. SEARCH content must match EXACTLY (character-for-character including whitespace)
|
|
25038
|
+
2. Each block replaces only first occurrence
|
|
25039
|
+
3. Include just enough lines for uniqueness (not too many, not too few)
|
|
25040
|
+
4. Keep blocks concise (don't include long unchanged sections)
|
|
25041
|
+
5. List blocks in order they appear in file
|
|
25042
|
+
6. Use multiple blocks for multiple independent changes
|
|
25043
|
+
|
|
25044
|
+
Special operations:
|
|
25045
|
+
- Move code: Two blocks (delete from original + insert at new location)
|
|
25046
|
+
- Delete code: Empty REPLACE section
|
|
25047
|
+
|
|
25048
|
+
IMPORTANT CONSTRAINTS:
|
|
25049
|
+
- SEARCH text must match file content exactly
|
|
25050
|
+
- Each block is independent (doesn't affect other blocks)
|
|
25051
|
+
- Cannot use for appending or inserting without SEARCH context`,
|
|
24937
25052
|
parameters: exports_external.object({
|
|
24938
25053
|
path: exports_external.string().describe("The path of the file to modify").meta({ usageValue: "File path here" }),
|
|
24939
25054
|
diff: exports_external.string().describe(`One or more SEARCH/REPLACE blocks following this exact format:
|
|
@@ -24959,7 +25074,7 @@ Critical rules:
|
|
|
24959
25074
|
* Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.
|
|
24960
25075
|
4. Special operations:
|
|
24961
25076
|
* To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
|
|
24962
|
-
* To delete code:
|
|
25077
|
+
* To delete code: Empty REPLACE section`).meta({ usageValue: "Search and replace blocks here" })
|
|
24963
25078
|
}).meta({
|
|
24964
25079
|
examples: [
|
|
24965
25080
|
{
|
|
@@ -25241,10 +25356,7 @@ var toolInfo12, handler12 = async (provider, args) => {
|
|
|
25241
25356
|
}
|
|
25242
25357
|
};
|
|
25243
25358
|
}
|
|
25244
|
-
|
|
25245
|
-
const trimmedContent = content.trim();
|
|
25246
|
-
if (trimmedContent.startsWith("<![CDATA[") && trimmedContent.endsWith("]]>"))
|
|
25247
|
-
content = trimmedContent.slice(9, -3);
|
|
25359
|
+
const { path, content } = parsed.data;
|
|
25248
25360
|
await provider.writeFile(path, content);
|
|
25249
25361
|
return {
|
|
25250
25362
|
success: true,
|
|
@@ -25259,7 +25371,27 @@ var init_writeToFile = __esm(() => {
|
|
|
25259
25371
|
init_utils();
|
|
25260
25372
|
toolInfo12 = {
|
|
25261
25373
|
name: "writeToFile",
|
|
25262
|
-
description:
|
|
25374
|
+
description: `Request to write content to a file at the specified path.
|
|
25375
|
+
|
|
25376
|
+
When to use:
|
|
25377
|
+
- Creating new files
|
|
25378
|
+
- Completely replacing file contents
|
|
25379
|
+
- When you have the complete intended content
|
|
25380
|
+
|
|
25381
|
+
When NOT to use:
|
|
25382
|
+
- For modifying existing files: Use replaceInFile instead
|
|
25383
|
+
- For appending content: Use executeCommand with echo >> instead
|
|
25384
|
+
- For targeted edits: Use replaceInFile instead
|
|
25385
|
+
|
|
25386
|
+
Features:
|
|
25387
|
+
- Automatically creates any directories needed
|
|
25388
|
+
- Overwrites existing files completely
|
|
25389
|
+
- Must provide complete file content (no truncation)
|
|
25390
|
+
|
|
25391
|
+
IMPORTANT CONSTRAINT:
|
|
25392
|
+
- Always provide COMPLETE intended content (no omissions)
|
|
25393
|
+
- Ensure no incorrect escape sequences (<, >, &)
|
|
25394
|
+
- Ensure no unwanted CDATA tags in content`,
|
|
25263
25395
|
parameters: exports_external.object({
|
|
25264
25396
|
path: exports_external.string().describe("The path of the file to write to").meta({ usageValue: "File path here" }),
|
|
25265
25397
|
content: exports_external.string().describe("The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.").meta({ usageValue: "Your file content here" })
|
|
@@ -28503,9 +28635,9 @@ var init_types2 = __esm(() => {
|
|
|
28503
28635
|
return this._def.options;
|
|
28504
28636
|
}
|
|
28505
28637
|
};
|
|
28506
|
-
ZodUnion2.create = (
|
|
28638
|
+
ZodUnion2.create = (types3, params) => {
|
|
28507
28639
|
return new ZodUnion2({
|
|
28508
|
-
options:
|
|
28640
|
+
options: types3,
|
|
28509
28641
|
typeName: ZodFirstPartyTypeKind2.ZodUnion,
|
|
28510
28642
|
...processCreateParams(params)
|
|
28511
28643
|
});
|
|
@@ -30606,15 +30738,15 @@ function parseNullDef() {
|
|
|
30606
30738
|
function parseUnionDef(def, refs) {
|
|
30607
30739
|
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
30608
30740
|
if (options.every((x) => (x._def.typeName in primitiveMappings) && (!x._def.checks || !x._def.checks.length))) {
|
|
30609
|
-
const
|
|
30741
|
+
const types4 = options.reduce((types22, x) => {
|
|
30610
30742
|
const type = primitiveMappings[x._def.typeName];
|
|
30611
30743
|
return type && !types22.includes(type) ? [...types22, type] : types22;
|
|
30612
30744
|
}, []);
|
|
30613
30745
|
return {
|
|
30614
|
-
type:
|
|
30746
|
+
type: types4.length > 1 ? types4 : types4[0]
|
|
30615
30747
|
};
|
|
30616
30748
|
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
30617
|
-
const
|
|
30749
|
+
const types4 = options.reduce((acc, x) => {
|
|
30618
30750
|
const type = typeof x._def.value;
|
|
30619
30751
|
switch (type) {
|
|
30620
30752
|
case "string":
|
|
@@ -30633,8 +30765,8 @@ function parseUnionDef(def, refs) {
|
|
|
30633
30765
|
return acc;
|
|
30634
30766
|
}
|
|
30635
30767
|
}, []);
|
|
30636
|
-
if (
|
|
30637
|
-
const uniqueTypes =
|
|
30768
|
+
if (types4.length === options.length) {
|
|
30769
|
+
const uniqueTypes = types4.filter((x, i, a) => a.indexOf(x) === i);
|
|
30638
30770
|
return {
|
|
30639
30771
|
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
30640
30772
|
enum: options.reduce((acc, x) => {
|
|
@@ -39696,9 +39828,9 @@ function convertJsonSchemaToZod(schema) {
|
|
|
39696
39828
|
return exports_external.union([literals[0], literals[1], ...literals.slice(2)]);
|
|
39697
39829
|
}
|
|
39698
39830
|
if (Array.isArray(schema.type)) {
|
|
39699
|
-
const
|
|
39700
|
-
if (
|
|
39701
|
-
const nonNullType =
|
|
39831
|
+
const types4 = schema.type;
|
|
39832
|
+
if (types4.includes("null") && types4.length === 2) {
|
|
39833
|
+
const nonNullType = types4.find((t) => t !== "null");
|
|
39702
39834
|
if (nonNullType === "string")
|
|
39703
39835
|
return exports_external.string().nullable();
|
|
39704
39836
|
if (nonNullType === "number")
|
|
@@ -40656,6 +40788,7 @@ var init_src = __esm(() => {
|
|
|
40656
40788
|
init_Agent();
|
|
40657
40789
|
init_config();
|
|
40658
40790
|
init_fs();
|
|
40791
|
+
init_memory2();
|
|
40659
40792
|
init_skills();
|
|
40660
40793
|
init_tools();
|
|
40661
40794
|
init_tools2();
|
|
@@ -41361,9 +41494,9 @@ var init__nodeUtil = __esm(() => {
|
|
|
41361
41494
|
freeProcess = moduleExports2 && _freeGlobal_default.process;
|
|
41362
41495
|
nodeUtil = function() {
|
|
41363
41496
|
try {
|
|
41364
|
-
var
|
|
41365
|
-
if (
|
|
41366
|
-
return
|
|
41497
|
+
var types5 = freeModule2 && freeModule2.require && freeModule2.require("util").types;
|
|
41498
|
+
if (types5) {
|
|
41499
|
+
return types5;
|
|
41367
41500
|
}
|
|
41368
41501
|
return freeProcess && freeProcess.binding && freeProcess.binding("util");
|
|
41369
41502
|
} catch (e) {}
|
|
@@ -42489,6 +42622,38 @@ var init_config2 = __esm(() => {
|
|
|
42489
42622
|
init_zod();
|
|
42490
42623
|
});
|
|
42491
42624
|
|
|
42625
|
+
// ../cli-shared/src/memory-manager.ts
|
|
42626
|
+
class MemoryManager {
|
|
42627
|
+
store;
|
|
42628
|
+
constructor(store, _cwd) {
|
|
42629
|
+
this.store = store;
|
|
42630
|
+
}
|
|
42631
|
+
async readMemory(topic) {
|
|
42632
|
+
return this.store.readMemory(topic);
|
|
42633
|
+
}
|
|
42634
|
+
async updateMemory(operation, topic, content, metadata) {
|
|
42635
|
+
return this.store.updateMemory(operation, topic, content, metadata);
|
|
42636
|
+
}
|
|
42637
|
+
async queryMemory(query = {}, options) {
|
|
42638
|
+
const finalQuery = {
|
|
42639
|
+
...query
|
|
42640
|
+
};
|
|
42641
|
+
if (!options?.operation && !finalQuery.limit) {
|
|
42642
|
+
finalQuery.limit = 1000;
|
|
42643
|
+
}
|
|
42644
|
+
return this.store.queryMemory(finalQuery, options);
|
|
42645
|
+
}
|
|
42646
|
+
async batchUpdateMemory(operations) {
|
|
42647
|
+
return this.store.batchUpdateMemory(operations);
|
|
42648
|
+
}
|
|
42649
|
+
async getStats() {
|
|
42650
|
+
return this.store.getStats();
|
|
42651
|
+
}
|
|
42652
|
+
close() {
|
|
42653
|
+
this.store.close();
|
|
42654
|
+
}
|
|
42655
|
+
}
|
|
42656
|
+
|
|
42492
42657
|
// ../../node_modules/extend/index.js
|
|
42493
42658
|
var require_extend = __commonJS((exports, module) => {
|
|
42494
42659
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
@@ -49087,7 +49252,7 @@ var init_multipart_parser = __esm(() => {
|
|
|
49087
49252
|
|
|
49088
49253
|
// ../../node_modules/node-fetch/src/body.js
|
|
49089
49254
|
import Stream, { PassThrough } from "node:stream";
|
|
49090
|
-
import { types as
|
|
49255
|
+
import { types as types5, deprecate, promisify } from "node:util";
|
|
49091
49256
|
import { Buffer as Buffer4 } from "node:buffer";
|
|
49092
49257
|
|
|
49093
49258
|
class Body {
|
|
@@ -49099,7 +49264,7 @@ class Body {
|
|
|
49099
49264
|
body = null;
|
|
49100
49265
|
} else if (isURLSearchParameters(body)) {
|
|
49101
49266
|
body = Buffer4.from(body.toString());
|
|
49102
|
-
} else if (isBlob(body)) {} else if (Buffer4.isBuffer(body)) {} else if (
|
|
49267
|
+
} else if (isBlob(body)) {} else if (Buffer4.isBuffer(body)) {} else if (types5.isAnyArrayBuffer(body)) {
|
|
49103
49268
|
body = Buffer4.from(body);
|
|
49104
49269
|
} else if (ArrayBuffer.isView(body)) {
|
|
49105
49270
|
body = Buffer4.from(body.buffer, body.byteOffset, body.byteLength);
|
|
@@ -49245,7 +49410,7 @@ var pipeline, INTERNALS, clone2 = (instance, highWaterMark) => {
|
|
|
49245
49410
|
if (isBlob(body)) {
|
|
49246
49411
|
return body.type || null;
|
|
49247
49412
|
}
|
|
49248
|
-
if (Buffer4.isBuffer(body) ||
|
|
49413
|
+
if (Buffer4.isBuffer(body) || types5.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
|
|
49249
49414
|
return null;
|
|
49250
49415
|
}
|
|
49251
49416
|
if (body instanceof FormData2) {
|
|
@@ -49302,7 +49467,7 @@ var init_body = __esm(() => {
|
|
|
49302
49467
|
});
|
|
49303
49468
|
|
|
49304
49469
|
// ../../node_modules/node-fetch/src/headers.js
|
|
49305
|
-
import { types as
|
|
49470
|
+
import { types as types6 } from "node:util";
|
|
49306
49471
|
import http from "node:http";
|
|
49307
49472
|
function fromRawHeaders(headers = []) {
|
|
49308
49473
|
return new Headers2(headers.reduce((result, value, index, array2) => {
|
|
@@ -49344,7 +49509,7 @@ var init_headers = __esm(() => {
|
|
|
49344
49509
|
for (const [name17, values] of Object.entries(raw)) {
|
|
49345
49510
|
result.push(...values.map((value) => [name17, value]));
|
|
49346
49511
|
}
|
|
49347
|
-
} else if (init == null) {} else if (typeof init === "object" && !
|
|
49512
|
+
} else if (init == null) {} else if (typeof init === "object" && !types6.isBoxedPrimitive(init)) {
|
|
49348
49513
|
const method = init[Symbol.iterator];
|
|
49349
49514
|
if (method == null) {
|
|
49350
49515
|
result.push(...Object.entries(init));
|
|
@@ -49353,7 +49518,7 @@ var init_headers = __esm(() => {
|
|
|
49353
49518
|
throw new TypeError("Header pairs must be iterable");
|
|
49354
49519
|
}
|
|
49355
49520
|
result = [...init].map((pair) => {
|
|
49356
|
-
if (typeof pair !== "object" ||
|
|
49521
|
+
if (typeof pair !== "object" || types6.isBoxedPrimitive(pair)) {
|
|
49357
49522
|
throw new TypeError("Each header pair must be an iterable object");
|
|
49358
49523
|
}
|
|
49359
49524
|
return [...pair];
|
|
@@ -72581,7 +72746,7 @@ function lookup(path) {
|
|
|
72581
72746
|
}
|
|
72582
72747
|
return $types[extension2] || false;
|
|
72583
72748
|
}
|
|
72584
|
-
function populateMaps(extensions,
|
|
72749
|
+
function populateMaps(extensions, types7) {
|
|
72585
72750
|
Object.keys(db).forEach(function forEachMimeType(type) {
|
|
72586
72751
|
var mime = db[type];
|
|
72587
72752
|
var exts = mime.extensions;
|
|
@@ -72591,10 +72756,10 @@ function populateMaps(extensions, types6) {
|
|
|
72591
72756
|
extensions[type] = exts;
|
|
72592
72757
|
for (var i2 = 0;i2 < exts.length; i2++) {
|
|
72593
72758
|
var extension2 = exts[i2];
|
|
72594
|
-
|
|
72595
|
-
const legacyType = _preferredTypeLegacy(extension2,
|
|
72596
|
-
if (legacyType !==
|
|
72597
|
-
$_extensionConflicts.push([extension2, legacyType,
|
|
72759
|
+
types7[extension2] = _preferredType(extension2, types7[extension2], type);
|
|
72760
|
+
const legacyType = _preferredTypeLegacy(extension2, types7[extension2], type);
|
|
72761
|
+
if (legacyType !== types7[extension2]) {
|
|
72762
|
+
$_extensionConflicts.push([extension2, legacyType, types7[extension2]]);
|
|
72598
72763
|
}
|
|
72599
72764
|
}
|
|
72600
72765
|
});
|
|
@@ -72931,35 +73096,35 @@ var import_ignore2, getProvider = (options = {}) => {
|
|
|
72931
73096
|
}
|
|
72932
73097
|
},
|
|
72933
73098
|
listMemoryTopics: async () => {
|
|
72934
|
-
const
|
|
72935
|
-
return Object.keys(
|
|
73099
|
+
const memory2 = await memoryStore.read() ?? {};
|
|
73100
|
+
return Object.keys(memory2);
|
|
72936
73101
|
},
|
|
72937
73102
|
readMemory: async (topic = defaultMemoryTopic) => {
|
|
72938
|
-
const
|
|
72939
|
-
return
|
|
73103
|
+
const memory2 = await memoryStore.read() ?? {};
|
|
73104
|
+
return memory2[topic];
|
|
72940
73105
|
},
|
|
72941
73106
|
updateMemory: async (operation, topic, content) => {
|
|
72942
73107
|
const memoryTopic = topic ?? defaultMemoryTopic;
|
|
72943
|
-
const
|
|
73108
|
+
const memory2 = await memoryStore.read() ?? {};
|
|
72944
73109
|
switch (operation) {
|
|
72945
73110
|
case "append":
|
|
72946
73111
|
if (content === undefined) {
|
|
72947
73112
|
throw new Error("Content is required for append operation.");
|
|
72948
73113
|
}
|
|
72949
|
-
|
|
73114
|
+
memory2[memoryTopic] = `${memory2[memoryTopic] || ""}
|
|
72950
73115
|
${content}`;
|
|
72951
73116
|
break;
|
|
72952
73117
|
case "replace":
|
|
72953
73118
|
if (content === undefined) {
|
|
72954
73119
|
throw new Error("Content is required for replace operation.");
|
|
72955
73120
|
}
|
|
72956
|
-
|
|
73121
|
+
memory2[memoryTopic] = content;
|
|
72957
73122
|
break;
|
|
72958
73123
|
case "remove":
|
|
72959
|
-
delete
|
|
73124
|
+
delete memory2[memoryTopic];
|
|
72960
73125
|
break;
|
|
72961
73126
|
}
|
|
72962
|
-
await memoryStore.write(
|
|
73127
|
+
await memoryStore.write(memory2);
|
|
72963
73128
|
},
|
|
72964
73129
|
readFile: async (path, includeIgnored) => {
|
|
72965
73130
|
if (!includeIgnored && ig.ignores(path)) {
|
|
@@ -73137,6 +73302,1177 @@ var init_provider = __esm(() => {
|
|
|
73137
73302
|
import_ignore2 = __toESM(require_ignore(), 1);
|
|
73138
73303
|
});
|
|
73139
73304
|
|
|
73305
|
+
// ../../node_modules/better-sqlite3/lib/util.js
|
|
73306
|
+
var require_util3 = __commonJS((exports) => {
|
|
73307
|
+
exports.getBooleanOption = (options, key) => {
|
|
73308
|
+
let value = false;
|
|
73309
|
+
if (key in options && typeof (value = options[key]) !== "boolean") {
|
|
73310
|
+
throw new TypeError(`Expected the "${key}" option to be a boolean`);
|
|
73311
|
+
}
|
|
73312
|
+
return value;
|
|
73313
|
+
};
|
|
73314
|
+
exports.cppdb = Symbol();
|
|
73315
|
+
exports.inspect = Symbol.for("nodejs.util.inspect.custom");
|
|
73316
|
+
});
|
|
73317
|
+
|
|
73318
|
+
// ../../node_modules/better-sqlite3/lib/sqlite-error.js
|
|
73319
|
+
var require_sqlite_error = __commonJS((exports, module) => {
|
|
73320
|
+
var descriptor = { value: "SqliteError", writable: true, enumerable: false, configurable: true };
|
|
73321
|
+
function SqliteError(message, code) {
|
|
73322
|
+
if (new.target !== SqliteError) {
|
|
73323
|
+
return new SqliteError(message, code);
|
|
73324
|
+
}
|
|
73325
|
+
if (typeof code !== "string") {
|
|
73326
|
+
throw new TypeError("Expected second argument to be a string");
|
|
73327
|
+
}
|
|
73328
|
+
Error.call(this, message);
|
|
73329
|
+
descriptor.value = "" + message;
|
|
73330
|
+
Object.defineProperty(this, "message", descriptor);
|
|
73331
|
+
Error.captureStackTrace(this, SqliteError);
|
|
73332
|
+
this.code = code;
|
|
73333
|
+
}
|
|
73334
|
+
Object.setPrototypeOf(SqliteError, Error);
|
|
73335
|
+
Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
|
|
73336
|
+
Object.defineProperty(SqliteError.prototype, "name", descriptor);
|
|
73337
|
+
module.exports = SqliteError;
|
|
73338
|
+
});
|
|
73339
|
+
|
|
73340
|
+
// ../../node_modules/file-uri-to-path/index.js
|
|
73341
|
+
var require_file_uri_to_path = __commonJS((exports, module) => {
|
|
73342
|
+
var sep = __require("path").sep || "/";
|
|
73343
|
+
module.exports = fileUriToPath;
|
|
73344
|
+
function fileUriToPath(uri) {
|
|
73345
|
+
if (typeof uri != "string" || uri.length <= 7 || uri.substring(0, 7) != "file://") {
|
|
73346
|
+
throw new TypeError("must pass in a file:// URI to convert to a file path");
|
|
73347
|
+
}
|
|
73348
|
+
var rest = decodeURI(uri.substring(7));
|
|
73349
|
+
var firstSlash = rest.indexOf("/");
|
|
73350
|
+
var host = rest.substring(0, firstSlash);
|
|
73351
|
+
var path = rest.substring(firstSlash + 1);
|
|
73352
|
+
if (host == "localhost")
|
|
73353
|
+
host = "";
|
|
73354
|
+
if (host) {
|
|
73355
|
+
host = sep + sep + host;
|
|
73356
|
+
}
|
|
73357
|
+
path = path.replace(/^(.+)\|/, "$1:");
|
|
73358
|
+
if (sep == "\\") {
|
|
73359
|
+
path = path.replace(/\//g, "\\");
|
|
73360
|
+
}
|
|
73361
|
+
if (/^.+\:/.test(path)) {} else {
|
|
73362
|
+
path = sep + path;
|
|
73363
|
+
}
|
|
73364
|
+
return host + path;
|
|
73365
|
+
}
|
|
73366
|
+
});
|
|
73367
|
+
|
|
73368
|
+
// ../../node_modules/bindings/bindings.js
|
|
73369
|
+
var require_bindings = __commonJS((exports, module) => {
|
|
73370
|
+
var __filename = "/Users/xiliangchen/projects/polka-codes/node_modules/bindings/bindings.js";
|
|
73371
|
+
var fs4 = __require("fs");
|
|
73372
|
+
var path = __require("path");
|
|
73373
|
+
var fileURLToPath = require_file_uri_to_path();
|
|
73374
|
+
var join5 = path.join;
|
|
73375
|
+
var dirname2 = path.dirname;
|
|
73376
|
+
var exists = fs4.accessSync && function(path2) {
|
|
73377
|
+
try {
|
|
73378
|
+
fs4.accessSync(path2);
|
|
73379
|
+
} catch (e2) {
|
|
73380
|
+
return false;
|
|
73381
|
+
}
|
|
73382
|
+
return true;
|
|
73383
|
+
} || fs4.existsSync || path.existsSync;
|
|
73384
|
+
var defaults = {
|
|
73385
|
+
arrow: process.env.NODE_BINDINGS_ARROW || " → ",
|
|
73386
|
+
compiled: process.env.NODE_BINDINGS_COMPILED_DIR || "compiled",
|
|
73387
|
+
platform: process.platform,
|
|
73388
|
+
arch: process.arch,
|
|
73389
|
+
nodePreGyp: "node-v" + process.versions.modules + "-" + process.platform + "-" + process.arch,
|
|
73390
|
+
version: process.versions.node,
|
|
73391
|
+
bindings: "bindings.node",
|
|
73392
|
+
try: [
|
|
73393
|
+
["module_root", "build", "bindings"],
|
|
73394
|
+
["module_root", "build", "Debug", "bindings"],
|
|
73395
|
+
["module_root", "build", "Release", "bindings"],
|
|
73396
|
+
["module_root", "out", "Debug", "bindings"],
|
|
73397
|
+
["module_root", "Debug", "bindings"],
|
|
73398
|
+
["module_root", "out", "Release", "bindings"],
|
|
73399
|
+
["module_root", "Release", "bindings"],
|
|
73400
|
+
["module_root", "build", "default", "bindings"],
|
|
73401
|
+
["module_root", "compiled", "version", "platform", "arch", "bindings"],
|
|
73402
|
+
["module_root", "addon-build", "release", "install-root", "bindings"],
|
|
73403
|
+
["module_root", "addon-build", "debug", "install-root", "bindings"],
|
|
73404
|
+
["module_root", "addon-build", "default", "install-root", "bindings"],
|
|
73405
|
+
["module_root", "lib", "binding", "nodePreGyp", "bindings"]
|
|
73406
|
+
]
|
|
73407
|
+
};
|
|
73408
|
+
function bindings(opts) {
|
|
73409
|
+
if (typeof opts == "string") {
|
|
73410
|
+
opts = { bindings: opts };
|
|
73411
|
+
} else if (!opts) {
|
|
73412
|
+
opts = {};
|
|
73413
|
+
}
|
|
73414
|
+
Object.keys(defaults).map(function(i3) {
|
|
73415
|
+
if (!(i3 in opts))
|
|
73416
|
+
opts[i3] = defaults[i3];
|
|
73417
|
+
});
|
|
73418
|
+
if (!opts.module_root) {
|
|
73419
|
+
opts.module_root = exports.getRoot(exports.getFileName());
|
|
73420
|
+
}
|
|
73421
|
+
if (path.extname(opts.bindings) != ".node") {
|
|
73422
|
+
opts.bindings += ".node";
|
|
73423
|
+
}
|
|
73424
|
+
var requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
73425
|
+
var tries = [], i2 = 0, l = opts.try.length, n, b, err;
|
|
73426
|
+
for (;i2 < l; i2++) {
|
|
73427
|
+
n = join5.apply(null, opts.try[i2].map(function(p) {
|
|
73428
|
+
return opts[p] || p;
|
|
73429
|
+
}));
|
|
73430
|
+
tries.push(n);
|
|
73431
|
+
try {
|
|
73432
|
+
b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
|
|
73433
|
+
if (!opts.path) {
|
|
73434
|
+
b.path = n;
|
|
73435
|
+
}
|
|
73436
|
+
return b;
|
|
73437
|
+
} catch (e2) {
|
|
73438
|
+
if (e2.code !== "MODULE_NOT_FOUND" && e2.code !== "QUALIFIED_PATH_RESOLUTION_FAILED" && !/not find/i.test(e2.message)) {
|
|
73439
|
+
throw e2;
|
|
73440
|
+
}
|
|
73441
|
+
}
|
|
73442
|
+
}
|
|
73443
|
+
err = new Error(`Could not locate the bindings file. Tried:
|
|
73444
|
+
` + tries.map(function(a) {
|
|
73445
|
+
return opts.arrow + a;
|
|
73446
|
+
}).join(`
|
|
73447
|
+
`));
|
|
73448
|
+
err.tries = tries;
|
|
73449
|
+
throw err;
|
|
73450
|
+
}
|
|
73451
|
+
module.exports = exports = bindings;
|
|
73452
|
+
exports.getFileName = function getFileName(calling_file) {
|
|
73453
|
+
var { prepareStackTrace: origPST, stackTraceLimit: origSTL } = Error, dummy = {}, fileName;
|
|
73454
|
+
Error.stackTraceLimit = 10;
|
|
73455
|
+
Error.prepareStackTrace = function(e2, st) {
|
|
73456
|
+
for (var i2 = 0, l = st.length;i2 < l; i2++) {
|
|
73457
|
+
fileName = st[i2].getFileName();
|
|
73458
|
+
if (fileName !== __filename) {
|
|
73459
|
+
if (calling_file) {
|
|
73460
|
+
if (fileName !== calling_file) {
|
|
73461
|
+
return;
|
|
73462
|
+
}
|
|
73463
|
+
} else {
|
|
73464
|
+
return;
|
|
73465
|
+
}
|
|
73466
|
+
}
|
|
73467
|
+
}
|
|
73468
|
+
};
|
|
73469
|
+
Error.captureStackTrace(dummy);
|
|
73470
|
+
dummy.stack;
|
|
73471
|
+
Error.prepareStackTrace = origPST;
|
|
73472
|
+
Error.stackTraceLimit = origSTL;
|
|
73473
|
+
var fileSchema = "file://";
|
|
73474
|
+
if (fileName.indexOf(fileSchema) === 0) {
|
|
73475
|
+
fileName = fileURLToPath(fileName);
|
|
73476
|
+
}
|
|
73477
|
+
return fileName;
|
|
73478
|
+
};
|
|
73479
|
+
exports.getRoot = function getRoot(file2) {
|
|
73480
|
+
var dir = dirname2(file2), prev;
|
|
73481
|
+
while (true) {
|
|
73482
|
+
if (dir === ".") {
|
|
73483
|
+
dir = process.cwd();
|
|
73484
|
+
}
|
|
73485
|
+
if (exists(join5(dir, "package.json")) || exists(join5(dir, "node_modules"))) {
|
|
73486
|
+
return dir;
|
|
73487
|
+
}
|
|
73488
|
+
if (prev === dir) {
|
|
73489
|
+
throw new Error('Could not find module root given file: "' + file2 + '". Do you have a `package.json` file? ');
|
|
73490
|
+
}
|
|
73491
|
+
prev = dir;
|
|
73492
|
+
dir = join5(dir, "..");
|
|
73493
|
+
}
|
|
73494
|
+
};
|
|
73495
|
+
});
|
|
73496
|
+
|
|
73497
|
+
// ../../node_modules/better-sqlite3/lib/methods/wrappers.js
|
|
73498
|
+
var require_wrappers = __commonJS((exports) => {
|
|
73499
|
+
var { cppdb } = require_util3();
|
|
73500
|
+
exports.prepare = function prepare(sql) {
|
|
73501
|
+
return this[cppdb].prepare(sql, this, false);
|
|
73502
|
+
};
|
|
73503
|
+
exports.exec = function exec(sql) {
|
|
73504
|
+
this[cppdb].exec(sql);
|
|
73505
|
+
return this;
|
|
73506
|
+
};
|
|
73507
|
+
exports.close = function close() {
|
|
73508
|
+
this[cppdb].close();
|
|
73509
|
+
return this;
|
|
73510
|
+
};
|
|
73511
|
+
exports.loadExtension = function loadExtension(...args) {
|
|
73512
|
+
this[cppdb].loadExtension(...args);
|
|
73513
|
+
return this;
|
|
73514
|
+
};
|
|
73515
|
+
exports.defaultSafeIntegers = function defaultSafeIntegers(...args) {
|
|
73516
|
+
this[cppdb].defaultSafeIntegers(...args);
|
|
73517
|
+
return this;
|
|
73518
|
+
};
|
|
73519
|
+
exports.unsafeMode = function unsafeMode(...args) {
|
|
73520
|
+
this[cppdb].unsafeMode(...args);
|
|
73521
|
+
return this;
|
|
73522
|
+
};
|
|
73523
|
+
exports.getters = {
|
|
73524
|
+
name: {
|
|
73525
|
+
get: function name() {
|
|
73526
|
+
return this[cppdb].name;
|
|
73527
|
+
},
|
|
73528
|
+
enumerable: true
|
|
73529
|
+
},
|
|
73530
|
+
open: {
|
|
73531
|
+
get: function open() {
|
|
73532
|
+
return this[cppdb].open;
|
|
73533
|
+
},
|
|
73534
|
+
enumerable: true
|
|
73535
|
+
},
|
|
73536
|
+
inTransaction: {
|
|
73537
|
+
get: function inTransaction() {
|
|
73538
|
+
return this[cppdb].inTransaction;
|
|
73539
|
+
},
|
|
73540
|
+
enumerable: true
|
|
73541
|
+
},
|
|
73542
|
+
readonly: {
|
|
73543
|
+
get: function readonly() {
|
|
73544
|
+
return this[cppdb].readonly;
|
|
73545
|
+
},
|
|
73546
|
+
enumerable: true
|
|
73547
|
+
},
|
|
73548
|
+
memory: {
|
|
73549
|
+
get: function memory() {
|
|
73550
|
+
return this[cppdb].memory;
|
|
73551
|
+
},
|
|
73552
|
+
enumerable: true
|
|
73553
|
+
}
|
|
73554
|
+
};
|
|
73555
|
+
});
|
|
73556
|
+
|
|
73557
|
+
// ../../node_modules/better-sqlite3/lib/methods/transaction.js
|
|
73558
|
+
var require_transaction = __commonJS((exports, module) => {
|
|
73559
|
+
var { cppdb } = require_util3();
|
|
73560
|
+
var controllers = new WeakMap;
|
|
73561
|
+
module.exports = function transaction(fn) {
|
|
73562
|
+
if (typeof fn !== "function")
|
|
73563
|
+
throw new TypeError("Expected first argument to be a function");
|
|
73564
|
+
const db2 = this[cppdb];
|
|
73565
|
+
const controller = getController(db2, this);
|
|
73566
|
+
const { apply: apply2 } = Function.prototype;
|
|
73567
|
+
const properties = {
|
|
73568
|
+
default: { value: wrapTransaction(apply2, fn, db2, controller.default) },
|
|
73569
|
+
deferred: { value: wrapTransaction(apply2, fn, db2, controller.deferred) },
|
|
73570
|
+
immediate: { value: wrapTransaction(apply2, fn, db2, controller.immediate) },
|
|
73571
|
+
exclusive: { value: wrapTransaction(apply2, fn, db2, controller.exclusive) },
|
|
73572
|
+
database: { value: this, enumerable: true }
|
|
73573
|
+
};
|
|
73574
|
+
Object.defineProperties(properties.default.value, properties);
|
|
73575
|
+
Object.defineProperties(properties.deferred.value, properties);
|
|
73576
|
+
Object.defineProperties(properties.immediate.value, properties);
|
|
73577
|
+
Object.defineProperties(properties.exclusive.value, properties);
|
|
73578
|
+
return properties.default.value;
|
|
73579
|
+
};
|
|
73580
|
+
var getController = (db2, self2) => {
|
|
73581
|
+
let controller = controllers.get(db2);
|
|
73582
|
+
if (!controller) {
|
|
73583
|
+
const shared = {
|
|
73584
|
+
commit: db2.prepare("COMMIT", self2, false),
|
|
73585
|
+
rollback: db2.prepare("ROLLBACK", self2, false),
|
|
73586
|
+
savepoint: db2.prepare("SAVEPOINT `\t_bs3.\t`", self2, false),
|
|
73587
|
+
release: db2.prepare("RELEASE `\t_bs3.\t`", self2, false),
|
|
73588
|
+
rollbackTo: db2.prepare("ROLLBACK TO `\t_bs3.\t`", self2, false)
|
|
73589
|
+
};
|
|
73590
|
+
controllers.set(db2, controller = {
|
|
73591
|
+
default: Object.assign({ begin: db2.prepare("BEGIN", self2, false) }, shared),
|
|
73592
|
+
deferred: Object.assign({ begin: db2.prepare("BEGIN DEFERRED", self2, false) }, shared),
|
|
73593
|
+
immediate: Object.assign({ begin: db2.prepare("BEGIN IMMEDIATE", self2, false) }, shared),
|
|
73594
|
+
exclusive: Object.assign({ begin: db2.prepare("BEGIN EXCLUSIVE", self2, false) }, shared)
|
|
73595
|
+
});
|
|
73596
|
+
}
|
|
73597
|
+
return controller;
|
|
73598
|
+
};
|
|
73599
|
+
var wrapTransaction = (apply2, fn, db2, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {
|
|
73600
|
+
let before, after, undo;
|
|
73601
|
+
if (db2.inTransaction) {
|
|
73602
|
+
before = savepoint;
|
|
73603
|
+
after = release;
|
|
73604
|
+
undo = rollbackTo;
|
|
73605
|
+
} else {
|
|
73606
|
+
before = begin;
|
|
73607
|
+
after = commit;
|
|
73608
|
+
undo = rollback;
|
|
73609
|
+
}
|
|
73610
|
+
before.run();
|
|
73611
|
+
try {
|
|
73612
|
+
const result = apply2.call(fn, this, arguments);
|
|
73613
|
+
if (result && typeof result.then === "function") {
|
|
73614
|
+
throw new TypeError("Transaction function cannot return a promise");
|
|
73615
|
+
}
|
|
73616
|
+
after.run();
|
|
73617
|
+
return result;
|
|
73618
|
+
} catch (ex) {
|
|
73619
|
+
if (db2.inTransaction) {
|
|
73620
|
+
undo.run();
|
|
73621
|
+
if (undo !== rollback)
|
|
73622
|
+
after.run();
|
|
73623
|
+
}
|
|
73624
|
+
throw ex;
|
|
73625
|
+
}
|
|
73626
|
+
};
|
|
73627
|
+
});
|
|
73628
|
+
|
|
73629
|
+
// ../../node_modules/better-sqlite3/lib/methods/pragma.js
|
|
73630
|
+
var require_pragma = __commonJS((exports, module) => {
|
|
73631
|
+
var { getBooleanOption, cppdb } = require_util3();
|
|
73632
|
+
module.exports = function pragma(source, options) {
|
|
73633
|
+
if (options == null)
|
|
73634
|
+
options = {};
|
|
73635
|
+
if (typeof source !== "string")
|
|
73636
|
+
throw new TypeError("Expected first argument to be a string");
|
|
73637
|
+
if (typeof options !== "object")
|
|
73638
|
+
throw new TypeError("Expected second argument to be an options object");
|
|
73639
|
+
const simple = getBooleanOption(options, "simple");
|
|
73640
|
+
const stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true);
|
|
73641
|
+
return simple ? stmt.pluck().get() : stmt.all();
|
|
73642
|
+
};
|
|
73643
|
+
});
|
|
73644
|
+
|
|
73645
|
+
// ../../node_modules/better-sqlite3/lib/methods/backup.js
|
|
73646
|
+
var require_backup = __commonJS((exports, module) => {
|
|
73647
|
+
var fs4 = __require("fs");
|
|
73648
|
+
var path = __require("path");
|
|
73649
|
+
var { promisify: promisify2 } = __require("util");
|
|
73650
|
+
var { cppdb } = require_util3();
|
|
73651
|
+
var fsAccess = promisify2(fs4.access);
|
|
73652
|
+
module.exports = async function backup(filename, options) {
|
|
73653
|
+
if (options == null)
|
|
73654
|
+
options = {};
|
|
73655
|
+
if (typeof filename !== "string")
|
|
73656
|
+
throw new TypeError("Expected first argument to be a string");
|
|
73657
|
+
if (typeof options !== "object")
|
|
73658
|
+
throw new TypeError("Expected second argument to be an options object");
|
|
73659
|
+
filename = filename.trim();
|
|
73660
|
+
const attachedName = "attached" in options ? options.attached : "main";
|
|
73661
|
+
const handler13 = "progress" in options ? options.progress : null;
|
|
73662
|
+
if (!filename)
|
|
73663
|
+
throw new TypeError("Backup filename cannot be an empty string");
|
|
73664
|
+
if (filename === ":memory:")
|
|
73665
|
+
throw new TypeError('Invalid backup filename ":memory:"');
|
|
73666
|
+
if (typeof attachedName !== "string")
|
|
73667
|
+
throw new TypeError('Expected the "attached" option to be a string');
|
|
73668
|
+
if (!attachedName)
|
|
73669
|
+
throw new TypeError('The "attached" option cannot be an empty string');
|
|
73670
|
+
if (handler13 != null && typeof handler13 !== "function")
|
|
73671
|
+
throw new TypeError('Expected the "progress" option to be a function');
|
|
73672
|
+
await fsAccess(path.dirname(filename)).catch(() => {
|
|
73673
|
+
throw new TypeError("Cannot save backup because the directory does not exist");
|
|
73674
|
+
});
|
|
73675
|
+
const isNewFile = await fsAccess(filename).then(() => false, () => true);
|
|
73676
|
+
return runBackup(this[cppdb].backup(this, attachedName, filename, isNewFile), handler13 || null);
|
|
73677
|
+
};
|
|
73678
|
+
var runBackup = (backup, handler13) => {
|
|
73679
|
+
let rate = 0;
|
|
73680
|
+
let useDefault = true;
|
|
73681
|
+
return new Promise((resolve4, reject) => {
|
|
73682
|
+
setImmediate(function step() {
|
|
73683
|
+
try {
|
|
73684
|
+
const progress = backup.transfer(rate);
|
|
73685
|
+
if (!progress.remainingPages) {
|
|
73686
|
+
backup.close();
|
|
73687
|
+
resolve4(progress);
|
|
73688
|
+
return;
|
|
73689
|
+
}
|
|
73690
|
+
if (useDefault) {
|
|
73691
|
+
useDefault = false;
|
|
73692
|
+
rate = 100;
|
|
73693
|
+
}
|
|
73694
|
+
if (handler13) {
|
|
73695
|
+
const ret = handler13(progress);
|
|
73696
|
+
if (ret !== undefined) {
|
|
73697
|
+
if (typeof ret === "number" && ret === ret)
|
|
73698
|
+
rate = Math.max(0, Math.min(2147483647, Math.round(ret)));
|
|
73699
|
+
else
|
|
73700
|
+
throw new TypeError("Expected progress callback to return a number or undefined");
|
|
73701
|
+
}
|
|
73702
|
+
}
|
|
73703
|
+
setImmediate(step);
|
|
73704
|
+
} catch (err) {
|
|
73705
|
+
backup.close();
|
|
73706
|
+
reject(err);
|
|
73707
|
+
}
|
|
73708
|
+
});
|
|
73709
|
+
});
|
|
73710
|
+
};
|
|
73711
|
+
});
|
|
73712
|
+
|
|
73713
|
+
// ../../node_modules/better-sqlite3/lib/methods/serialize.js
|
|
73714
|
+
var require_serialize = __commonJS((exports, module) => {
|
|
73715
|
+
var { cppdb } = require_util3();
|
|
73716
|
+
module.exports = function serialize(options) {
|
|
73717
|
+
if (options == null)
|
|
73718
|
+
options = {};
|
|
73719
|
+
if (typeof options !== "object")
|
|
73720
|
+
throw new TypeError("Expected first argument to be an options object");
|
|
73721
|
+
const attachedName = "attached" in options ? options.attached : "main";
|
|
73722
|
+
if (typeof attachedName !== "string")
|
|
73723
|
+
throw new TypeError('Expected the "attached" option to be a string');
|
|
73724
|
+
if (!attachedName)
|
|
73725
|
+
throw new TypeError('The "attached" option cannot be an empty string');
|
|
73726
|
+
return this[cppdb].serialize(attachedName);
|
|
73727
|
+
};
|
|
73728
|
+
});
|
|
73729
|
+
|
|
73730
|
+
// ../../node_modules/better-sqlite3/lib/methods/function.js
|
|
73731
|
+
var require_function = __commonJS((exports, module) => {
|
|
73732
|
+
var { getBooleanOption, cppdb } = require_util3();
|
|
73733
|
+
module.exports = function defineFunction(name17, options, fn) {
|
|
73734
|
+
if (options == null)
|
|
73735
|
+
options = {};
|
|
73736
|
+
if (typeof options === "function") {
|
|
73737
|
+
fn = options;
|
|
73738
|
+
options = {};
|
|
73739
|
+
}
|
|
73740
|
+
if (typeof name17 !== "string")
|
|
73741
|
+
throw new TypeError("Expected first argument to be a string");
|
|
73742
|
+
if (typeof fn !== "function")
|
|
73743
|
+
throw new TypeError("Expected last argument to be a function");
|
|
73744
|
+
if (typeof options !== "object")
|
|
73745
|
+
throw new TypeError("Expected second argument to be an options object");
|
|
73746
|
+
if (!name17)
|
|
73747
|
+
throw new TypeError("User-defined function name cannot be an empty string");
|
|
73748
|
+
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
73749
|
+
const deterministic = getBooleanOption(options, "deterministic");
|
|
73750
|
+
const directOnly = getBooleanOption(options, "directOnly");
|
|
73751
|
+
const varargs = getBooleanOption(options, "varargs");
|
|
73752
|
+
let argCount = -1;
|
|
73753
|
+
if (!varargs) {
|
|
73754
|
+
argCount = fn.length;
|
|
73755
|
+
if (!Number.isInteger(argCount) || argCount < 0)
|
|
73756
|
+
throw new TypeError("Expected function.length to be a positive integer");
|
|
73757
|
+
if (argCount > 100)
|
|
73758
|
+
throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
73759
|
+
}
|
|
73760
|
+
this[cppdb].function(fn, name17, argCount, safeIntegers, deterministic, directOnly);
|
|
73761
|
+
return this;
|
|
73762
|
+
};
|
|
73763
|
+
});
|
|
73764
|
+
|
|
73765
|
+
// ../../node_modules/better-sqlite3/lib/methods/aggregate.js
|
|
73766
|
+
var require_aggregate = __commonJS((exports, module) => {
|
|
73767
|
+
var { getBooleanOption, cppdb } = require_util3();
|
|
73768
|
+
module.exports = function defineAggregate(name17, options) {
|
|
73769
|
+
if (typeof name17 !== "string")
|
|
73770
|
+
throw new TypeError("Expected first argument to be a string");
|
|
73771
|
+
if (typeof options !== "object" || options === null)
|
|
73772
|
+
throw new TypeError("Expected second argument to be an options object");
|
|
73773
|
+
if (!name17)
|
|
73774
|
+
throw new TypeError("User-defined function name cannot be an empty string");
|
|
73775
|
+
const start = "start" in options ? options.start : null;
|
|
73776
|
+
const step = getFunctionOption(options, "step", true);
|
|
73777
|
+
const inverse = getFunctionOption(options, "inverse", false);
|
|
73778
|
+
const result = getFunctionOption(options, "result", false);
|
|
73779
|
+
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
73780
|
+
const deterministic = getBooleanOption(options, "deterministic");
|
|
73781
|
+
const directOnly = getBooleanOption(options, "directOnly");
|
|
73782
|
+
const varargs = getBooleanOption(options, "varargs");
|
|
73783
|
+
let argCount = -1;
|
|
73784
|
+
if (!varargs) {
|
|
73785
|
+
argCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);
|
|
73786
|
+
if (argCount > 0)
|
|
73787
|
+
argCount -= 1;
|
|
73788
|
+
if (argCount > 100)
|
|
73789
|
+
throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
73790
|
+
}
|
|
73791
|
+
this[cppdb].aggregate(start, step, inverse, result, name17, argCount, safeIntegers, deterministic, directOnly);
|
|
73792
|
+
return this;
|
|
73793
|
+
};
|
|
73794
|
+
var getFunctionOption = (options, key, required2) => {
|
|
73795
|
+
const value = key in options ? options[key] : null;
|
|
73796
|
+
if (typeof value === "function")
|
|
73797
|
+
return value;
|
|
73798
|
+
if (value != null)
|
|
73799
|
+
throw new TypeError(`Expected the "${key}" option to be a function`);
|
|
73800
|
+
if (required2)
|
|
73801
|
+
throw new TypeError(`Missing required option "${key}"`);
|
|
73802
|
+
return null;
|
|
73803
|
+
};
|
|
73804
|
+
var getLength = ({ length }) => {
|
|
73805
|
+
if (Number.isInteger(length) && length >= 0)
|
|
73806
|
+
return length;
|
|
73807
|
+
throw new TypeError("Expected function.length to be a positive integer");
|
|
73808
|
+
};
|
|
73809
|
+
});
|
|
73810
|
+
|
|
73811
|
+
// ../../node_modules/better-sqlite3/lib/methods/table.js
|
|
73812
|
+
var require_table = __commonJS((exports, module) => {
|
|
73813
|
+
var { cppdb } = require_util3();
|
|
73814
|
+
module.exports = function defineTable(name17, factory) {
|
|
73815
|
+
if (typeof name17 !== "string")
|
|
73816
|
+
throw new TypeError("Expected first argument to be a string");
|
|
73817
|
+
if (!name17)
|
|
73818
|
+
throw new TypeError("Virtual table module name cannot be an empty string");
|
|
73819
|
+
let eponymous = false;
|
|
73820
|
+
if (typeof factory === "object" && factory !== null) {
|
|
73821
|
+
eponymous = true;
|
|
73822
|
+
factory = defer(parseTableDefinition(factory, "used", name17));
|
|
73823
|
+
} else {
|
|
73824
|
+
if (typeof factory !== "function")
|
|
73825
|
+
throw new TypeError("Expected second argument to be a function or a table definition object");
|
|
73826
|
+
factory = wrapFactory(factory);
|
|
73827
|
+
}
|
|
73828
|
+
this[cppdb].table(factory, name17, eponymous);
|
|
73829
|
+
return this;
|
|
73830
|
+
};
|
|
73831
|
+
function wrapFactory(factory) {
|
|
73832
|
+
return function virtualTableFactory(moduleName, databaseName, tableName, ...args) {
|
|
73833
|
+
const thisObject = {
|
|
73834
|
+
module: moduleName,
|
|
73835
|
+
database: databaseName,
|
|
73836
|
+
table: tableName
|
|
73837
|
+
};
|
|
73838
|
+
const def = apply2.call(factory, thisObject, args);
|
|
73839
|
+
if (typeof def !== "object" || def === null) {
|
|
73840
|
+
throw new TypeError(`Virtual table module "${moduleName}" did not return a table definition object`);
|
|
73841
|
+
}
|
|
73842
|
+
return parseTableDefinition(def, "returned", moduleName);
|
|
73843
|
+
};
|
|
73844
|
+
}
|
|
73845
|
+
function parseTableDefinition(def, verb, moduleName) {
|
|
73846
|
+
if (!hasOwnProperty10.call(def, "rows")) {
|
|
73847
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "rows" property`);
|
|
73848
|
+
}
|
|
73849
|
+
if (!hasOwnProperty10.call(def, "columns")) {
|
|
73850
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "columns" property`);
|
|
73851
|
+
}
|
|
73852
|
+
const rows = def.rows;
|
|
73853
|
+
if (typeof rows !== "function" || Object.getPrototypeOf(rows) !== GeneratorFunctionPrototype) {
|
|
73854
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "rows" property (should be a generator function)`);
|
|
73855
|
+
}
|
|
73856
|
+
let columns = def.columns;
|
|
73857
|
+
if (!Array.isArray(columns) || !(columns = [...columns]).every((x2) => typeof x2 === "string")) {
|
|
73858
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "columns" property (should be an array of strings)`);
|
|
73859
|
+
}
|
|
73860
|
+
if (columns.length !== new Set(columns).size) {
|
|
73861
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate column names`);
|
|
73862
|
+
}
|
|
73863
|
+
if (!columns.length) {
|
|
73864
|
+
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with zero columns`);
|
|
73865
|
+
}
|
|
73866
|
+
let parameters;
|
|
73867
|
+
if (hasOwnProperty10.call(def, "parameters")) {
|
|
73868
|
+
parameters = def.parameters;
|
|
73869
|
+
if (!Array.isArray(parameters) || !(parameters = [...parameters]).every((x2) => typeof x2 === "string")) {
|
|
73870
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "parameters" property (should be an array of strings)`);
|
|
73871
|
+
}
|
|
73872
|
+
} else {
|
|
73873
|
+
parameters = inferParameters(rows);
|
|
73874
|
+
}
|
|
73875
|
+
if (parameters.length !== new Set(parameters).size) {
|
|
73876
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate parameter names`);
|
|
73877
|
+
}
|
|
73878
|
+
if (parameters.length > 32) {
|
|
73879
|
+
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with more than the maximum number of 32 parameters`);
|
|
73880
|
+
}
|
|
73881
|
+
for (const parameter of parameters) {
|
|
73882
|
+
if (columns.includes(parameter)) {
|
|
73883
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with column "${parameter}" which was ambiguously defined as both a column and parameter`);
|
|
73884
|
+
}
|
|
73885
|
+
}
|
|
73886
|
+
let safeIntegers = 2;
|
|
73887
|
+
if (hasOwnProperty10.call(def, "safeIntegers")) {
|
|
73888
|
+
const bool = def.safeIntegers;
|
|
73889
|
+
if (typeof bool !== "boolean") {
|
|
73890
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "safeIntegers" property (should be a boolean)`);
|
|
73891
|
+
}
|
|
73892
|
+
safeIntegers = +bool;
|
|
73893
|
+
}
|
|
73894
|
+
let directOnly = false;
|
|
73895
|
+
if (hasOwnProperty10.call(def, "directOnly")) {
|
|
73896
|
+
directOnly = def.directOnly;
|
|
73897
|
+
if (typeof directOnly !== "boolean") {
|
|
73898
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "directOnly" property (should be a boolean)`);
|
|
73899
|
+
}
|
|
73900
|
+
}
|
|
73901
|
+
const columnDefinitions = [
|
|
73902
|
+
...parameters.map(identifier).map((str) => `${str} HIDDEN`),
|
|
73903
|
+
...columns.map(identifier)
|
|
73904
|
+
];
|
|
73905
|
+
return [
|
|
73906
|
+
`CREATE TABLE x(${columnDefinitions.join(", ")});`,
|
|
73907
|
+
wrapGenerator(rows, new Map(columns.map((x2, i2) => [x2, parameters.length + i2])), moduleName),
|
|
73908
|
+
parameters,
|
|
73909
|
+
safeIntegers,
|
|
73910
|
+
directOnly
|
|
73911
|
+
];
|
|
73912
|
+
}
|
|
73913
|
+
function wrapGenerator(generator, columnMap, moduleName) {
|
|
73914
|
+
return function* virtualTable(...args) {
|
|
73915
|
+
const output = args.map((x2) => Buffer.isBuffer(x2) ? Buffer.from(x2) : x2);
|
|
73916
|
+
for (let i2 = 0;i2 < columnMap.size; ++i2) {
|
|
73917
|
+
output.push(null);
|
|
73918
|
+
}
|
|
73919
|
+
for (const row of generator(...args)) {
|
|
73920
|
+
if (Array.isArray(row)) {
|
|
73921
|
+
extractRowArray(row, output, columnMap.size, moduleName);
|
|
73922
|
+
yield output;
|
|
73923
|
+
} else if (typeof row === "object" && row !== null) {
|
|
73924
|
+
extractRowObject(row, output, columnMap, moduleName);
|
|
73925
|
+
yield output;
|
|
73926
|
+
} else {
|
|
73927
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded something that isn't a valid row object`);
|
|
73928
|
+
}
|
|
73929
|
+
}
|
|
73930
|
+
};
|
|
73931
|
+
}
|
|
73932
|
+
function extractRowArray(row, output, columnCount, moduleName) {
|
|
73933
|
+
if (row.length !== columnCount) {
|
|
73934
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an incorrect number of columns`);
|
|
73935
|
+
}
|
|
73936
|
+
const offset = output.length - columnCount;
|
|
73937
|
+
for (let i2 = 0;i2 < columnCount; ++i2) {
|
|
73938
|
+
output[i2 + offset] = row[i2];
|
|
73939
|
+
}
|
|
73940
|
+
}
|
|
73941
|
+
function extractRowObject(row, output, columnMap, moduleName) {
|
|
73942
|
+
let count = 0;
|
|
73943
|
+
for (const key of Object.keys(row)) {
|
|
73944
|
+
const index = columnMap.get(key);
|
|
73945
|
+
if (index === undefined) {
|
|
73946
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an undeclared column "${key}"`);
|
|
73947
|
+
}
|
|
73948
|
+
output[index] = row[key];
|
|
73949
|
+
count += 1;
|
|
73950
|
+
}
|
|
73951
|
+
if (count !== columnMap.size) {
|
|
73952
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with missing columns`);
|
|
73953
|
+
}
|
|
73954
|
+
}
|
|
73955
|
+
function inferParameters({ length }) {
|
|
73956
|
+
if (!Number.isInteger(length) || length < 0) {
|
|
73957
|
+
throw new TypeError("Expected function.length to be a positive integer");
|
|
73958
|
+
}
|
|
73959
|
+
const params = [];
|
|
73960
|
+
for (let i2 = 0;i2 < length; ++i2) {
|
|
73961
|
+
params.push(`$${i2 + 1}`);
|
|
73962
|
+
}
|
|
73963
|
+
return params;
|
|
73964
|
+
}
|
|
73965
|
+
var { hasOwnProperty: hasOwnProperty10 } = Object.prototype;
|
|
73966
|
+
var { apply: apply2 } = Function.prototype;
|
|
73967
|
+
var GeneratorFunctionPrototype = Object.getPrototypeOf(function* () {});
|
|
73968
|
+
var identifier = (str) => `"${str.replace(/"/g, '""')}"`;
|
|
73969
|
+
var defer = (x2) => () => x2;
|
|
73970
|
+
});
|
|
73971
|
+
|
|
73972
|
+
// ../../node_modules/better-sqlite3/lib/methods/inspect.js
|
|
73973
|
+
var require_inspect = __commonJS((exports, module) => {
|
|
73974
|
+
var DatabaseInspection = function Database() {};
|
|
73975
|
+
module.exports = function inspect(depth, opts) {
|
|
73976
|
+
return Object.assign(new DatabaseInspection, this);
|
|
73977
|
+
};
|
|
73978
|
+
});
|
|
73979
|
+
|
|
73980
|
+
// ../../node_modules/better-sqlite3/lib/database.js
|
|
73981
|
+
var require_database = __commonJS((exports, module) => {
|
|
73982
|
+
var fs4 = __require("fs");
|
|
73983
|
+
var path = __require("path");
|
|
73984
|
+
var util3 = require_util3();
|
|
73985
|
+
var SqliteError = require_sqlite_error();
|
|
73986
|
+
var DEFAULT_ADDON;
|
|
73987
|
+
function Database(filenameGiven, options) {
|
|
73988
|
+
if (new.target == null) {
|
|
73989
|
+
return new Database(filenameGiven, options);
|
|
73990
|
+
}
|
|
73991
|
+
let buffer;
|
|
73992
|
+
if (Buffer.isBuffer(filenameGiven)) {
|
|
73993
|
+
buffer = filenameGiven;
|
|
73994
|
+
filenameGiven = ":memory:";
|
|
73995
|
+
}
|
|
73996
|
+
if (filenameGiven == null)
|
|
73997
|
+
filenameGiven = "";
|
|
73998
|
+
if (options == null)
|
|
73999
|
+
options = {};
|
|
74000
|
+
if (typeof filenameGiven !== "string")
|
|
74001
|
+
throw new TypeError("Expected first argument to be a string");
|
|
74002
|
+
if (typeof options !== "object")
|
|
74003
|
+
throw new TypeError("Expected second argument to be an options object");
|
|
74004
|
+
if ("readOnly" in options)
|
|
74005
|
+
throw new TypeError('Misspelled option "readOnly" should be "readonly"');
|
|
74006
|
+
if ("memory" in options)
|
|
74007
|
+
throw new TypeError('Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)');
|
|
74008
|
+
const filename = filenameGiven.trim();
|
|
74009
|
+
const anonymous = filename === "" || filename === ":memory:";
|
|
74010
|
+
const readonly2 = util3.getBooleanOption(options, "readonly");
|
|
74011
|
+
const fileMustExist = util3.getBooleanOption(options, "fileMustExist");
|
|
74012
|
+
const timeout = "timeout" in options ? options.timeout : 5000;
|
|
74013
|
+
const verbose = "verbose" in options ? options.verbose : null;
|
|
74014
|
+
const nativeBinding = "nativeBinding" in options ? options.nativeBinding : null;
|
|
74015
|
+
if (readonly2 && anonymous && !buffer)
|
|
74016
|
+
throw new TypeError("In-memory/temporary databases cannot be readonly");
|
|
74017
|
+
if (!Number.isInteger(timeout) || timeout < 0)
|
|
74018
|
+
throw new TypeError('Expected the "timeout" option to be a positive integer');
|
|
74019
|
+
if (timeout > 2147483647)
|
|
74020
|
+
throw new RangeError('Option "timeout" cannot be greater than 2147483647');
|
|
74021
|
+
if (verbose != null && typeof verbose !== "function")
|
|
74022
|
+
throw new TypeError('Expected the "verbose" option to be a function');
|
|
74023
|
+
if (nativeBinding != null && typeof nativeBinding !== "string" && typeof nativeBinding !== "object")
|
|
74024
|
+
throw new TypeError('Expected the "nativeBinding" option to be a string or addon object');
|
|
74025
|
+
let addon;
|
|
74026
|
+
if (nativeBinding == null) {
|
|
74027
|
+
addon = DEFAULT_ADDON || (DEFAULT_ADDON = require_bindings()("better_sqlite3.node"));
|
|
74028
|
+
} else if (typeof nativeBinding === "string") {
|
|
74029
|
+
const requireFunc = typeof __non_webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
74030
|
+
addon = requireFunc(path.resolve(nativeBinding).replace(/(\.node)?$/, ".node"));
|
|
74031
|
+
} else {
|
|
74032
|
+
addon = nativeBinding;
|
|
74033
|
+
}
|
|
74034
|
+
if (!addon.isInitialized) {
|
|
74035
|
+
addon.setErrorConstructor(SqliteError);
|
|
74036
|
+
addon.isInitialized = true;
|
|
74037
|
+
}
|
|
74038
|
+
if (!anonymous && !filename.startsWith("file:") && !fs4.existsSync(path.dirname(filename))) {
|
|
74039
|
+
throw new TypeError("Cannot open database because the directory does not exist");
|
|
74040
|
+
}
|
|
74041
|
+
Object.defineProperties(this, {
|
|
74042
|
+
[util3.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly2, fileMustExist, timeout, verbose || null, buffer || null) },
|
|
74043
|
+
...wrappers.getters
|
|
74044
|
+
});
|
|
74045
|
+
}
|
|
74046
|
+
var wrappers = require_wrappers();
|
|
74047
|
+
Database.prototype.prepare = wrappers.prepare;
|
|
74048
|
+
Database.prototype.transaction = require_transaction();
|
|
74049
|
+
Database.prototype.pragma = require_pragma();
|
|
74050
|
+
Database.prototype.backup = require_backup();
|
|
74051
|
+
Database.prototype.serialize = require_serialize();
|
|
74052
|
+
Database.prototype.function = require_function();
|
|
74053
|
+
Database.prototype.aggregate = require_aggregate();
|
|
74054
|
+
Database.prototype.table = require_table();
|
|
74055
|
+
Database.prototype.loadExtension = wrappers.loadExtension;
|
|
74056
|
+
Database.prototype.exec = wrappers.exec;
|
|
74057
|
+
Database.prototype.close = wrappers.close;
|
|
74058
|
+
Database.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
|
|
74059
|
+
Database.prototype.unsafeMode = wrappers.unsafeMode;
|
|
74060
|
+
Database.prototype[util3.inspect] = require_inspect();
|
|
74061
|
+
module.exports = Database;
|
|
74062
|
+
});
|
|
74063
|
+
|
|
74064
|
+
// ../../node_modules/better-sqlite3/lib/index.js
|
|
74065
|
+
var require_lib2 = __commonJS((exports, module) => {
|
|
74066
|
+
module.exports = require_database();
|
|
74067
|
+
module.exports.SqliteError = require_sqlite_error();
|
|
74068
|
+
});
|
|
74069
|
+
|
|
74070
|
+
// ../cli-shared/src/sqlite-memory-store.ts
|
|
74071
|
+
import { randomUUID } from "node:crypto";
|
|
74072
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
74073
|
+
import { mkdir as mkdir2, rename as rename2 } from "node:fs/promises";
|
|
74074
|
+
import { dirname as dirname2, resolve as resolve4 } from "node:path";
|
|
74075
|
+
var import_better_sqlite3, SQLiteMemoryStore;
|
|
74076
|
+
var init_sqlite_memory_store = __esm(() => {
|
|
74077
|
+
import_better_sqlite3 = __toESM(require_lib2(), 1);
|
|
74078
|
+
SQLiteMemoryStore = class SQLiteMemoryStore {
|
|
74079
|
+
db = null;
|
|
74080
|
+
dbPromise = null;
|
|
74081
|
+
config;
|
|
74082
|
+
currentScope;
|
|
74083
|
+
maxRetries = 3;
|
|
74084
|
+
retryDelay = 100;
|
|
74085
|
+
static SORT_COLUMNS = {
|
|
74086
|
+
created: "created_at",
|
|
74087
|
+
updated: "updated_at",
|
|
74088
|
+
accessed: "last_accessed",
|
|
74089
|
+
name: "name"
|
|
74090
|
+
};
|
|
74091
|
+
static ALLOWED_SORT_ORDERS = ["asc", "desc"];
|
|
74092
|
+
static ALLOWED_PRIORITIES = ["low", "medium", "high", "critical"];
|
|
74093
|
+
constructor(config3, scope) {
|
|
74094
|
+
this.config = config3;
|
|
74095
|
+
this.currentScope = scope;
|
|
74096
|
+
}
|
|
74097
|
+
async initializeDatabase() {
|
|
74098
|
+
if (this.dbPromise) {
|
|
74099
|
+
return this.dbPromise;
|
|
74100
|
+
}
|
|
74101
|
+
this.dbPromise = (async () => {
|
|
74102
|
+
if (this.db) {
|
|
74103
|
+
return this.db;
|
|
74104
|
+
}
|
|
74105
|
+
const dbPath = this.resolvePath(this.config.path || "~/.config/polka-codes/memory.sqlite");
|
|
74106
|
+
try {
|
|
74107
|
+
const dir = dirname2(dbPath);
|
|
74108
|
+
if (!existsSync3(dir)) {
|
|
74109
|
+
await mkdir2(dir, { recursive: true, mode: 448 });
|
|
74110
|
+
}
|
|
74111
|
+
if (!existsSync3(dbPath)) {
|
|
74112
|
+
const { openSync, closeSync } = await import("node:fs");
|
|
74113
|
+
const fd = openSync(dbPath, "w");
|
|
74114
|
+
closeSync(fd);
|
|
74115
|
+
await import("node:fs/promises").then((fs4) => fs4.chmod(dbPath, 384));
|
|
74116
|
+
}
|
|
74117
|
+
const db2 = new import_better_sqlite3.default(dbPath, {
|
|
74118
|
+
verbose: process.env.SQLITE_DEBUG ? console.log : undefined
|
|
74119
|
+
});
|
|
74120
|
+
this.configurePragmas(db2);
|
|
74121
|
+
this.checkIntegrity(db2);
|
|
74122
|
+
this.initializeSchema(db2);
|
|
74123
|
+
this.db = db2;
|
|
74124
|
+
return db2;
|
|
74125
|
+
} catch (error48) {
|
|
74126
|
+
console.error("[SQLiteMemoryStore] Initialization failed:", error48);
|
|
74127
|
+
if (existsSync3(dbPath)) {
|
|
74128
|
+
const backupPath = `${dbPath}.corrupted.${Date.now()}`;
|
|
74129
|
+
console.warn(`[SQLiteMemoryStore] Backing up corrupted database to: ${backupPath}`);
|
|
74130
|
+
try {
|
|
74131
|
+
await rename2(dbPath, backupPath);
|
|
74132
|
+
} catch (backupError) {
|
|
74133
|
+
console.error("[SQLiteMemoryStore] Failed to backup corrupted database:", backupError);
|
|
74134
|
+
this.dbPromise = null;
|
|
74135
|
+
throw backupError;
|
|
74136
|
+
}
|
|
74137
|
+
this.dbPromise = null;
|
|
74138
|
+
return this.initializeDatabase();
|
|
74139
|
+
}
|
|
74140
|
+
this.dbPromise = null;
|
|
74141
|
+
throw error48;
|
|
74142
|
+
}
|
|
74143
|
+
})();
|
|
74144
|
+
return this.dbPromise;
|
|
74145
|
+
}
|
|
74146
|
+
configurePragmas(db2) {
|
|
74147
|
+
db2.pragma("journal_mode = WAL");
|
|
74148
|
+
db2.pragma("synchronous = NORMAL");
|
|
74149
|
+
db2.pragma("busy_timeout = 5000");
|
|
74150
|
+
db2.pragma("foreign_keys = ON");
|
|
74151
|
+
db2.pragma("temp_store = MEMORY");
|
|
74152
|
+
db2.pragma("mmap_size = 30000000000");
|
|
74153
|
+
db2.pragma("page_size = 4096");
|
|
74154
|
+
}
|
|
74155
|
+
checkIntegrity(db2) {
|
|
74156
|
+
try {
|
|
74157
|
+
const result = db2.pragma("integrity_check", { simple: true });
|
|
74158
|
+
if (result !== "ok") {
|
|
74159
|
+
throw new Error(`Database integrity check failed: ${result}`);
|
|
74160
|
+
}
|
|
74161
|
+
} catch (error48) {
|
|
74162
|
+
console.error("[SQLiteMemoryStore] Integrity check failed:", error48);
|
|
74163
|
+
throw new Error("Database is corrupted");
|
|
74164
|
+
}
|
|
74165
|
+
}
|
|
74166
|
+
initializeSchema(db2) {
|
|
74167
|
+
db2.exec(`
|
|
74168
|
+
CREATE TABLE IF NOT EXISTS memory_entries (
|
|
74169
|
+
id TEXT PRIMARY KEY,
|
|
74170
|
+
name TEXT NOT NULL CHECK(length(name) > 0),
|
|
74171
|
+
scope TEXT NOT NULL CHECK(scope IN ('global') OR scope LIKE 'project:%'),
|
|
74172
|
+
content TEXT NOT NULL CHECK(length(content) > 0),
|
|
74173
|
+
entry_type TEXT NOT NULL CHECK(length(entry_type) > 0),
|
|
74174
|
+
status TEXT CHECK(status IS NULL OR length(status) > 0),
|
|
74175
|
+
priority TEXT CHECK(priority IS NULL OR priority IN ('low', 'medium', 'high', 'critical')),
|
|
74176
|
+
tags TEXT CHECK(tags IS NULL OR length(tags) > 0),
|
|
74177
|
+
metadata TEXT CHECK(metadata IS NULL OR json_valid(metadata)),
|
|
74178
|
+
created_at INTEGER NOT NULL CHECK(created_at > 0),
|
|
74179
|
+
updated_at INTEGER NOT NULL CHECK(updated_at > 0),
|
|
74180
|
+
last_accessed INTEGER NOT NULL CHECK(last_accessed > 0),
|
|
74181
|
+
UNIQUE(name, scope)
|
|
74182
|
+
)
|
|
74183
|
+
`);
|
|
74184
|
+
db2.exec(`
|
|
74185
|
+
CREATE INDEX IF NOT EXISTS idx_memory_entries_scope_type ON memory_entries(scope, entry_type);
|
|
74186
|
+
CREATE INDEX IF NOT EXISTS idx_memory_entries_updated ON memory_entries(updated_at);
|
|
74187
|
+
`);
|
|
74188
|
+
}
|
|
74189
|
+
async getDatabase() {
|
|
74190
|
+
if (!this.db) {
|
|
74191
|
+
this.db = await this.initializeDatabase();
|
|
74192
|
+
}
|
|
74193
|
+
return this.db;
|
|
74194
|
+
}
|
|
74195
|
+
resolvePath(path) {
|
|
74196
|
+
if (path.startsWith("~")) {
|
|
74197
|
+
const home = process.env.HOME || process.env.USERPROFILE || ".";
|
|
74198
|
+
if (home === ".") {
|
|
74199
|
+
throw new Error("Cannot resolve home directory");
|
|
74200
|
+
}
|
|
74201
|
+
const expanded = `${home}${path.slice(1)}`;
|
|
74202
|
+
const resolved = resolve4(expanded);
|
|
74203
|
+
const sep = process.platform === "win32" ? "\\" : "/";
|
|
74204
|
+
if (resolved !== home && !resolved.startsWith(home + sep)) {
|
|
74205
|
+
throw new Error(`Path escapes home directory: ${path}`);
|
|
74206
|
+
}
|
|
74207
|
+
return resolved;
|
|
74208
|
+
}
|
|
74209
|
+
return resolve4(path);
|
|
74210
|
+
}
|
|
74211
|
+
generateUUID() {
|
|
74212
|
+
return randomUUID();
|
|
74213
|
+
}
|
|
74214
|
+
now() {
|
|
74215
|
+
return Date.now();
|
|
74216
|
+
}
|
|
74217
|
+
sleep(ms) {
|
|
74218
|
+
return new Promise((resolve5) => setTimeout(resolve5, ms));
|
|
74219
|
+
}
|
|
74220
|
+
isRetryableError(error48) {
|
|
74221
|
+
if (error48 instanceof Error) {
|
|
74222
|
+
const message = error48.message.toLowerCase();
|
|
74223
|
+
return message.includes("database is locked") || message.includes("database is busy") || message.includes("sqlite_busy") || message.includes("sqlite_locked");
|
|
74224
|
+
}
|
|
74225
|
+
return false;
|
|
74226
|
+
}
|
|
74227
|
+
async transaction(callback, options = {}) {
|
|
74228
|
+
const db2 = await this.getDatabase();
|
|
74229
|
+
const retries = options.retries ?? this.maxRetries;
|
|
74230
|
+
for (let attempt = 0;attempt < retries; attempt++) {
|
|
74231
|
+
try {
|
|
74232
|
+
db2.exec("BEGIN IMMEDIATE");
|
|
74233
|
+
const result = await callback();
|
|
74234
|
+
db2.exec("COMMIT");
|
|
74235
|
+
return result;
|
|
74236
|
+
} catch (error48) {
|
|
74237
|
+
try {
|
|
74238
|
+
db2.exec("ROLLBACK");
|
|
74239
|
+
} catch (rollbackError) {
|
|
74240
|
+
console.error("[SQLiteMemoryStore] Rollback failed:", rollbackError);
|
|
74241
|
+
}
|
|
74242
|
+
const isRetryable = this.isRetryableError(error48);
|
|
74243
|
+
if (isRetryable && attempt < retries - 1) {
|
|
74244
|
+
const delay2 = this.retryDelay * 2 ** attempt;
|
|
74245
|
+
console.warn(`[SQLiteMemoryStore] Retryable error, retrying in ${delay2}ms...`);
|
|
74246
|
+
await this.sleep(delay2);
|
|
74247
|
+
continue;
|
|
74248
|
+
}
|
|
74249
|
+
throw error48;
|
|
74250
|
+
}
|
|
74251
|
+
}
|
|
74252
|
+
throw new Error("Maximum retries exceeded");
|
|
74253
|
+
}
|
|
74254
|
+
async readMemory(topic) {
|
|
74255
|
+
const db2 = await this.getDatabase();
|
|
74256
|
+
const scope = this.currentScope;
|
|
74257
|
+
return this.transaction(async () => {
|
|
74258
|
+
const stmt = db2.prepare("SELECT content FROM memory_entries WHERE name = ? AND scope = ?");
|
|
74259
|
+
const row = stmt.get(topic, scope);
|
|
74260
|
+
if (row) {
|
|
74261
|
+
const updateStmt = db2.prepare("UPDATE memory_entries SET last_accessed = ? WHERE name = ? AND scope = ?");
|
|
74262
|
+
updateStmt.run(this.now(), topic, scope);
|
|
74263
|
+
}
|
|
74264
|
+
return row?.content;
|
|
74265
|
+
});
|
|
74266
|
+
}
|
|
74267
|
+
async updateMemoryInternal(db2, operation, topic, content, metadata) {
|
|
74268
|
+
const scope = this.currentScope;
|
|
74269
|
+
const now2 = this.now();
|
|
74270
|
+
if (operation === "remove") {
|
|
74271
|
+
const stmt = db2.prepare("DELETE FROM memory_entries WHERE name = ? AND scope = ?");
|
|
74272
|
+
stmt.run(topic, scope);
|
|
74273
|
+
return;
|
|
74274
|
+
}
|
|
74275
|
+
const existingStmt = db2.prepare("SELECT content, entry_type, status, priority, tags FROM memory_entries WHERE name = ? AND scope = ?");
|
|
74276
|
+
const existing = existingStmt.get(topic, scope);
|
|
74277
|
+
let finalContent;
|
|
74278
|
+
let entry_type;
|
|
74279
|
+
let status;
|
|
74280
|
+
let priority;
|
|
74281
|
+
let tags;
|
|
74282
|
+
if (existing) {
|
|
74283
|
+
if (operation === "append") {
|
|
74284
|
+
if (!content) {
|
|
74285
|
+
throw new Error("Content is required for append operation.");
|
|
74286
|
+
}
|
|
74287
|
+
finalContent = `${existing.content}
|
|
74288
|
+
${content}`;
|
|
74289
|
+
} else {
|
|
74290
|
+
if (!content) {
|
|
74291
|
+
throw new Error("Content is required for replace operation.");
|
|
74292
|
+
}
|
|
74293
|
+
finalContent = content;
|
|
74294
|
+
}
|
|
74295
|
+
entry_type = metadata?.entry_type || existing.entry_type;
|
|
74296
|
+
status = metadata?.status || existing.status;
|
|
74297
|
+
priority = metadata?.priority || existing.priority;
|
|
74298
|
+
tags = metadata?.tags || existing.tags;
|
|
74299
|
+
} else {
|
|
74300
|
+
if (!content) {
|
|
74301
|
+
throw new Error("Content is required for new memory entries.");
|
|
74302
|
+
}
|
|
74303
|
+
finalContent = content;
|
|
74304
|
+
entry_type = metadata?.entry_type || "note";
|
|
74305
|
+
status = metadata?.status;
|
|
74306
|
+
priority = metadata?.priority;
|
|
74307
|
+
tags = metadata?.tags;
|
|
74308
|
+
}
|
|
74309
|
+
const upsertStmt = db2.prepare(`
|
|
74310
|
+
INSERT INTO memory_entries (id, name, scope, content, entry_type, status, priority, tags, created_at, updated_at, last_accessed)
|
|
74311
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
74312
|
+
ON CONFLICT(name, scope) DO UPDATE SET
|
|
74313
|
+
content = excluded.content,
|
|
74314
|
+
entry_type = excluded.entry_type,
|
|
74315
|
+
status = excluded.status,
|
|
74316
|
+
priority = excluded.priority,
|
|
74317
|
+
tags = excluded.tags,
|
|
74318
|
+
updated_at = excluded.updated_at,
|
|
74319
|
+
last_accessed = excluded.last_accessed
|
|
74320
|
+
`);
|
|
74321
|
+
upsertStmt.run(this.generateUUID(), topic, scope, finalContent, entry_type, status || null, priority || null, tags || null, now2, now2, now2);
|
|
74322
|
+
}
|
|
74323
|
+
async updateMemory(operation, topic, content, metadata) {
|
|
74324
|
+
return this.transaction(async () => {
|
|
74325
|
+
const db2 = await this.getDatabase();
|
|
74326
|
+
await this.updateMemoryInternal(db2, operation, topic, content, metadata);
|
|
74327
|
+
});
|
|
74328
|
+
}
|
|
74329
|
+
async queryMemory(query = {}, options = {}) {
|
|
74330
|
+
const db2 = await this.getDatabase();
|
|
74331
|
+
const { sql, params } = this.buildQuery(query, options);
|
|
74332
|
+
if (options.operation === "count") {
|
|
74333
|
+
const countStmt = db2.prepare(`SELECT COUNT(*) as count FROM (${sql})`);
|
|
74334
|
+
const result = countStmt.get(...params);
|
|
74335
|
+
return result.count;
|
|
74336
|
+
}
|
|
74337
|
+
if (options.operation === "delete") {
|
|
74338
|
+
const deleteStmt = db2.prepare(`DELETE FROM memory_entries WHERE id IN (SELECT id FROM (${sql}))`);
|
|
74339
|
+
const info = deleteStmt.run(...params);
|
|
74340
|
+
return info.changes;
|
|
74341
|
+
}
|
|
74342
|
+
const stmt = db2.prepare(sql);
|
|
74343
|
+
return stmt.all(...params);
|
|
74344
|
+
}
|
|
74345
|
+
buildQuery(query, _options) {
|
|
74346
|
+
const conditions = [];
|
|
74347
|
+
const params = [];
|
|
74348
|
+
let sql = "SELECT * FROM memory_entries WHERE 1=1";
|
|
74349
|
+
const scope = query.scope === "auto" ? this.currentScope : query.scope;
|
|
74350
|
+
if (scope === "global") {
|
|
74351
|
+
conditions.push("scope = ?");
|
|
74352
|
+
params.push("global");
|
|
74353
|
+
} else if (scope === "project" || !scope && this.currentScope !== "global") {
|
|
74354
|
+
conditions.push("scope = ?");
|
|
74355
|
+
params.push(this.currentScope);
|
|
74356
|
+
}
|
|
74357
|
+
if (query.type) {
|
|
74358
|
+
if (!query.type.trim()) {
|
|
74359
|
+
throw new Error("Type cannot be empty");
|
|
74360
|
+
}
|
|
74361
|
+
conditions.push("entry_type = ?");
|
|
74362
|
+
params.push(query.type.trim());
|
|
74363
|
+
}
|
|
74364
|
+
if (query.status) {
|
|
74365
|
+
conditions.push("status = ?");
|
|
74366
|
+
params.push(query.status);
|
|
74367
|
+
}
|
|
74368
|
+
if (query.priority) {
|
|
74369
|
+
if (!SQLiteMemoryStore.ALLOWED_PRIORITIES.includes(query.priority)) {
|
|
74370
|
+
throw new Error(`Invalid priority: ${query.priority}`);
|
|
74371
|
+
}
|
|
74372
|
+
conditions.push("priority = ?");
|
|
74373
|
+
params.push(query.priority);
|
|
74374
|
+
}
|
|
74375
|
+
if (query.tags) {
|
|
74376
|
+
const tags = Array.isArray(query.tags) ? query.tags : [query.tags];
|
|
74377
|
+
for (const tag of tags) {
|
|
74378
|
+
const trimmed = tag.trim();
|
|
74379
|
+
if (!trimmed) {
|
|
74380
|
+
throw new Error("Tags cannot be empty");
|
|
74381
|
+
}
|
|
74382
|
+
conditions.push("(tags = ? OR tags LIKE ? OR tags LIKE ? OR tags LIKE ?)");
|
|
74383
|
+
params.push(trimmed, `${trimmed},%`, `%,${trimmed}`, `%,${trimmed},%`);
|
|
74384
|
+
}
|
|
74385
|
+
}
|
|
74386
|
+
if (query.search) {
|
|
74387
|
+
const searchTerm = query.search.trim();
|
|
74388
|
+
const sanitized = searchTerm.replace(/[\\_%]/g, "\\$&");
|
|
74389
|
+
conditions.push("(content LIKE ? OR name LIKE ?)");
|
|
74390
|
+
params.push(`%${sanitized}%`, `%${sanitized}%`);
|
|
74391
|
+
}
|
|
74392
|
+
if (query.createdAfter) {
|
|
74393
|
+
conditions.push("created_at >= ?");
|
|
74394
|
+
params.push(query.createdAfter);
|
|
74395
|
+
}
|
|
74396
|
+
if (query.createdBefore) {
|
|
74397
|
+
conditions.push("created_at <= ?");
|
|
74398
|
+
params.push(query.createdBefore);
|
|
74399
|
+
}
|
|
74400
|
+
if (query.updatedAfter) {
|
|
74401
|
+
conditions.push("updated_at >= ?");
|
|
74402
|
+
params.push(query.updatedAfter);
|
|
74403
|
+
}
|
|
74404
|
+
if (query.updatedBefore) {
|
|
74405
|
+
conditions.push("updated_at <= ?");
|
|
74406
|
+
params.push(query.updatedBefore);
|
|
74407
|
+
}
|
|
74408
|
+
if (conditions.length > 0) {
|
|
74409
|
+
sql += ` AND ${conditions.join(" AND ")}`;
|
|
74410
|
+
}
|
|
74411
|
+
if (query.sortBy) {
|
|
74412
|
+
const column = SQLiteMemoryStore.SORT_COLUMNS[query.sortBy];
|
|
74413
|
+
if (!column) {
|
|
74414
|
+
throw new Error(`Invalid sortBy: ${query.sortBy}`);
|
|
74415
|
+
}
|
|
74416
|
+
const order = query.sortOrder || "desc";
|
|
74417
|
+
if (!SQLiteMemoryStore.ALLOWED_SORT_ORDERS.includes(order)) {
|
|
74418
|
+
throw new Error(`Invalid sortOrder: ${order}`);
|
|
74419
|
+
}
|
|
74420
|
+
sql += ` ORDER BY ${column} ${order.toUpperCase()}`;
|
|
74421
|
+
}
|
|
74422
|
+
if (query.limit) {
|
|
74423
|
+
const limit = Number(query.limit);
|
|
74424
|
+
if (Number.isNaN(limit) || limit < 1 || limit > 1e4) {
|
|
74425
|
+
throw new Error("Limit must be between 1 and 10000");
|
|
74426
|
+
}
|
|
74427
|
+
sql += " LIMIT ?";
|
|
74428
|
+
params.push(limit);
|
|
74429
|
+
if (query.offset) {
|
|
74430
|
+
const offset = Number(query.offset);
|
|
74431
|
+
if (Number.isNaN(offset) || offset < 0) {
|
|
74432
|
+
throw new Error("Offset must be >= 0");
|
|
74433
|
+
}
|
|
74434
|
+
sql += " OFFSET ?";
|
|
74435
|
+
params.push(offset);
|
|
74436
|
+
}
|
|
74437
|
+
}
|
|
74438
|
+
return { sql, params };
|
|
74439
|
+
}
|
|
74440
|
+
async batchUpdateMemory(operations) {
|
|
74441
|
+
return this.transaction(async () => {
|
|
74442
|
+
const db2 = await this.getDatabase();
|
|
74443
|
+
for (const op of operations) {
|
|
74444
|
+
await this.updateMemoryInternal(db2, op.operation, op.name, op.content, op.metadata);
|
|
74445
|
+
}
|
|
74446
|
+
});
|
|
74447
|
+
}
|
|
74448
|
+
close() {
|
|
74449
|
+
if (this.db) {
|
|
74450
|
+
this.db.close();
|
|
74451
|
+
this.db = null;
|
|
74452
|
+
}
|
|
74453
|
+
}
|
|
74454
|
+
async getStats() {
|
|
74455
|
+
const db2 = await this.getDatabase();
|
|
74456
|
+
const countStmt = db2.prepare("SELECT COUNT(*) as count FROM memory_entries");
|
|
74457
|
+
const { count: totalEntries } = countStmt.get();
|
|
74458
|
+
const typeStmt = db2.prepare("SELECT entry_type, COUNT(*) as count FROM memory_entries GROUP BY entry_type");
|
|
74459
|
+
const typeRows = typeStmt.all();
|
|
74460
|
+
const entriesByType = Object.fromEntries(typeRows.map((r2) => [r2.entry_type, r2.count]));
|
|
74461
|
+
const dbPath = this.resolvePath(this.config.path || "~/.config/polka-codes/memory.sqlite");
|
|
74462
|
+
let databaseSize = 0;
|
|
74463
|
+
try {
|
|
74464
|
+
const stats = await import("node:fs/promises").then((fs4) => fs4.stat(dbPath));
|
|
74465
|
+
databaseSize = stats.size;
|
|
74466
|
+
} catch {}
|
|
74467
|
+
return {
|
|
74468
|
+
totalEntries,
|
|
74469
|
+
entriesByType,
|
|
74470
|
+
databaseSize
|
|
74471
|
+
};
|
|
74472
|
+
}
|
|
74473
|
+
};
|
|
74474
|
+
});
|
|
74475
|
+
|
|
73140
74476
|
// ../../node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
73141
74477
|
function assembleStyles2() {
|
|
73142
74478
|
const codes = new Map;
|
|
@@ -73903,7 +75239,7 @@ var init_eventHandler = __esm(() => {
|
|
|
73903
75239
|
// ../cli-shared/src/utils/readMultiline.ts
|
|
73904
75240
|
import readline3 from "node:readline";
|
|
73905
75241
|
function readMultiline(prompt = "Enter text (Ctrl+D to finish):") {
|
|
73906
|
-
return new Promise((
|
|
75242
|
+
return new Promise((resolve5) => {
|
|
73907
75243
|
console.log(prompt);
|
|
73908
75244
|
const rl = readline3.createInterface({
|
|
73909
75245
|
input: process.stdin,
|
|
@@ -73915,7 +75251,7 @@ function readMultiline(prompt = "Enter text (Ctrl+D to finish):") {
|
|
|
73915
75251
|
lines.push(line);
|
|
73916
75252
|
});
|
|
73917
75253
|
rl.on("close", () => {
|
|
73918
|
-
|
|
75254
|
+
resolve5(lines.join(`
|
|
73919
75255
|
`));
|
|
73920
75256
|
});
|
|
73921
75257
|
});
|
|
@@ -73936,6 +75272,7 @@ var init_utils3 = __esm(() => {
|
|
|
73936
75272
|
var init_src3 = __esm(() => {
|
|
73937
75273
|
init_config2();
|
|
73938
75274
|
init_provider();
|
|
75275
|
+
init_sqlite_memory_store();
|
|
73939
75276
|
init_utils3();
|
|
73940
75277
|
});
|
|
73941
75278
|
|
|
@@ -73959,20 +75296,47 @@ You MUST follow these style constraints for the action line:
|
|
|
73959
75296
|
- NO apologies, hedging, or promises about later work.
|
|
73960
75297
|
`, MEMORY_USAGE_SECTION = `## Memory Usage
|
|
73961
75298
|
|
|
73962
|
-
You have access to a
|
|
75299
|
+
You have access to a persistent SQLite-based memory store to track information across sessions. This is particularly useful for managing todos, bugs, decisions, and notes.
|
|
75300
|
+
|
|
75301
|
+
### Memory Entry Types
|
|
75302
|
+
|
|
75303
|
+
Memory entries can be organized by type:
|
|
75304
|
+
- **todo**: Task items with status (open/done), priority, and tags
|
|
75305
|
+
- **bug**: Bug reports with priority and status
|
|
75306
|
+
- **decision**: Architectural decisions and rationale
|
|
75307
|
+
- **note**: General notes and documentation
|
|
75308
|
+
|
|
75309
|
+
### Todo List Workflow
|
|
75310
|
+
|
|
75311
|
+
When working on multi-step tasks, use the memory store to track progress:
|
|
73963
75312
|
|
|
73964
|
-
|
|
75313
|
+
**Creating a todo item:**
|
|
75314
|
+
Use topic names that clearly describe the task. The content should include the full description.
|
|
73965
75315
|
|
|
73966
|
-
|
|
73967
|
-
-
|
|
73968
|
-
-
|
|
75316
|
+
**Updating todo status:**
|
|
75317
|
+
- Mark todos as done when completed
|
|
75318
|
+
- Update descriptions as requirements evolve
|
|
75319
|
+
- Add tags for organization (e.g., "bug,urgent", "feature,auth")
|
|
75320
|
+
|
|
75321
|
+
**Querying todos:**
|
|
75322
|
+
- Filter by type: "todo" to see all tasks
|
|
75323
|
+
- Filter by status: "open" for pending work
|
|
75324
|
+
- Filter by priority: "high" or "critical" for urgent items
|
|
75325
|
+
- Search: Find specific todos by keyword
|
|
73969
75326
|
|
|
73970
75327
|
### Best Practices
|
|
73971
75328
|
|
|
73972
|
-
-
|
|
73973
|
-
-
|
|
73974
|
-
-
|
|
73975
|
-
-
|
|
75329
|
+
- **Use descriptive topic names**: "fix-login-bug" is better than "bug-1"
|
|
75330
|
+
- **Set appropriate priorities**: Use "critical", "high", "medium", or "low"
|
|
75331
|
+
- **Add relevant tags**: Group related items with tags like "auth", "ui", "backend"
|
|
75332
|
+
- **Update status regularly**: Mark items as done when completed
|
|
75333
|
+
- **Store context**: Include important decisions in memory for future reference
|
|
75334
|
+
- **Memory persists**: All stored information is available across sessions in the current project
|
|
75335
|
+
|
|
75336
|
+
### Memory Scopes
|
|
75337
|
+
|
|
75338
|
+
- **Project scope**: When working in a project directory (with .polkacodes.yml), memory is isolated to that project
|
|
75339
|
+
- **Global scope**: When working outside a project, memory is shared globally
|
|
73976
75340
|
`, AGENTS_INSTRUCTION = `## AGENTS.md Instructions
|
|
73977
75341
|
|
|
73978
75342
|
If you are working in a subdirectory, check if there is an AGENTS.md file in that directory or parent directories for specific instructions. These files contain project-specific guidelines and conventions that you must follow.`;
|
|
@@ -89771,6 +91135,29 @@ ${defaultContext}`;
|
|
|
89771
91135
|
}
|
|
89772
91136
|
}
|
|
89773
91137
|
}
|
|
91138
|
+
if (plan2) {
|
|
91139
|
+
try {
|
|
91140
|
+
const taskSummary = task.split(`
|
|
91141
|
+
`)[0].substring(0, 100);
|
|
91142
|
+
const topic = `plan:${taskSummary.replace(/[^a-zA-Z0-9_-]+/g, "-").toLowerCase()}`;
|
|
91143
|
+
const keywords = task.toLowerCase().match(/(?:implement|create|add|fix|refactor|update|improve|optimize|test|document)(?:\s+(\w+))?/g);
|
|
91144
|
+
const _tags = keywords ? keywords.map((k) => {
|
|
91145
|
+
const parts = k.split(" ");
|
|
91146
|
+
if (parts.length > 1) {
|
|
91147
|
+
return parts.join("-");
|
|
91148
|
+
}
|
|
91149
|
+
return k;
|
|
91150
|
+
}).join(",") : undefined;
|
|
91151
|
+
await tools3.updateMemory({
|
|
91152
|
+
operation: "replace",
|
|
91153
|
+
topic,
|
|
91154
|
+
content: plan2
|
|
91155
|
+
});
|
|
91156
|
+
context.logger.info(`Plan saved to memory as: ${topic}`);
|
|
91157
|
+
} catch (error48) {
|
|
91158
|
+
context.logger.warn("Failed to save plan to memory:", error48);
|
|
91159
|
+
}
|
|
91160
|
+
}
|
|
89774
91161
|
return { plan: plan2 || undefined, files: outputFiles, messages: result.messages };
|
|
89775
91162
|
}
|
|
89776
91163
|
context.logger.warn("Failed to generate plan.", result);
|
|
@@ -93074,15 +94461,15 @@ function parseUnionDef2(def, refs) {
|
|
|
93074
94461
|
return asAnyOf2(def, refs);
|
|
93075
94462
|
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
93076
94463
|
if (options.every((x2) => (x2._def.typeName in primitiveMappings2) && (!x2._def.checks || !x2._def.checks.length))) {
|
|
93077
|
-
const
|
|
94464
|
+
const types7 = options.reduce((types8, x2) => {
|
|
93078
94465
|
const type = primitiveMappings2[x2._def.typeName];
|
|
93079
|
-
return type && !
|
|
94466
|
+
return type && !types8.includes(type) ? [...types8, type] : types8;
|
|
93080
94467
|
}, []);
|
|
93081
94468
|
return {
|
|
93082
|
-
type:
|
|
94469
|
+
type: types7.length > 1 ? types7 : types7[0]
|
|
93083
94470
|
};
|
|
93084
94471
|
} else if (options.every((x2) => x2._def.typeName === "ZodLiteral" && !x2.description)) {
|
|
93085
|
-
const
|
|
94472
|
+
const types7 = options.reduce((acc, x2) => {
|
|
93086
94473
|
const type = typeof x2._def.value;
|
|
93087
94474
|
switch (type) {
|
|
93088
94475
|
case "string":
|
|
@@ -93101,8 +94488,8 @@ function parseUnionDef2(def, refs) {
|
|
|
93101
94488
|
return acc;
|
|
93102
94489
|
}
|
|
93103
94490
|
}, []);
|
|
93104
|
-
if (
|
|
93105
|
-
const uniqueTypes =
|
|
94491
|
+
if (types7.length === options.length) {
|
|
94492
|
+
const uniqueTypes = types7.filter((x2, i2, a) => a.indexOf(x2) === i2);
|
|
93106
94493
|
return {
|
|
93107
94494
|
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
93108
94495
|
enum: options.reduce((acc, x2) => {
|
|
@@ -94192,7 +95579,7 @@ class Protocol {
|
|
|
94192
95579
|
return;
|
|
94193
95580
|
}
|
|
94194
95581
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1000;
|
|
94195
|
-
await new Promise((
|
|
95582
|
+
await new Promise((resolve6) => setTimeout(resolve6, pollInterval));
|
|
94196
95583
|
options?.signal?.throwIfAborted();
|
|
94197
95584
|
}
|
|
94198
95585
|
} catch (error48) {
|
|
@@ -94204,7 +95591,7 @@ class Protocol {
|
|
|
94204
95591
|
}
|
|
94205
95592
|
request(request, resultSchema, options) {
|
|
94206
95593
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
94207
|
-
return new Promise((
|
|
95594
|
+
return new Promise((resolve6, reject) => {
|
|
94208
95595
|
const earlyReject = (error48) => {
|
|
94209
95596
|
reject(error48);
|
|
94210
95597
|
};
|
|
@@ -94282,7 +95669,7 @@ class Protocol {
|
|
|
94282
95669
|
if (!parseResult.success) {
|
|
94283
95670
|
reject(parseResult.error);
|
|
94284
95671
|
} else {
|
|
94285
|
-
|
|
95672
|
+
resolve6(parseResult.data);
|
|
94286
95673
|
}
|
|
94287
95674
|
} catch (error48) {
|
|
94288
95675
|
reject(error48);
|
|
@@ -94473,12 +95860,12 @@ class Protocol {
|
|
|
94473
95860
|
interval = task.pollInterval;
|
|
94474
95861
|
}
|
|
94475
95862
|
} catch {}
|
|
94476
|
-
return new Promise((
|
|
95863
|
+
return new Promise((resolve6, reject) => {
|
|
94477
95864
|
if (signal.aborted) {
|
|
94478
95865
|
reject(new McpError2(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
94479
95866
|
return;
|
|
94480
95867
|
}
|
|
94481
|
-
const timeoutId = setTimeout(
|
|
95868
|
+
const timeoutId = setTimeout(resolve6, interval);
|
|
94482
95869
|
signal.addEventListener("abort", () => {
|
|
94483
95870
|
clearTimeout(timeoutId);
|
|
94484
95871
|
reject(new McpError2(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -95588,7 +96975,7 @@ var require_codegen = __commonJS((exports) => {
|
|
|
95588
96975
|
});
|
|
95589
96976
|
|
|
95590
96977
|
// ../../node_modules/ajv/dist/compile/util.js
|
|
95591
|
-
var
|
|
96978
|
+
var require_util4 = __commonJS((exports) => {
|
|
95592
96979
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
95593
96980
|
exports.checkStrictMode = exports.getErrorPath = exports.Type = exports.useFunc = exports.setEvaluated = exports.evaluatedPropsToName = exports.mergeEvaluated = exports.eachItem = exports.unescapeJsonPointer = exports.escapeJsonPointer = exports.escapeFragment = exports.unescapeFragment = exports.schemaRefOrVal = exports.schemaHasRulesButRef = exports.schemaHasRules = exports.checkUnknownRules = exports.alwaysValidSchema = exports.toHash = undefined;
|
|
95594
96981
|
var codegen_1 = require_codegen();
|
|
@@ -95781,7 +97168,7 @@ var require_errors2 = __commonJS((exports) => {
|
|
|
95781
97168
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
95782
97169
|
exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = undefined;
|
|
95783
97170
|
var codegen_1 = require_codegen();
|
|
95784
|
-
var util_1 =
|
|
97171
|
+
var util_1 = require_util4();
|
|
95785
97172
|
var names_1 = require_names();
|
|
95786
97173
|
exports.keywordError = {
|
|
95787
97174
|
message: ({ keyword }) => (0, codegen_1.str)`must pass "${keyword}" keyword validation`
|
|
@@ -95998,44 +97385,44 @@ var require_dataType = __commonJS((exports) => {
|
|
|
95998
97385
|
var applicability_1 = require_applicability();
|
|
95999
97386
|
var errors_1 = require_errors2();
|
|
96000
97387
|
var codegen_1 = require_codegen();
|
|
96001
|
-
var util_1 =
|
|
97388
|
+
var util_1 = require_util4();
|
|
96002
97389
|
var DataType;
|
|
96003
97390
|
(function(DataType2) {
|
|
96004
97391
|
DataType2[DataType2["Correct"] = 0] = "Correct";
|
|
96005
97392
|
DataType2[DataType2["Wrong"] = 1] = "Wrong";
|
|
96006
97393
|
})(DataType || (exports.DataType = DataType = {}));
|
|
96007
97394
|
function getSchemaTypes(schema) {
|
|
96008
|
-
const
|
|
96009
|
-
const hasNull =
|
|
97395
|
+
const types7 = getJSONTypes(schema.type);
|
|
97396
|
+
const hasNull = types7.includes("null");
|
|
96010
97397
|
if (hasNull) {
|
|
96011
97398
|
if (schema.nullable === false)
|
|
96012
97399
|
throw new Error("type: null contradicts nullable: false");
|
|
96013
97400
|
} else {
|
|
96014
|
-
if (!
|
|
97401
|
+
if (!types7.length && schema.nullable !== undefined) {
|
|
96015
97402
|
throw new Error('"nullable" cannot be used without "type"');
|
|
96016
97403
|
}
|
|
96017
97404
|
if (schema.nullable === true)
|
|
96018
|
-
|
|
97405
|
+
types7.push("null");
|
|
96019
97406
|
}
|
|
96020
|
-
return
|
|
97407
|
+
return types7;
|
|
96021
97408
|
}
|
|
96022
97409
|
exports.getSchemaTypes = getSchemaTypes;
|
|
96023
97410
|
function getJSONTypes(ts) {
|
|
96024
|
-
const
|
|
96025
|
-
if (
|
|
96026
|
-
return
|
|
96027
|
-
throw new Error("type must be JSONType or JSONType[]: " +
|
|
97411
|
+
const types7 = Array.isArray(ts) ? ts : ts ? [ts] : [];
|
|
97412
|
+
if (types7.every(rules_1.isJSONType))
|
|
97413
|
+
return types7;
|
|
97414
|
+
throw new Error("type must be JSONType or JSONType[]: " + types7.join(","));
|
|
96028
97415
|
}
|
|
96029
97416
|
exports.getJSONTypes = getJSONTypes;
|
|
96030
|
-
function coerceAndCheckDataType(it,
|
|
97417
|
+
function coerceAndCheckDataType(it, types7) {
|
|
96031
97418
|
const { gen, data, opts } = it;
|
|
96032
|
-
const coerceTo = coerceToTypes(
|
|
96033
|
-
const checkTypes =
|
|
97419
|
+
const coerceTo = coerceToTypes(types7, opts.coerceTypes);
|
|
97420
|
+
const checkTypes = types7.length > 0 && !(coerceTo.length === 0 && types7.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types7[0]));
|
|
96034
97421
|
if (checkTypes) {
|
|
96035
|
-
const wrongType = checkDataTypes(
|
|
97422
|
+
const wrongType = checkDataTypes(types7, data, opts.strictNumbers, DataType.Wrong);
|
|
96036
97423
|
gen.if(wrongType, () => {
|
|
96037
97424
|
if (coerceTo.length)
|
|
96038
|
-
coerceData(it,
|
|
97425
|
+
coerceData(it, types7, coerceTo);
|
|
96039
97426
|
else
|
|
96040
97427
|
reportTypeError(it);
|
|
96041
97428
|
});
|
|
@@ -96044,15 +97431,15 @@ var require_dataType = __commonJS((exports) => {
|
|
|
96044
97431
|
}
|
|
96045
97432
|
exports.coerceAndCheckDataType = coerceAndCheckDataType;
|
|
96046
97433
|
var COERCIBLE = new Set(["string", "number", "integer", "boolean", "null"]);
|
|
96047
|
-
function coerceToTypes(
|
|
96048
|
-
return coerceTypes ?
|
|
97434
|
+
function coerceToTypes(types7, coerceTypes) {
|
|
97435
|
+
return coerceTypes ? types7.filter((t2) => COERCIBLE.has(t2) || coerceTypes === "array" && t2 === "array") : [];
|
|
96049
97436
|
}
|
|
96050
|
-
function coerceData(it,
|
|
97437
|
+
function coerceData(it, types7, coerceTo) {
|
|
96051
97438
|
const { gen, data, opts } = it;
|
|
96052
97439
|
const dataType = gen.let("dataType", (0, codegen_1._)`typeof ${data}`);
|
|
96053
97440
|
const coerced = gen.let("coerced", (0, codegen_1._)`undefined`);
|
|
96054
97441
|
if (opts.coerceTypes === "array") {
|
|
96055
|
-
gen.if((0, codegen_1._)`${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1._)`${data}[0]`).assign(dataType, (0, codegen_1._)`typeof ${data}`).if(checkDataTypes(
|
|
97442
|
+
gen.if((0, codegen_1._)`${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1._)`${data}[0]`).assign(dataType, (0, codegen_1._)`typeof ${data}`).if(checkDataTypes(types7, data, opts.strictNumbers), () => gen.assign(coerced, data)));
|
|
96056
97443
|
}
|
|
96057
97444
|
gen.if((0, codegen_1._)`${coerced} !== undefined`);
|
|
96058
97445
|
for (const t2 of coerceTo) {
|
|
@@ -96128,19 +97515,19 @@ var require_dataType = __commonJS((exports) => {
|
|
|
96128
97515
|
return checkDataType(dataTypes[0], data, strictNums, correct);
|
|
96129
97516
|
}
|
|
96130
97517
|
let cond;
|
|
96131
|
-
const
|
|
96132
|
-
if (
|
|
97518
|
+
const types7 = (0, util_1.toHash)(dataTypes);
|
|
97519
|
+
if (types7.array && types7.object) {
|
|
96133
97520
|
const notObj = (0, codegen_1._)`typeof ${data} != "object"`;
|
|
96134
|
-
cond =
|
|
96135
|
-
delete
|
|
96136
|
-
delete
|
|
96137
|
-
delete
|
|
97521
|
+
cond = types7.null ? notObj : (0, codegen_1._)`!${data} || ${notObj}`;
|
|
97522
|
+
delete types7.null;
|
|
97523
|
+
delete types7.array;
|
|
97524
|
+
delete types7.object;
|
|
96138
97525
|
} else {
|
|
96139
97526
|
cond = codegen_1.nil;
|
|
96140
97527
|
}
|
|
96141
|
-
if (
|
|
96142
|
-
delete
|
|
96143
|
-
for (const t2 in
|
|
97528
|
+
if (types7.number)
|
|
97529
|
+
delete types7.integer;
|
|
97530
|
+
for (const t2 in types7)
|
|
96144
97531
|
cond = (0, codegen_1.and)(cond, checkDataType(t2, data, strictNums, correct));
|
|
96145
97532
|
return cond;
|
|
96146
97533
|
}
|
|
@@ -96176,7 +97563,7 @@ var require_defaults = __commonJS((exports) => {
|
|
|
96176
97563
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
96177
97564
|
exports.assignDefaults = undefined;
|
|
96178
97565
|
var codegen_1 = require_codegen();
|
|
96179
|
-
var util_1 =
|
|
97566
|
+
var util_1 = require_util4();
|
|
96180
97567
|
function assignDefaults(it, ty) {
|
|
96181
97568
|
const { properties, items } = it.schema;
|
|
96182
97569
|
if (ty === "object" && properties) {
|
|
@@ -96210,9 +97597,9 @@ var require_code2 = __commonJS((exports) => {
|
|
|
96210
97597
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
96211
97598
|
exports.validateUnion = exports.validateArray = exports.usePattern = exports.callValidateCode = exports.schemaProperties = exports.allSchemaProperties = exports.noPropertyInData = exports.propertyInData = exports.isOwnProperty = exports.hasPropFunc = exports.reportMissingProp = exports.checkMissingProp = exports.checkReportMissingProp = undefined;
|
|
96212
97599
|
var codegen_1 = require_codegen();
|
|
96213
|
-
var util_1 =
|
|
97600
|
+
var util_1 = require_util4();
|
|
96214
97601
|
var names_1 = require_names();
|
|
96215
|
-
var util_2 =
|
|
97602
|
+
var util_2 = require_util4();
|
|
96216
97603
|
function checkReportMissingProp(cxt, prop) {
|
|
96217
97604
|
const { gen, data, it } = cxt;
|
|
96218
97605
|
gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
|
|
@@ -96454,7 +97841,7 @@ var require_subschema = __commonJS((exports) => {
|
|
|
96454
97841
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
96455
97842
|
exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = undefined;
|
|
96456
97843
|
var codegen_1 = require_codegen();
|
|
96457
|
-
var util_1 =
|
|
97844
|
+
var util_1 = require_util4();
|
|
96458
97845
|
function getSubschema(it, { keyword, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
|
|
96459
97846
|
if (keyword !== undefined && schema !== undefined) {
|
|
96460
97847
|
throw new Error('both "keyword" and "schema" passed, only one allowed');
|
|
@@ -96658,7 +98045,7 @@ var require_json_schema_traverse = __commonJS((exports, module) => {
|
|
|
96658
98045
|
var require_resolve = __commonJS((exports) => {
|
|
96659
98046
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
96660
98047
|
exports.getSchemaRefs = exports.resolveUrl = exports.normalizeId = exports._getFullPath = exports.getFullPath = exports.inlineRef = undefined;
|
|
96661
|
-
var util_1 =
|
|
98048
|
+
var util_1 = require_util4();
|
|
96662
98049
|
var equal = require_fast_deep_equal();
|
|
96663
98050
|
var traverse = require_json_schema_traverse();
|
|
96664
98051
|
var SIMPLE_INLINED = new Set([
|
|
@@ -96821,7 +98208,7 @@ var require_validate = __commonJS((exports) => {
|
|
|
96821
98208
|
var codegen_1 = require_codegen();
|
|
96822
98209
|
var names_1 = require_names();
|
|
96823
98210
|
var resolve_1 = require_resolve();
|
|
96824
|
-
var util_1 =
|
|
98211
|
+
var util_1 = require_util4();
|
|
96825
98212
|
var errors_1 = require_errors2();
|
|
96826
98213
|
function validateFunctionCode(it) {
|
|
96827
98214
|
if (isSchemaObj(it)) {
|
|
@@ -96928,9 +98315,9 @@ var require_validate = __commonJS((exports) => {
|
|
|
96928
98315
|
function typeAndKeywords(it, errsCount) {
|
|
96929
98316
|
if (it.opts.jtd)
|
|
96930
98317
|
return schemaKeywords(it, [], false, errsCount);
|
|
96931
|
-
const
|
|
96932
|
-
const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it,
|
|
96933
|
-
schemaKeywords(it,
|
|
98318
|
+
const types7 = (0, dataType_1.getSchemaTypes)(it.schema);
|
|
98319
|
+
const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it, types7);
|
|
98320
|
+
schemaKeywords(it, types7, !checkedTypes, errsCount);
|
|
96934
98321
|
}
|
|
96935
98322
|
function checkRefsAndKeywords(it) {
|
|
96936
98323
|
const { schema, errSchemaPath, opts, self: self2 } = it;
|
|
@@ -96980,7 +98367,7 @@ var require_validate = __commonJS((exports) => {
|
|
|
96980
98367
|
if (items instanceof codegen_1.Name)
|
|
96981
98368
|
gen.assign((0, codegen_1._)`${evaluated}.items`, items);
|
|
96982
98369
|
}
|
|
96983
|
-
function schemaKeywords(it,
|
|
98370
|
+
function schemaKeywords(it, types7, typeErrors, errsCount) {
|
|
96984
98371
|
const { gen, schema, data, allErrors, opts, self: self2 } = it;
|
|
96985
98372
|
const { RULES } = self2;
|
|
96986
98373
|
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema, RULES))) {
|
|
@@ -96988,7 +98375,7 @@ var require_validate = __commonJS((exports) => {
|
|
|
96988
98375
|
return;
|
|
96989
98376
|
}
|
|
96990
98377
|
if (!opts.jtd)
|
|
96991
|
-
checkStrictTypes(it,
|
|
98378
|
+
checkStrictTypes(it, types7);
|
|
96992
98379
|
gen.block(() => {
|
|
96993
98380
|
for (const group of RULES.rules)
|
|
96994
98381
|
groupKeywords(group);
|
|
@@ -97000,7 +98387,7 @@ var require_validate = __commonJS((exports) => {
|
|
|
97000
98387
|
if (group.type) {
|
|
97001
98388
|
gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
|
|
97002
98389
|
iterateKeywords(it, group);
|
|
97003
|
-
if (
|
|
98390
|
+
if (types7.length === 1 && types7[0] === group.type && typeErrors) {
|
|
97004
98391
|
gen.else();
|
|
97005
98392
|
(0, dataType_2.reportTypeError)(it);
|
|
97006
98393
|
}
|
|
@@ -97024,27 +98411,27 @@ var require_validate = __commonJS((exports) => {
|
|
|
97024
98411
|
}
|
|
97025
98412
|
});
|
|
97026
98413
|
}
|
|
97027
|
-
function checkStrictTypes(it,
|
|
98414
|
+
function checkStrictTypes(it, types7) {
|
|
97028
98415
|
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
|
97029
98416
|
return;
|
|
97030
|
-
checkContextTypes(it,
|
|
98417
|
+
checkContextTypes(it, types7);
|
|
97031
98418
|
if (!it.opts.allowUnionTypes)
|
|
97032
|
-
checkMultipleTypes(it,
|
|
98419
|
+
checkMultipleTypes(it, types7);
|
|
97033
98420
|
checkKeywordTypes(it, it.dataTypes);
|
|
97034
98421
|
}
|
|
97035
|
-
function checkContextTypes(it,
|
|
97036
|
-
if (!
|
|
98422
|
+
function checkContextTypes(it, types7) {
|
|
98423
|
+
if (!types7.length)
|
|
97037
98424
|
return;
|
|
97038
98425
|
if (!it.dataTypes.length) {
|
|
97039
|
-
it.dataTypes =
|
|
98426
|
+
it.dataTypes = types7;
|
|
97040
98427
|
return;
|
|
97041
98428
|
}
|
|
97042
|
-
|
|
98429
|
+
types7.forEach((t2) => {
|
|
97043
98430
|
if (!includesType(it.dataTypes, t2)) {
|
|
97044
98431
|
strictTypesError(it, `type "${t2}" not allowed by context "${it.dataTypes.join(",")}"`);
|
|
97045
98432
|
}
|
|
97046
98433
|
});
|
|
97047
|
-
narrowSchemaTypes(it,
|
|
98434
|
+
narrowSchemaTypes(it, types7);
|
|
97048
98435
|
}
|
|
97049
98436
|
function checkMultipleTypes(it, ts) {
|
|
97050
98437
|
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
@@ -97349,7 +98736,7 @@ var require_compile = __commonJS((exports) => {
|
|
|
97349
98736
|
var validation_error_1 = require_validation_error();
|
|
97350
98737
|
var names_1 = require_names();
|
|
97351
98738
|
var resolve_1 = require_resolve();
|
|
97352
|
-
var util_1 =
|
|
98739
|
+
var util_1 = require_util4();
|
|
97353
98740
|
var validate_1 = require_validate();
|
|
97354
98741
|
|
|
97355
98742
|
class SchemaEnv {
|
|
@@ -97463,7 +98850,7 @@ var require_compile = __commonJS((exports) => {
|
|
|
97463
98850
|
const schOrFunc = root2.refs[ref];
|
|
97464
98851
|
if (schOrFunc)
|
|
97465
98852
|
return schOrFunc;
|
|
97466
|
-
let _sch =
|
|
98853
|
+
let _sch = resolve6.call(this, root2, ref);
|
|
97467
98854
|
if (_sch === undefined) {
|
|
97468
98855
|
const schema = (_a16 = root2.localRefs) === null || _a16 === undefined ? undefined : _a16[ref];
|
|
97469
98856
|
const { schemaId } = this.opts;
|
|
@@ -97490,7 +98877,7 @@ var require_compile = __commonJS((exports) => {
|
|
|
97490
98877
|
function sameSchemaEnv(s1, s2) {
|
|
97491
98878
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
97492
98879
|
}
|
|
97493
|
-
function
|
|
98880
|
+
function resolve6(root2, ref) {
|
|
97494
98881
|
let sch;
|
|
97495
98882
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
97496
98883
|
ref = sch;
|
|
@@ -98020,7 +99407,7 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
98020
99407
|
}
|
|
98021
99408
|
return uri;
|
|
98022
99409
|
}
|
|
98023
|
-
function
|
|
99410
|
+
function resolve6(baseURI, relativeURI, options) {
|
|
98024
99411
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
98025
99412
|
const resolved = resolveComponent(parse6(baseURI, schemelessOptions), parse6(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
98026
99413
|
schemelessOptions.skipEscape = true;
|
|
@@ -98248,7 +99635,7 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
98248
99635
|
var fastUri = {
|
|
98249
99636
|
SCHEMES,
|
|
98250
99637
|
normalize: normalize5,
|
|
98251
|
-
resolve:
|
|
99638
|
+
resolve: resolve6,
|
|
98252
99639
|
resolveComponent,
|
|
98253
99640
|
equal,
|
|
98254
99641
|
serialize,
|
|
@@ -98301,7 +99688,7 @@ var require_core = __commonJS((exports) => {
|
|
|
98301
99688
|
var codegen_2 = require_codegen();
|
|
98302
99689
|
var resolve_1 = require_resolve();
|
|
98303
99690
|
var dataType_1 = require_dataType();
|
|
98304
|
-
var util_1 =
|
|
99691
|
+
var util_1 = require_util4();
|
|
98305
99692
|
var $dataRefSchema = require_data();
|
|
98306
99693
|
var uri_1 = require_uri();
|
|
98307
99694
|
var defaultRegExp = (str, flags) => new RegExp(str, flags);
|
|
@@ -98881,7 +100268,7 @@ var require_ref = __commonJS((exports) => {
|
|
|
98881
100268
|
var codegen_1 = require_codegen();
|
|
98882
100269
|
var names_1 = require_names();
|
|
98883
100270
|
var compile_1 = require_compile();
|
|
98884
|
-
var util_1 =
|
|
100271
|
+
var util_1 = require_util4();
|
|
98885
100272
|
var def = {
|
|
98886
100273
|
keyword: "$ref",
|
|
98887
100274
|
schemaType: "string",
|
|
@@ -99090,7 +100477,7 @@ var require_ucs2length = __commonJS((exports) => {
|
|
|
99090
100477
|
var require_limitLength = __commonJS((exports) => {
|
|
99091
100478
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
99092
100479
|
var codegen_1 = require_codegen();
|
|
99093
|
-
var util_1 =
|
|
100480
|
+
var util_1 = require_util4();
|
|
99094
100481
|
var ucs2length_1 = require_ucs2length();
|
|
99095
100482
|
var error48 = {
|
|
99096
100483
|
message({ keyword, schemaCode }) {
|
|
@@ -99171,7 +100558,7 @@ var require_required = __commonJS((exports) => {
|
|
|
99171
100558
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
99172
100559
|
var code_1 = require_code2();
|
|
99173
100560
|
var codegen_1 = require_codegen();
|
|
99174
|
-
var util_1 =
|
|
100561
|
+
var util_1 = require_util4();
|
|
99175
100562
|
var error48 = {
|
|
99176
100563
|
message: ({ params: { missingProperty } }) => (0, codegen_1.str)`must have required property '${missingProperty}'`,
|
|
99177
100564
|
params: ({ params: { missingProperty } }) => (0, codegen_1._)`{missingProperty: ${missingProperty}}`
|
|
@@ -99284,7 +100671,7 @@ var require_uniqueItems = __commonJS((exports) => {
|
|
|
99284
100671
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
99285
100672
|
var dataType_1 = require_dataType();
|
|
99286
100673
|
var codegen_1 = require_codegen();
|
|
99287
|
-
var util_1 =
|
|
100674
|
+
var util_1 = require_util4();
|
|
99288
100675
|
var equal_1 = require_equal();
|
|
99289
100676
|
var error48 = {
|
|
99290
100677
|
message: ({ params: { i: i2, j } }) => (0, codegen_1.str)`must NOT have duplicate items (items ## ${j} and ${i2} are identical)`,
|
|
@@ -99347,7 +100734,7 @@ var require_uniqueItems = __commonJS((exports) => {
|
|
|
99347
100734
|
var require_const = __commonJS((exports) => {
|
|
99348
100735
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
99349
100736
|
var codegen_1 = require_codegen();
|
|
99350
|
-
var util_1 =
|
|
100737
|
+
var util_1 = require_util4();
|
|
99351
100738
|
var equal_1 = require_equal();
|
|
99352
100739
|
var error48 = {
|
|
99353
100740
|
message: "must be equal to constant",
|
|
@@ -99373,7 +100760,7 @@ var require_const = __commonJS((exports) => {
|
|
|
99373
100760
|
var require_enum = __commonJS((exports) => {
|
|
99374
100761
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
99375
100762
|
var codegen_1 = require_codegen();
|
|
99376
|
-
var util_1 =
|
|
100763
|
+
var util_1 = require_util4();
|
|
99377
100764
|
var equal_1 = require_equal();
|
|
99378
100765
|
var error48 = {
|
|
99379
100766
|
message: "must be equal to one of the allowed values",
|
|
@@ -99450,7 +100837,7 @@ var require_additionalItems = __commonJS((exports) => {
|
|
|
99450
100837
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
99451
100838
|
exports.validateAdditionalItems = undefined;
|
|
99452
100839
|
var codegen_1 = require_codegen();
|
|
99453
|
-
var util_1 =
|
|
100840
|
+
var util_1 = require_util4();
|
|
99454
100841
|
var error48 = {
|
|
99455
100842
|
message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than ${len} items`,
|
|
99456
100843
|
params: ({ params: { len } }) => (0, codegen_1._)`{limit: ${len}}`
|
|
@@ -99500,7 +100887,7 @@ var require_items = __commonJS((exports) => {
|
|
|
99500
100887
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
99501
100888
|
exports.validateTuple = undefined;
|
|
99502
100889
|
var codegen_1 = require_codegen();
|
|
99503
|
-
var util_1 =
|
|
100890
|
+
var util_1 = require_util4();
|
|
99504
100891
|
var code_1 = require_code2();
|
|
99505
100892
|
var def = {
|
|
99506
100893
|
keyword: "items",
|
|
@@ -99567,7 +100954,7 @@ var require_prefixItems = __commonJS((exports) => {
|
|
|
99567
100954
|
var require_items2020 = __commonJS((exports) => {
|
|
99568
100955
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
99569
100956
|
var codegen_1 = require_codegen();
|
|
99570
|
-
var util_1 =
|
|
100957
|
+
var util_1 = require_util4();
|
|
99571
100958
|
var code_1 = require_code2();
|
|
99572
100959
|
var additionalItems_1 = require_additionalItems();
|
|
99573
100960
|
var error48 = {
|
|
@@ -99599,7 +100986,7 @@ var require_items2020 = __commonJS((exports) => {
|
|
|
99599
100986
|
var require_contains = __commonJS((exports) => {
|
|
99600
100987
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
99601
100988
|
var codegen_1 = require_codegen();
|
|
99602
|
-
var util_1 =
|
|
100989
|
+
var util_1 = require_util4();
|
|
99603
100990
|
var error48 = {
|
|
99604
100991
|
message: ({ params: { min, max } }) => max === undefined ? (0, codegen_1.str)`must contain at least ${min} valid item(s)` : (0, codegen_1.str)`must contain at least ${min} and no more than ${max} valid item(s)`,
|
|
99605
100992
|
params: ({ params: { min, max } }) => max === undefined ? (0, codegen_1._)`{minContains: ${min}}` : (0, codegen_1._)`{minContains: ${min}, maxContains: ${max}}`
|
|
@@ -99691,7 +101078,7 @@ var require_dependencies = __commonJS((exports) => {
|
|
|
99691
101078
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
99692
101079
|
exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = undefined;
|
|
99693
101080
|
var codegen_1 = require_codegen();
|
|
99694
|
-
var util_1 =
|
|
101081
|
+
var util_1 = require_util4();
|
|
99695
101082
|
var code_1 = require_code2();
|
|
99696
101083
|
exports.error = {
|
|
99697
101084
|
message: ({ params: { property, depsCount, deps } }) => {
|
|
@@ -99775,7 +101162,7 @@ var require_dependencies = __commonJS((exports) => {
|
|
|
99775
101162
|
var require_propertyNames = __commonJS((exports) => {
|
|
99776
101163
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
99777
101164
|
var codegen_1 = require_codegen();
|
|
99778
|
-
var util_1 =
|
|
101165
|
+
var util_1 = require_util4();
|
|
99779
101166
|
var error48 = {
|
|
99780
101167
|
message: "property name must be valid",
|
|
99781
101168
|
params: ({ params }) => (0, codegen_1._)`{propertyName: ${params.propertyName}}`
|
|
@@ -99817,7 +101204,7 @@ var require_additionalProperties = __commonJS((exports) => {
|
|
|
99817
101204
|
var code_1 = require_code2();
|
|
99818
101205
|
var codegen_1 = require_codegen();
|
|
99819
101206
|
var names_1 = require_names();
|
|
99820
|
-
var util_1 =
|
|
101207
|
+
var util_1 = require_util4();
|
|
99821
101208
|
var error48 = {
|
|
99822
101209
|
message: "must NOT have additional properties",
|
|
99823
101210
|
params: ({ params }) => (0, codegen_1._)`{additionalProperty: ${params.additionalProperty}}`
|
|
@@ -99919,7 +101306,7 @@ var require_properties = __commonJS((exports) => {
|
|
|
99919
101306
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
99920
101307
|
var validate_1 = require_validate();
|
|
99921
101308
|
var code_1 = require_code2();
|
|
99922
|
-
var util_1 =
|
|
101309
|
+
var util_1 = require_util4();
|
|
99923
101310
|
var additionalProperties_1 = require_additionalProperties();
|
|
99924
101311
|
var def = {
|
|
99925
101312
|
keyword: "properties",
|
|
@@ -99974,8 +101361,8 @@ var require_patternProperties = __commonJS((exports) => {
|
|
|
99974
101361
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
99975
101362
|
var code_1 = require_code2();
|
|
99976
101363
|
var codegen_1 = require_codegen();
|
|
99977
|
-
var util_1 =
|
|
99978
|
-
var util_2 =
|
|
101364
|
+
var util_1 = require_util4();
|
|
101365
|
+
var util_2 = require_util4();
|
|
99979
101366
|
var def = {
|
|
99980
101367
|
keyword: "patternProperties",
|
|
99981
101368
|
type: "object",
|
|
@@ -100043,7 +101430,7 @@ var require_patternProperties = __commonJS((exports) => {
|
|
|
100043
101430
|
// ../../node_modules/ajv/dist/vocabularies/applicator/not.js
|
|
100044
101431
|
var require_not = __commonJS((exports) => {
|
|
100045
101432
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
100046
|
-
var util_1 =
|
|
101433
|
+
var util_1 = require_util4();
|
|
100047
101434
|
var def = {
|
|
100048
101435
|
keyword: "not",
|
|
100049
101436
|
schemaType: ["object", "boolean"],
|
|
@@ -100086,7 +101473,7 @@ var require_anyOf = __commonJS((exports) => {
|
|
|
100086
101473
|
var require_oneOf = __commonJS((exports) => {
|
|
100087
101474
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
100088
101475
|
var codegen_1 = require_codegen();
|
|
100089
|
-
var util_1 =
|
|
101476
|
+
var util_1 = require_util4();
|
|
100090
101477
|
var error48 = {
|
|
100091
101478
|
message: "must match exactly one schema in oneOf",
|
|
100092
101479
|
params: ({ params }) => (0, codegen_1._)`{passingSchemas: ${params.passing}}`
|
|
@@ -100140,7 +101527,7 @@ var require_oneOf = __commonJS((exports) => {
|
|
|
100140
101527
|
// ../../node_modules/ajv/dist/vocabularies/applicator/allOf.js
|
|
100141
101528
|
var require_allOf = __commonJS((exports) => {
|
|
100142
101529
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
100143
|
-
var util_1 =
|
|
101530
|
+
var util_1 = require_util4();
|
|
100144
101531
|
var def = {
|
|
100145
101532
|
keyword: "allOf",
|
|
100146
101533
|
schemaType: "array",
|
|
@@ -100165,7 +101552,7 @@ var require_allOf = __commonJS((exports) => {
|
|
|
100165
101552
|
var require_if = __commonJS((exports) => {
|
|
100166
101553
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
100167
101554
|
var codegen_1 = require_codegen();
|
|
100168
|
-
var util_1 =
|
|
101555
|
+
var util_1 = require_util4();
|
|
100169
101556
|
var error48 = {
|
|
100170
101557
|
message: ({ params }) => (0, codegen_1.str)`must match "${params.ifClause}" schema`,
|
|
100171
101558
|
params: ({ params }) => (0, codegen_1._)`{failingKeyword: ${params.ifClause}}`
|
|
@@ -100230,7 +101617,7 @@ var require_if = __commonJS((exports) => {
|
|
|
100230
101617
|
// ../../node_modules/ajv/dist/vocabularies/applicator/thenElse.js
|
|
100231
101618
|
var require_thenElse = __commonJS((exports) => {
|
|
100232
101619
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
100233
|
-
var util_1 =
|
|
101620
|
+
var util_1 = require_util4();
|
|
100234
101621
|
var def = {
|
|
100235
101622
|
keyword: ["then", "else"],
|
|
100236
101623
|
schemaType: ["object", "boolean"],
|
|
@@ -100437,7 +101824,7 @@ var require_discriminator = __commonJS((exports) => {
|
|
|
100437
101824
|
var types_1 = require_types2();
|
|
100438
101825
|
var compile_1 = require_compile();
|
|
100439
101826
|
var ref_error_1 = require_ref_error();
|
|
100440
|
-
var util_1 =
|
|
101827
|
+
var util_1 = require_util4();
|
|
100441
101828
|
var error48 = {
|
|
100442
101829
|
message: ({ params: { discrError, tagName } }) => discrError === types_1.DiscrError.Tag ? `tag "${tagName}" must be string` : `value of tag "${tagName}" must be in oneOf`,
|
|
100443
101830
|
params: ({ params: { discrError, tag, tagName } }) => (0, codegen_1._)`{error: ${discrError}, tag: ${tagName}, tagValue: ${tag}}`
|
|
@@ -101943,7 +103330,7 @@ var require_codegen2 = __commonJS((exports) => {
|
|
|
101943
103330
|
});
|
|
101944
103331
|
|
|
101945
103332
|
// ../../node_modules/ajv-formats/node_modules/ajv/dist/compile/util.js
|
|
101946
|
-
var
|
|
103333
|
+
var require_util5 = __commonJS((exports) => {
|
|
101947
103334
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
101948
103335
|
exports.checkStrictMode = exports.getErrorPath = exports.Type = exports.useFunc = exports.setEvaluated = exports.evaluatedPropsToName = exports.mergeEvaluated = exports.eachItem = exports.unescapeJsonPointer = exports.escapeJsonPointer = exports.escapeFragment = exports.unescapeFragment = exports.schemaRefOrVal = exports.schemaHasRulesButRef = exports.schemaHasRules = exports.checkUnknownRules = exports.alwaysValidSchema = exports.toHash = undefined;
|
|
101949
103336
|
var codegen_1 = require_codegen2();
|
|
@@ -102136,7 +103523,7 @@ var require_errors3 = __commonJS((exports) => {
|
|
|
102136
103523
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
102137
103524
|
exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = undefined;
|
|
102138
103525
|
var codegen_1 = require_codegen2();
|
|
102139
|
-
var util_1 =
|
|
103526
|
+
var util_1 = require_util5();
|
|
102140
103527
|
var names_1 = require_names2();
|
|
102141
103528
|
exports.keywordError = {
|
|
102142
103529
|
message: ({ keyword }) => (0, codegen_1.str)`must pass "${keyword}" keyword validation`
|
|
@@ -102353,44 +103740,44 @@ var require_dataType2 = __commonJS((exports) => {
|
|
|
102353
103740
|
var applicability_1 = require_applicability2();
|
|
102354
103741
|
var errors_1 = require_errors3();
|
|
102355
103742
|
var codegen_1 = require_codegen2();
|
|
102356
|
-
var util_1 =
|
|
103743
|
+
var util_1 = require_util5();
|
|
102357
103744
|
var DataType;
|
|
102358
103745
|
(function(DataType2) {
|
|
102359
103746
|
DataType2[DataType2["Correct"] = 0] = "Correct";
|
|
102360
103747
|
DataType2[DataType2["Wrong"] = 1] = "Wrong";
|
|
102361
103748
|
})(DataType || (exports.DataType = DataType = {}));
|
|
102362
103749
|
function getSchemaTypes(schema) {
|
|
102363
|
-
const
|
|
102364
|
-
const hasNull =
|
|
103750
|
+
const types7 = getJSONTypes(schema.type);
|
|
103751
|
+
const hasNull = types7.includes("null");
|
|
102365
103752
|
if (hasNull) {
|
|
102366
103753
|
if (schema.nullable === false)
|
|
102367
103754
|
throw new Error("type: null contradicts nullable: false");
|
|
102368
103755
|
} else {
|
|
102369
|
-
if (!
|
|
103756
|
+
if (!types7.length && schema.nullable !== undefined) {
|
|
102370
103757
|
throw new Error('"nullable" cannot be used without "type"');
|
|
102371
103758
|
}
|
|
102372
103759
|
if (schema.nullable === true)
|
|
102373
|
-
|
|
103760
|
+
types7.push("null");
|
|
102374
103761
|
}
|
|
102375
|
-
return
|
|
103762
|
+
return types7;
|
|
102376
103763
|
}
|
|
102377
103764
|
exports.getSchemaTypes = getSchemaTypes;
|
|
102378
103765
|
function getJSONTypes(ts) {
|
|
102379
|
-
const
|
|
102380
|
-
if (
|
|
102381
|
-
return
|
|
102382
|
-
throw new Error("type must be JSONType or JSONType[]: " +
|
|
103766
|
+
const types7 = Array.isArray(ts) ? ts : ts ? [ts] : [];
|
|
103767
|
+
if (types7.every(rules_1.isJSONType))
|
|
103768
|
+
return types7;
|
|
103769
|
+
throw new Error("type must be JSONType or JSONType[]: " + types7.join(","));
|
|
102383
103770
|
}
|
|
102384
103771
|
exports.getJSONTypes = getJSONTypes;
|
|
102385
|
-
function coerceAndCheckDataType(it,
|
|
103772
|
+
function coerceAndCheckDataType(it, types7) {
|
|
102386
103773
|
const { gen, data, opts } = it;
|
|
102387
|
-
const coerceTo = coerceToTypes(
|
|
102388
|
-
const checkTypes =
|
|
103774
|
+
const coerceTo = coerceToTypes(types7, opts.coerceTypes);
|
|
103775
|
+
const checkTypes = types7.length > 0 && !(coerceTo.length === 0 && types7.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types7[0]));
|
|
102389
103776
|
if (checkTypes) {
|
|
102390
|
-
const wrongType = checkDataTypes(
|
|
103777
|
+
const wrongType = checkDataTypes(types7, data, opts.strictNumbers, DataType.Wrong);
|
|
102391
103778
|
gen.if(wrongType, () => {
|
|
102392
103779
|
if (coerceTo.length)
|
|
102393
|
-
coerceData(it,
|
|
103780
|
+
coerceData(it, types7, coerceTo);
|
|
102394
103781
|
else
|
|
102395
103782
|
reportTypeError(it);
|
|
102396
103783
|
});
|
|
@@ -102399,15 +103786,15 @@ var require_dataType2 = __commonJS((exports) => {
|
|
|
102399
103786
|
}
|
|
102400
103787
|
exports.coerceAndCheckDataType = coerceAndCheckDataType;
|
|
102401
103788
|
var COERCIBLE = new Set(["string", "number", "integer", "boolean", "null"]);
|
|
102402
|
-
function coerceToTypes(
|
|
102403
|
-
return coerceTypes ?
|
|
103789
|
+
function coerceToTypes(types7, coerceTypes) {
|
|
103790
|
+
return coerceTypes ? types7.filter((t2) => COERCIBLE.has(t2) || coerceTypes === "array" && t2 === "array") : [];
|
|
102404
103791
|
}
|
|
102405
|
-
function coerceData(it,
|
|
103792
|
+
function coerceData(it, types7, coerceTo) {
|
|
102406
103793
|
const { gen, data, opts } = it;
|
|
102407
103794
|
const dataType = gen.let("dataType", (0, codegen_1._)`typeof ${data}`);
|
|
102408
103795
|
const coerced = gen.let("coerced", (0, codegen_1._)`undefined`);
|
|
102409
103796
|
if (opts.coerceTypes === "array") {
|
|
102410
|
-
gen.if((0, codegen_1._)`${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1._)`${data}[0]`).assign(dataType, (0, codegen_1._)`typeof ${data}`).if(checkDataTypes(
|
|
103797
|
+
gen.if((0, codegen_1._)`${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1._)`${data}[0]`).assign(dataType, (0, codegen_1._)`typeof ${data}`).if(checkDataTypes(types7, data, opts.strictNumbers), () => gen.assign(coerced, data)));
|
|
102411
103798
|
}
|
|
102412
103799
|
gen.if((0, codegen_1._)`${coerced} !== undefined`);
|
|
102413
103800
|
for (const t2 of coerceTo) {
|
|
@@ -102483,19 +103870,19 @@ var require_dataType2 = __commonJS((exports) => {
|
|
|
102483
103870
|
return checkDataType(dataTypes[0], data, strictNums, correct);
|
|
102484
103871
|
}
|
|
102485
103872
|
let cond;
|
|
102486
|
-
const
|
|
102487
|
-
if (
|
|
103873
|
+
const types7 = (0, util_1.toHash)(dataTypes);
|
|
103874
|
+
if (types7.array && types7.object) {
|
|
102488
103875
|
const notObj = (0, codegen_1._)`typeof ${data} != "object"`;
|
|
102489
|
-
cond =
|
|
102490
|
-
delete
|
|
102491
|
-
delete
|
|
102492
|
-
delete
|
|
103876
|
+
cond = types7.null ? notObj : (0, codegen_1._)`!${data} || ${notObj}`;
|
|
103877
|
+
delete types7.null;
|
|
103878
|
+
delete types7.array;
|
|
103879
|
+
delete types7.object;
|
|
102493
103880
|
} else {
|
|
102494
103881
|
cond = codegen_1.nil;
|
|
102495
103882
|
}
|
|
102496
|
-
if (
|
|
102497
|
-
delete
|
|
102498
|
-
for (const t2 in
|
|
103883
|
+
if (types7.number)
|
|
103884
|
+
delete types7.integer;
|
|
103885
|
+
for (const t2 in types7)
|
|
102499
103886
|
cond = (0, codegen_1.and)(cond, checkDataType(t2, data, strictNums, correct));
|
|
102500
103887
|
return cond;
|
|
102501
103888
|
}
|
|
@@ -102531,7 +103918,7 @@ var require_defaults2 = __commonJS((exports) => {
|
|
|
102531
103918
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
102532
103919
|
exports.assignDefaults = undefined;
|
|
102533
103920
|
var codegen_1 = require_codegen2();
|
|
102534
|
-
var util_1 =
|
|
103921
|
+
var util_1 = require_util5();
|
|
102535
103922
|
function assignDefaults(it, ty) {
|
|
102536
103923
|
const { properties, items } = it.schema;
|
|
102537
103924
|
if (ty === "object" && properties) {
|
|
@@ -102565,9 +103952,9 @@ var require_code4 = __commonJS((exports) => {
|
|
|
102565
103952
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
102566
103953
|
exports.validateUnion = exports.validateArray = exports.usePattern = exports.callValidateCode = exports.schemaProperties = exports.allSchemaProperties = exports.noPropertyInData = exports.propertyInData = exports.isOwnProperty = exports.hasPropFunc = exports.reportMissingProp = exports.checkMissingProp = exports.checkReportMissingProp = undefined;
|
|
102567
103954
|
var codegen_1 = require_codegen2();
|
|
102568
|
-
var util_1 =
|
|
103955
|
+
var util_1 = require_util5();
|
|
102569
103956
|
var names_1 = require_names2();
|
|
102570
|
-
var util_2 =
|
|
103957
|
+
var util_2 = require_util5();
|
|
102571
103958
|
function checkReportMissingProp(cxt, prop) {
|
|
102572
103959
|
const { gen, data, it } = cxt;
|
|
102573
103960
|
gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
|
|
@@ -102809,7 +104196,7 @@ var require_subschema2 = __commonJS((exports) => {
|
|
|
102809
104196
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
102810
104197
|
exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = undefined;
|
|
102811
104198
|
var codegen_1 = require_codegen2();
|
|
102812
|
-
var util_1 =
|
|
104199
|
+
var util_1 = require_util5();
|
|
102813
104200
|
function getSubschema(it, { keyword, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
|
|
102814
104201
|
if (keyword !== undefined && schema !== undefined) {
|
|
102815
104202
|
throw new Error('both "keyword" and "schema" passed, only one allowed');
|
|
@@ -102888,7 +104275,7 @@ var require_subschema2 = __commonJS((exports) => {
|
|
|
102888
104275
|
var require_resolve2 = __commonJS((exports) => {
|
|
102889
104276
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
102890
104277
|
exports.getSchemaRefs = exports.resolveUrl = exports.normalizeId = exports._getFullPath = exports.getFullPath = exports.inlineRef = undefined;
|
|
102891
|
-
var util_1 =
|
|
104278
|
+
var util_1 = require_util5();
|
|
102892
104279
|
var equal = require_fast_deep_equal();
|
|
102893
104280
|
var traverse = require_json_schema_traverse();
|
|
102894
104281
|
var SIMPLE_INLINED = new Set([
|
|
@@ -103051,7 +104438,7 @@ var require_validate2 = __commonJS((exports) => {
|
|
|
103051
104438
|
var codegen_1 = require_codegen2();
|
|
103052
104439
|
var names_1 = require_names2();
|
|
103053
104440
|
var resolve_1 = require_resolve2();
|
|
103054
|
-
var util_1 =
|
|
104441
|
+
var util_1 = require_util5();
|
|
103055
104442
|
var errors_1 = require_errors3();
|
|
103056
104443
|
function validateFunctionCode(it) {
|
|
103057
104444
|
if (isSchemaObj(it)) {
|
|
@@ -103158,9 +104545,9 @@ var require_validate2 = __commonJS((exports) => {
|
|
|
103158
104545
|
function typeAndKeywords(it, errsCount) {
|
|
103159
104546
|
if (it.opts.jtd)
|
|
103160
104547
|
return schemaKeywords(it, [], false, errsCount);
|
|
103161
|
-
const
|
|
103162
|
-
const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it,
|
|
103163
|
-
schemaKeywords(it,
|
|
104548
|
+
const types7 = (0, dataType_1.getSchemaTypes)(it.schema);
|
|
104549
|
+
const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it, types7);
|
|
104550
|
+
schemaKeywords(it, types7, !checkedTypes, errsCount);
|
|
103164
104551
|
}
|
|
103165
104552
|
function checkRefsAndKeywords(it) {
|
|
103166
104553
|
const { schema, errSchemaPath, opts, self: self2 } = it;
|
|
@@ -103210,7 +104597,7 @@ var require_validate2 = __commonJS((exports) => {
|
|
|
103210
104597
|
if (items instanceof codegen_1.Name)
|
|
103211
104598
|
gen.assign((0, codegen_1._)`${evaluated}.items`, items);
|
|
103212
104599
|
}
|
|
103213
|
-
function schemaKeywords(it,
|
|
104600
|
+
function schemaKeywords(it, types7, typeErrors, errsCount) {
|
|
103214
104601
|
const { gen, schema, data, allErrors, opts, self: self2 } = it;
|
|
103215
104602
|
const { RULES } = self2;
|
|
103216
104603
|
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema, RULES))) {
|
|
@@ -103218,7 +104605,7 @@ var require_validate2 = __commonJS((exports) => {
|
|
|
103218
104605
|
return;
|
|
103219
104606
|
}
|
|
103220
104607
|
if (!opts.jtd)
|
|
103221
|
-
checkStrictTypes(it,
|
|
104608
|
+
checkStrictTypes(it, types7);
|
|
103222
104609
|
gen.block(() => {
|
|
103223
104610
|
for (const group of RULES.rules)
|
|
103224
104611
|
groupKeywords(group);
|
|
@@ -103230,7 +104617,7 @@ var require_validate2 = __commonJS((exports) => {
|
|
|
103230
104617
|
if (group.type) {
|
|
103231
104618
|
gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
|
|
103232
104619
|
iterateKeywords(it, group);
|
|
103233
|
-
if (
|
|
104620
|
+
if (types7.length === 1 && types7[0] === group.type && typeErrors) {
|
|
103234
104621
|
gen.else();
|
|
103235
104622
|
(0, dataType_2.reportTypeError)(it);
|
|
103236
104623
|
}
|
|
@@ -103254,27 +104641,27 @@ var require_validate2 = __commonJS((exports) => {
|
|
|
103254
104641
|
}
|
|
103255
104642
|
});
|
|
103256
104643
|
}
|
|
103257
|
-
function checkStrictTypes(it,
|
|
104644
|
+
function checkStrictTypes(it, types7) {
|
|
103258
104645
|
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
|
103259
104646
|
return;
|
|
103260
|
-
checkContextTypes(it,
|
|
104647
|
+
checkContextTypes(it, types7);
|
|
103261
104648
|
if (!it.opts.allowUnionTypes)
|
|
103262
|
-
checkMultipleTypes(it,
|
|
104649
|
+
checkMultipleTypes(it, types7);
|
|
103263
104650
|
checkKeywordTypes(it, it.dataTypes);
|
|
103264
104651
|
}
|
|
103265
|
-
function checkContextTypes(it,
|
|
103266
|
-
if (!
|
|
104652
|
+
function checkContextTypes(it, types7) {
|
|
104653
|
+
if (!types7.length)
|
|
103267
104654
|
return;
|
|
103268
104655
|
if (!it.dataTypes.length) {
|
|
103269
|
-
it.dataTypes =
|
|
104656
|
+
it.dataTypes = types7;
|
|
103270
104657
|
return;
|
|
103271
104658
|
}
|
|
103272
|
-
|
|
104659
|
+
types7.forEach((t2) => {
|
|
103273
104660
|
if (!includesType(it.dataTypes, t2)) {
|
|
103274
104661
|
strictTypesError(it, `type "${t2}" not allowed by context "${it.dataTypes.join(",")}"`);
|
|
103275
104662
|
}
|
|
103276
104663
|
});
|
|
103277
|
-
narrowSchemaTypes(it,
|
|
104664
|
+
narrowSchemaTypes(it, types7);
|
|
103278
104665
|
}
|
|
103279
104666
|
function checkMultipleTypes(it, ts) {
|
|
103280
104667
|
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
@@ -103579,7 +104966,7 @@ var require_compile2 = __commonJS((exports) => {
|
|
|
103579
104966
|
var validation_error_1 = require_validation_error2();
|
|
103580
104967
|
var names_1 = require_names2();
|
|
103581
104968
|
var resolve_1 = require_resolve2();
|
|
103582
|
-
var util_1 =
|
|
104969
|
+
var util_1 = require_util5();
|
|
103583
104970
|
var validate_1 = require_validate2();
|
|
103584
104971
|
|
|
103585
104972
|
class SchemaEnv {
|
|
@@ -103693,7 +105080,7 @@ var require_compile2 = __commonJS((exports) => {
|
|
|
103693
105080
|
const schOrFunc = root2.refs[ref];
|
|
103694
105081
|
if (schOrFunc)
|
|
103695
105082
|
return schOrFunc;
|
|
103696
|
-
let _sch =
|
|
105083
|
+
let _sch = resolve6.call(this, root2, ref);
|
|
103697
105084
|
if (_sch === undefined) {
|
|
103698
105085
|
const schema = (_a16 = root2.localRefs) === null || _a16 === undefined ? undefined : _a16[ref];
|
|
103699
105086
|
const { schemaId } = this.opts;
|
|
@@ -103720,7 +105107,7 @@ var require_compile2 = __commonJS((exports) => {
|
|
|
103720
105107
|
function sameSchemaEnv(s1, s2) {
|
|
103721
105108
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
103722
105109
|
}
|
|
103723
|
-
function
|
|
105110
|
+
function resolve6(root2, ref) {
|
|
103724
105111
|
let sch;
|
|
103725
105112
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
103726
105113
|
ref = sch;
|
|
@@ -104536,7 +105923,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
104536
105923
|
target.fragment = relative3.fragment;
|
|
104537
105924
|
return target;
|
|
104538
105925
|
}
|
|
104539
|
-
function
|
|
105926
|
+
function resolve6(baseURI, relativeURI, options) {
|
|
104540
105927
|
var schemelessOptions = assign({ scheme: "null" }, options);
|
|
104541
105928
|
return serialize(resolveComponents(parse6(baseURI, schemelessOptions), parse6(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
|
|
104542
105929
|
}
|
|
@@ -104804,7 +106191,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
104804
106191
|
exports2.removeDotSegments = removeDotSegments;
|
|
104805
106192
|
exports2.serialize = serialize;
|
|
104806
106193
|
exports2.resolveComponents = resolveComponents;
|
|
104807
|
-
exports2.resolve =
|
|
106194
|
+
exports2.resolve = resolve6;
|
|
104808
106195
|
exports2.normalize = normalize5;
|
|
104809
106196
|
exports2.equal = equal;
|
|
104810
106197
|
exports2.escapeComponent = escapeComponent;
|
|
@@ -104855,7 +106242,7 @@ var require_core3 = __commonJS((exports) => {
|
|
|
104855
106242
|
var codegen_2 = require_codegen2();
|
|
104856
106243
|
var resolve_1 = require_resolve2();
|
|
104857
106244
|
var dataType_1 = require_dataType2();
|
|
104858
|
-
var util_1 =
|
|
106245
|
+
var util_1 = require_util5();
|
|
104859
106246
|
var $dataRefSchema = require_data2();
|
|
104860
106247
|
var uri_1 = require_uri2();
|
|
104861
106248
|
var defaultRegExp = (str, flags) => new RegExp(str, flags);
|
|
@@ -105435,7 +106822,7 @@ var require_ref2 = __commonJS((exports) => {
|
|
|
105435
106822
|
var codegen_1 = require_codegen2();
|
|
105436
106823
|
var names_1 = require_names2();
|
|
105437
106824
|
var compile_1 = require_compile2();
|
|
105438
|
-
var util_1 =
|
|
106825
|
+
var util_1 = require_util5();
|
|
105439
106826
|
var def = {
|
|
105440
106827
|
keyword: "$ref",
|
|
105441
106828
|
schemaType: "string",
|
|
@@ -105644,7 +107031,7 @@ var require_ucs2length2 = __commonJS((exports) => {
|
|
|
105644
107031
|
var require_limitLength2 = __commonJS((exports) => {
|
|
105645
107032
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
105646
107033
|
var codegen_1 = require_codegen2();
|
|
105647
|
-
var util_1 =
|
|
107034
|
+
var util_1 = require_util5();
|
|
105648
107035
|
var ucs2length_1 = require_ucs2length2();
|
|
105649
107036
|
var error48 = {
|
|
105650
107037
|
message({ keyword, schemaCode }) {
|
|
@@ -105725,7 +107112,7 @@ var require_required2 = __commonJS((exports) => {
|
|
|
105725
107112
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
105726
107113
|
var code_1 = require_code4();
|
|
105727
107114
|
var codegen_1 = require_codegen2();
|
|
105728
|
-
var util_1 =
|
|
107115
|
+
var util_1 = require_util5();
|
|
105729
107116
|
var error48 = {
|
|
105730
107117
|
message: ({ params: { missingProperty } }) => (0, codegen_1.str)`must have required property '${missingProperty}'`,
|
|
105731
107118
|
params: ({ params: { missingProperty } }) => (0, codegen_1._)`{missingProperty: ${missingProperty}}`
|
|
@@ -105838,7 +107225,7 @@ var require_uniqueItems2 = __commonJS((exports) => {
|
|
|
105838
107225
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
105839
107226
|
var dataType_1 = require_dataType2();
|
|
105840
107227
|
var codegen_1 = require_codegen2();
|
|
105841
|
-
var util_1 =
|
|
107228
|
+
var util_1 = require_util5();
|
|
105842
107229
|
var equal_1 = require_equal2();
|
|
105843
107230
|
var error48 = {
|
|
105844
107231
|
message: ({ params: { i: i2, j } }) => (0, codegen_1.str)`must NOT have duplicate items (items ## ${j} and ${i2} are identical)`,
|
|
@@ -105901,7 +107288,7 @@ var require_uniqueItems2 = __commonJS((exports) => {
|
|
|
105901
107288
|
var require_const2 = __commonJS((exports) => {
|
|
105902
107289
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
105903
107290
|
var codegen_1 = require_codegen2();
|
|
105904
|
-
var util_1 =
|
|
107291
|
+
var util_1 = require_util5();
|
|
105905
107292
|
var equal_1 = require_equal2();
|
|
105906
107293
|
var error48 = {
|
|
105907
107294
|
message: "must be equal to constant",
|
|
@@ -105927,7 +107314,7 @@ var require_const2 = __commonJS((exports) => {
|
|
|
105927
107314
|
var require_enum2 = __commonJS((exports) => {
|
|
105928
107315
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
105929
107316
|
var codegen_1 = require_codegen2();
|
|
105930
|
-
var util_1 =
|
|
107317
|
+
var util_1 = require_util5();
|
|
105931
107318
|
var equal_1 = require_equal2();
|
|
105932
107319
|
var error48 = {
|
|
105933
107320
|
message: "must be equal to one of the allowed values",
|
|
@@ -106004,7 +107391,7 @@ var require_additionalItems2 = __commonJS((exports) => {
|
|
|
106004
107391
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106005
107392
|
exports.validateAdditionalItems = undefined;
|
|
106006
107393
|
var codegen_1 = require_codegen2();
|
|
106007
|
-
var util_1 =
|
|
107394
|
+
var util_1 = require_util5();
|
|
106008
107395
|
var error48 = {
|
|
106009
107396
|
message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than ${len} items`,
|
|
106010
107397
|
params: ({ params: { len } }) => (0, codegen_1._)`{limit: ${len}}`
|
|
@@ -106054,7 +107441,7 @@ var require_items2 = __commonJS((exports) => {
|
|
|
106054
107441
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106055
107442
|
exports.validateTuple = undefined;
|
|
106056
107443
|
var codegen_1 = require_codegen2();
|
|
106057
|
-
var util_1 =
|
|
107444
|
+
var util_1 = require_util5();
|
|
106058
107445
|
var code_1 = require_code4();
|
|
106059
107446
|
var def = {
|
|
106060
107447
|
keyword: "items",
|
|
@@ -106121,7 +107508,7 @@ var require_prefixItems2 = __commonJS((exports) => {
|
|
|
106121
107508
|
var require_items20202 = __commonJS((exports) => {
|
|
106122
107509
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106123
107510
|
var codegen_1 = require_codegen2();
|
|
106124
|
-
var util_1 =
|
|
107511
|
+
var util_1 = require_util5();
|
|
106125
107512
|
var code_1 = require_code4();
|
|
106126
107513
|
var additionalItems_1 = require_additionalItems2();
|
|
106127
107514
|
var error48 = {
|
|
@@ -106153,7 +107540,7 @@ var require_items20202 = __commonJS((exports) => {
|
|
|
106153
107540
|
var require_contains2 = __commonJS((exports) => {
|
|
106154
107541
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106155
107542
|
var codegen_1 = require_codegen2();
|
|
106156
|
-
var util_1 =
|
|
107543
|
+
var util_1 = require_util5();
|
|
106157
107544
|
var error48 = {
|
|
106158
107545
|
message: ({ params: { min, max } }) => max === undefined ? (0, codegen_1.str)`must contain at least ${min} valid item(s)` : (0, codegen_1.str)`must contain at least ${min} and no more than ${max} valid item(s)`,
|
|
106159
107546
|
params: ({ params: { min, max } }) => max === undefined ? (0, codegen_1._)`{minContains: ${min}}` : (0, codegen_1._)`{minContains: ${min}, maxContains: ${max}}`
|
|
@@ -106245,7 +107632,7 @@ var require_dependencies2 = __commonJS((exports) => {
|
|
|
106245
107632
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106246
107633
|
exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = undefined;
|
|
106247
107634
|
var codegen_1 = require_codegen2();
|
|
106248
|
-
var util_1 =
|
|
107635
|
+
var util_1 = require_util5();
|
|
106249
107636
|
var code_1 = require_code4();
|
|
106250
107637
|
exports.error = {
|
|
106251
107638
|
message: ({ params: { property, depsCount, deps } }) => {
|
|
@@ -106329,7 +107716,7 @@ var require_dependencies2 = __commonJS((exports) => {
|
|
|
106329
107716
|
var require_propertyNames2 = __commonJS((exports) => {
|
|
106330
107717
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106331
107718
|
var codegen_1 = require_codegen2();
|
|
106332
|
-
var util_1 =
|
|
107719
|
+
var util_1 = require_util5();
|
|
106333
107720
|
var error48 = {
|
|
106334
107721
|
message: "property name must be valid",
|
|
106335
107722
|
params: ({ params }) => (0, codegen_1._)`{propertyName: ${params.propertyName}}`
|
|
@@ -106371,7 +107758,7 @@ var require_additionalProperties2 = __commonJS((exports) => {
|
|
|
106371
107758
|
var code_1 = require_code4();
|
|
106372
107759
|
var codegen_1 = require_codegen2();
|
|
106373
107760
|
var names_1 = require_names2();
|
|
106374
|
-
var util_1 =
|
|
107761
|
+
var util_1 = require_util5();
|
|
106375
107762
|
var error48 = {
|
|
106376
107763
|
message: "must NOT have additional properties",
|
|
106377
107764
|
params: ({ params }) => (0, codegen_1._)`{additionalProperty: ${params.additionalProperty}}`
|
|
@@ -106473,7 +107860,7 @@ var require_properties2 = __commonJS((exports) => {
|
|
|
106473
107860
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106474
107861
|
var validate_1 = require_validate2();
|
|
106475
107862
|
var code_1 = require_code4();
|
|
106476
|
-
var util_1 =
|
|
107863
|
+
var util_1 = require_util5();
|
|
106477
107864
|
var additionalProperties_1 = require_additionalProperties2();
|
|
106478
107865
|
var def = {
|
|
106479
107866
|
keyword: "properties",
|
|
@@ -106528,8 +107915,8 @@ var require_patternProperties2 = __commonJS((exports) => {
|
|
|
106528
107915
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106529
107916
|
var code_1 = require_code4();
|
|
106530
107917
|
var codegen_1 = require_codegen2();
|
|
106531
|
-
var util_1 =
|
|
106532
|
-
var util_2 =
|
|
107918
|
+
var util_1 = require_util5();
|
|
107919
|
+
var util_2 = require_util5();
|
|
106533
107920
|
var def = {
|
|
106534
107921
|
keyword: "patternProperties",
|
|
106535
107922
|
type: "object",
|
|
@@ -106597,7 +107984,7 @@ var require_patternProperties2 = __commonJS((exports) => {
|
|
|
106597
107984
|
// ../../node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/not.js
|
|
106598
107985
|
var require_not2 = __commonJS((exports) => {
|
|
106599
107986
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106600
|
-
var util_1 =
|
|
107987
|
+
var util_1 = require_util5();
|
|
106601
107988
|
var def = {
|
|
106602
107989
|
keyword: "not",
|
|
106603
107990
|
schemaType: ["object", "boolean"],
|
|
@@ -106640,7 +108027,7 @@ var require_anyOf2 = __commonJS((exports) => {
|
|
|
106640
108027
|
var require_oneOf2 = __commonJS((exports) => {
|
|
106641
108028
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106642
108029
|
var codegen_1 = require_codegen2();
|
|
106643
|
-
var util_1 =
|
|
108030
|
+
var util_1 = require_util5();
|
|
106644
108031
|
var error48 = {
|
|
106645
108032
|
message: "must match exactly one schema in oneOf",
|
|
106646
108033
|
params: ({ params }) => (0, codegen_1._)`{passingSchemas: ${params.passing}}`
|
|
@@ -106694,7 +108081,7 @@ var require_oneOf2 = __commonJS((exports) => {
|
|
|
106694
108081
|
// ../../node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/allOf.js
|
|
106695
108082
|
var require_allOf2 = __commonJS((exports) => {
|
|
106696
108083
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106697
|
-
var util_1 =
|
|
108084
|
+
var util_1 = require_util5();
|
|
106698
108085
|
var def = {
|
|
106699
108086
|
keyword: "allOf",
|
|
106700
108087
|
schemaType: "array",
|
|
@@ -106719,7 +108106,7 @@ var require_allOf2 = __commonJS((exports) => {
|
|
|
106719
108106
|
var require_if2 = __commonJS((exports) => {
|
|
106720
108107
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106721
108108
|
var codegen_1 = require_codegen2();
|
|
106722
|
-
var util_1 =
|
|
108109
|
+
var util_1 = require_util5();
|
|
106723
108110
|
var error48 = {
|
|
106724
108111
|
message: ({ params }) => (0, codegen_1.str)`must match "${params.ifClause}" schema`,
|
|
106725
108112
|
params: ({ params }) => (0, codegen_1._)`{failingKeyword: ${params.ifClause}}`
|
|
@@ -106784,7 +108171,7 @@ var require_if2 = __commonJS((exports) => {
|
|
|
106784
108171
|
// ../../node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/thenElse.js
|
|
106785
108172
|
var require_thenElse2 = __commonJS((exports) => {
|
|
106786
108173
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106787
|
-
var util_1 =
|
|
108174
|
+
var util_1 = require_util5();
|
|
106788
108175
|
var def = {
|
|
106789
108176
|
keyword: ["then", "else"],
|
|
106790
108177
|
schemaType: ["object", "boolean"],
|
|
@@ -106990,7 +108377,7 @@ var require_discriminator2 = __commonJS((exports) => {
|
|
|
106990
108377
|
var codegen_1 = require_codegen2();
|
|
106991
108378
|
var types_1 = require_types3();
|
|
106992
108379
|
var compile_1 = require_compile2();
|
|
106993
|
-
var util_1 =
|
|
108380
|
+
var util_1 = require_util5();
|
|
106994
108381
|
var error48 = {
|
|
106995
108382
|
message: ({ params: { discrError, tagName } }) => discrError === types_1.DiscrError.Tag ? `tag "${tagName}" must be string` : `value of tag "${tagName}" must be in oneOf`,
|
|
106996
108383
|
params: ({ params: { discrError, tag, tagName } }) => (0, codegen_1._)`{error: ${discrError}, tag: ${tagName}, tagValue: ${tag}}`
|
|
@@ -108121,12 +109508,12 @@ var require_isexe = __commonJS((exports, module) => {
|
|
|
108121
109508
|
if (typeof Promise !== "function") {
|
|
108122
109509
|
throw new TypeError("callback not provided");
|
|
108123
109510
|
}
|
|
108124
|
-
return new Promise(function(
|
|
109511
|
+
return new Promise(function(resolve6, reject) {
|
|
108125
109512
|
isexe(path11, options || {}, function(er, is) {
|
|
108126
109513
|
if (er) {
|
|
108127
109514
|
reject(er);
|
|
108128
109515
|
} else {
|
|
108129
|
-
|
|
109516
|
+
resolve6(is);
|
|
108130
109517
|
}
|
|
108131
109518
|
});
|
|
108132
109519
|
});
|
|
@@ -108188,27 +109575,27 @@ var require_which = __commonJS((exports, module) => {
|
|
|
108188
109575
|
opt = {};
|
|
108189
109576
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
108190
109577
|
const found = [];
|
|
108191
|
-
const step = (i2) => new Promise((
|
|
109578
|
+
const step = (i2) => new Promise((resolve6, reject) => {
|
|
108192
109579
|
if (i2 === pathEnv.length)
|
|
108193
|
-
return opt.all && found.length ?
|
|
109580
|
+
return opt.all && found.length ? resolve6(found) : reject(getNotFoundError(cmd));
|
|
108194
109581
|
const ppRaw = pathEnv[i2];
|
|
108195
109582
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
108196
109583
|
const pCmd = path11.join(pathPart, cmd);
|
|
108197
109584
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
108198
|
-
|
|
109585
|
+
resolve6(subStep(p, i2, 0));
|
|
108199
109586
|
});
|
|
108200
|
-
const subStep = (p, i2, ii) => new Promise((
|
|
109587
|
+
const subStep = (p, i2, ii) => new Promise((resolve6, reject) => {
|
|
108201
109588
|
if (ii === pathExt.length)
|
|
108202
|
-
return
|
|
109589
|
+
return resolve6(step(i2 + 1));
|
|
108203
109590
|
const ext = pathExt[ii];
|
|
108204
109591
|
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
108205
109592
|
if (!er && is) {
|
|
108206
109593
|
if (opt.all)
|
|
108207
109594
|
found.push(p + ext);
|
|
108208
109595
|
else
|
|
108209
|
-
return
|
|
109596
|
+
return resolve6(p + ext);
|
|
108210
109597
|
}
|
|
108211
|
-
return
|
|
109598
|
+
return resolve6(subStep(p, i2, ii + 1));
|
|
108212
109599
|
});
|
|
108213
109600
|
});
|
|
108214
109601
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -108552,7 +109939,7 @@ class StdioClientTransport {
|
|
|
108552
109939
|
if (this._process) {
|
|
108553
109940
|
throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
108554
109941
|
}
|
|
108555
|
-
return new Promise((
|
|
109942
|
+
return new Promise((resolve6, reject) => {
|
|
108556
109943
|
this._process = import_cross_spawn.default(this._serverParams.command, this._serverParams.args ?? [], {
|
|
108557
109944
|
env: {
|
|
108558
109945
|
...getDefaultEnvironment(),
|
|
@@ -108568,7 +109955,7 @@ class StdioClientTransport {
|
|
|
108568
109955
|
this.onerror?.(error48);
|
|
108569
109956
|
});
|
|
108570
109957
|
this._process.on("spawn", () => {
|
|
108571
|
-
|
|
109958
|
+
resolve6();
|
|
108572
109959
|
});
|
|
108573
109960
|
this._process.on("close", (_code) => {
|
|
108574
109961
|
this._process = undefined;
|
|
@@ -108615,20 +110002,20 @@ class StdioClientTransport {
|
|
|
108615
110002
|
if (this._process) {
|
|
108616
110003
|
const processToClose = this._process;
|
|
108617
110004
|
this._process = undefined;
|
|
108618
|
-
const closePromise = new Promise((
|
|
110005
|
+
const closePromise = new Promise((resolve6) => {
|
|
108619
110006
|
processToClose.once("close", () => {
|
|
108620
|
-
|
|
110007
|
+
resolve6();
|
|
108621
110008
|
});
|
|
108622
110009
|
});
|
|
108623
110010
|
try {
|
|
108624
110011
|
processToClose.stdin?.end();
|
|
108625
110012
|
} catch {}
|
|
108626
|
-
await Promise.race([closePromise, new Promise((
|
|
110013
|
+
await Promise.race([closePromise, new Promise((resolve6) => setTimeout(resolve6, 2000).unref())]);
|
|
108627
110014
|
if (processToClose.exitCode === null) {
|
|
108628
110015
|
try {
|
|
108629
110016
|
processToClose.kill("SIGTERM");
|
|
108630
110017
|
} catch {}
|
|
108631
|
-
await Promise.race([closePromise, new Promise((
|
|
110018
|
+
await Promise.race([closePromise, new Promise((resolve6) => setTimeout(resolve6, 2000).unref())]);
|
|
108632
110019
|
}
|
|
108633
110020
|
if (processToClose.exitCode === null) {
|
|
108634
110021
|
try {
|
|
@@ -108639,15 +110026,15 @@ class StdioClientTransport {
|
|
|
108639
110026
|
this._readBuffer.clear();
|
|
108640
110027
|
}
|
|
108641
110028
|
send(message) {
|
|
108642
|
-
return new Promise((
|
|
110029
|
+
return new Promise((resolve6) => {
|
|
108643
110030
|
if (!this._process?.stdin) {
|
|
108644
110031
|
throw new Error("Not connected");
|
|
108645
110032
|
}
|
|
108646
110033
|
const json2 = serializeMessage(message);
|
|
108647
110034
|
if (this._process.stdin.write(json2)) {
|
|
108648
|
-
|
|
110035
|
+
resolve6();
|
|
108649
110036
|
} else {
|
|
108650
|
-
this._process.stdin.once("drain",
|
|
110037
|
+
this._process.stdin.once("drain", resolve6);
|
|
108651
110038
|
}
|
|
108652
110039
|
});
|
|
108653
110040
|
}
|
|
@@ -108827,12 +110214,12 @@ var {
|
|
|
108827
110214
|
Help
|
|
108828
110215
|
} = import__.default;
|
|
108829
110216
|
// package.json
|
|
108830
|
-
var version = "0.9.
|
|
110217
|
+
var version = "0.9.89";
|
|
108831
110218
|
|
|
108832
110219
|
// src/commands/agent.ts
|
|
108833
110220
|
init_src();
|
|
108834
110221
|
import { exec as exec3 } from "node:child_process";
|
|
108835
|
-
import { randomUUID } from "node:crypto";
|
|
110222
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
108836
110223
|
import * as fs12 from "node:fs/promises";
|
|
108837
110224
|
import * as path10 from "node:path";
|
|
108838
110225
|
import { promisify as promisify3 } from "node:util";
|
|
@@ -111222,7 +112609,7 @@ function createContinuousImprovementLoop(context, stateManager, _sessionId) {
|
|
|
111222
112609
|
context.logger.info("[Continuous] Wait interrupted");
|
|
111223
112610
|
return;
|
|
111224
112611
|
}
|
|
111225
|
-
await new Promise((
|
|
112612
|
+
await new Promise((resolve5) => setTimeout(resolve5, 1000));
|
|
111226
112613
|
}
|
|
111227
112614
|
}
|
|
111228
112615
|
return {
|
|
@@ -111573,10 +112960,10 @@ ${"═".repeat(60)}`);
|
|
|
111573
112960
|
input: process.stdin,
|
|
111574
112961
|
output: process.stdout
|
|
111575
112962
|
});
|
|
111576
|
-
const answer = await new Promise((
|
|
112963
|
+
const answer = await new Promise((resolve5) => {
|
|
111577
112964
|
rl.question("Approve this task? (yes/no): ", (response) => {
|
|
111578
112965
|
rl.close();
|
|
111579
|
-
|
|
112966
|
+
resolve5(response);
|
|
111580
112967
|
});
|
|
111581
112968
|
});
|
|
111582
112969
|
if (!answer) {
|
|
@@ -111655,10 +113042,10 @@ ${"═".repeat(60)}`);
|
|
|
111655
113042
|
input: process.stdin,
|
|
111656
113043
|
output: process.stdout
|
|
111657
113044
|
});
|
|
111658
|
-
return new Promise((
|
|
113045
|
+
return new Promise((resolve5) => {
|
|
111659
113046
|
rl.question(query, (answer) => {
|
|
111660
113047
|
rl.close();
|
|
111661
|
-
|
|
113048
|
+
resolve5(answer.trim());
|
|
111662
113049
|
});
|
|
111663
113050
|
});
|
|
111664
113051
|
}
|
|
@@ -112993,7 +114380,7 @@ async function runAgent(goal, options, _command) {
|
|
|
112993
114380
|
const config4 = await loadConfig(configOptions, options.config);
|
|
112994
114381
|
const workingDir = process.cwd();
|
|
112995
114382
|
const stateDir = path10.join(workingDir, ".polka", "agent-state");
|
|
112996
|
-
const sessionId = `agent-${Date.now()}-${
|
|
114383
|
+
const sessionId = `agent-${Date.now()}-${randomUUID2()}`;
|
|
112997
114384
|
const asyncExec = promisify3(exec3);
|
|
112998
114385
|
const tools3 = {
|
|
112999
114386
|
executeCommand: async (input) => {
|
|
@@ -113100,7 +114487,7 @@ ${errorStdout}` : ""}`);
|
|
|
113100
114487
|
var agentCommand = new Command("agent").description("Run autonomous agent (experimental)").argument("[goal]", "Goal to achieve", "").option("--continuous", "Run in continuous improvement mode").option("--preset <name>", "Configuration preset", "balanced").option("--config <path>", "Configuration file path").option("--approval-level <level>", "Approval level (none|destructive|commits|all)", "destructive").action(runAgent);
|
|
113101
114488
|
|
|
113102
114489
|
// src/commands/code.ts
|
|
113103
|
-
import { readFile as
|
|
114490
|
+
import { readFile as readFile11 } from "node:fs/promises";
|
|
113104
114491
|
init_mime_types();
|
|
113105
114492
|
|
|
113106
114493
|
// src/runWorkflow.ts
|
|
@@ -113476,8 +114863,6 @@ init_dist7();
|
|
|
113476
114863
|
init_errors5();
|
|
113477
114864
|
init_errors6();
|
|
113478
114865
|
import { spawn as spawn4, spawnSync as spawnSync2 } from "node:child_process";
|
|
113479
|
-
import fs13, { mkdir as mkdir7 } from "node:fs/promises";
|
|
113480
|
-
import { dirname as dirname5 } from "node:path";
|
|
113481
114866
|
|
|
113482
114867
|
// src/skillIntegration.ts
|
|
113483
114868
|
init_src();
|
|
@@ -113627,7 +115012,7 @@ async function confirm(input, context) {
|
|
|
113627
115012
|
if (context.yes) {
|
|
113628
115013
|
return true;
|
|
113629
115014
|
}
|
|
113630
|
-
await new Promise((
|
|
115015
|
+
await new Promise((resolve6) => setTimeout(resolve6, 50));
|
|
113631
115016
|
process.stderr.write("\x07");
|
|
113632
115017
|
return await dist_default4({ message: input.message });
|
|
113633
115018
|
}
|
|
@@ -113635,7 +115020,7 @@ async function input(input2, context) {
|
|
|
113635
115020
|
if (context.yes) {
|
|
113636
115021
|
return input2.default ?? "";
|
|
113637
115022
|
}
|
|
113638
|
-
await new Promise((
|
|
115023
|
+
await new Promise((resolve6) => setTimeout(resolve6, 50));
|
|
113639
115024
|
process.stderr.write("\x07");
|
|
113640
115025
|
const result = await getUserInput(input2.message, {
|
|
113641
115026
|
default: input2.default
|
|
@@ -113649,33 +115034,12 @@ async function select(input2, context) {
|
|
|
113649
115034
|
if (context.yes) {
|
|
113650
115035
|
return input2.choices[0].value;
|
|
113651
115036
|
}
|
|
113652
|
-
await new Promise((
|
|
115037
|
+
await new Promise((resolve6) => setTimeout(resolve6, 50));
|
|
113653
115038
|
process.stderr.write("\x07");
|
|
113654
115039
|
return await dist_default7({ message: input2.message, choices: input2.choices });
|
|
113655
115040
|
}
|
|
113656
|
-
async function writeToFile(input2) {
|
|
113657
|
-
await mkdir7(dirname5(input2.path), { recursive: true });
|
|
113658
|
-
await fs13.writeFile(input2.path, input2.content);
|
|
113659
|
-
return {
|
|
113660
|
-
success: true,
|
|
113661
|
-
message: {
|
|
113662
|
-
type: "text",
|
|
113663
|
-
value: `Successfully wrote to ${input2.path}`
|
|
113664
|
-
}
|
|
113665
|
-
};
|
|
113666
|
-
}
|
|
113667
|
-
async function readFile11(input2) {
|
|
113668
|
-
try {
|
|
113669
|
-
return await fs13.readFile(input2.path, "utf8");
|
|
113670
|
-
} catch (error48) {
|
|
113671
|
-
if (error48 && typeof error48 === "object" && "code" in error48 && (error48.code === "ENOENT" || error48.code === "EISDIR")) {
|
|
113672
|
-
return null;
|
|
113673
|
-
}
|
|
113674
|
-
throw error48;
|
|
113675
|
-
}
|
|
113676
|
-
}
|
|
113677
115041
|
async function executeCommand(input2) {
|
|
113678
|
-
return new Promise((
|
|
115042
|
+
return new Promise((resolve6, reject) => {
|
|
113679
115043
|
const child = input2.shell === true ? spawn4(input2.args && input2.args.length > 0 ? `${input2.command} ${input2.args.map(quoteForShell).join(" ")}` : input2.command, {
|
|
113680
115044
|
shell: true,
|
|
113681
115045
|
stdio: "pipe"
|
|
@@ -113691,7 +115055,7 @@ async function executeCommand(input2) {
|
|
|
113691
115055
|
let exitCode = null;
|
|
113692
115056
|
const checkAndResolve = () => {
|
|
113693
115057
|
if (stdoutEnded && stderrEnded && closeEventFired) {
|
|
113694
|
-
|
|
115058
|
+
resolve6({ exitCode: exitCode ?? -1, stdout, stderr });
|
|
113695
115059
|
}
|
|
113696
115060
|
};
|
|
113697
115061
|
if (child.stdout) {
|
|
@@ -113824,7 +115188,7 @@ async function generateText2(input2, context) {
|
|
|
113824
115188
|
lastError = providerError;
|
|
113825
115189
|
const backoff2 = computeRateLimitBackoffSeconds(i2);
|
|
113826
115190
|
console.debug(`Waiting ${backoff2}s before retry...`);
|
|
113827
|
-
await new Promise((
|
|
115191
|
+
await new Promise((resolve6) => setTimeout(resolve6, backoff2 * 1000));
|
|
113828
115192
|
continue;
|
|
113829
115193
|
}
|
|
113830
115194
|
throw providerError;
|
|
@@ -114008,8 +115372,6 @@ var localToolHandlers = {
|
|
|
114008
115372
|
confirm,
|
|
114009
115373
|
input,
|
|
114010
115374
|
select,
|
|
114011
|
-
writeToFile,
|
|
114012
|
-
readFile: readFile11,
|
|
114013
115375
|
executeCommand,
|
|
114014
115376
|
generateText: generateText2,
|
|
114015
115377
|
invokeTool,
|
|
@@ -114025,6 +115387,7 @@ var localToolHandlers = {
|
|
|
114025
115387
|
listSkills: listSkills3,
|
|
114026
115388
|
readSkillFile: readSkillFile3
|
|
114027
115389
|
};
|
|
115390
|
+
var localToolNames = Object.keys(localToolHandlers);
|
|
114028
115391
|
async function toolCall(toolCall2, context) {
|
|
114029
115392
|
const handler20 = localToolHandlers[toolCall2.tool];
|
|
114030
115393
|
if (handler20) {
|
|
@@ -114137,6 +115500,9 @@ async function runWorkflow(workflow2, workflowInput, options) {
|
|
|
114137
115500
|
if (typeof prop !== "string" || prop === "then" || prop === "toJSON") {
|
|
114138
115501
|
return;
|
|
114139
115502
|
}
|
|
115503
|
+
if (!toolHandlers.has(prop) && !localToolNames.includes(prop)) {
|
|
115504
|
+
return;
|
|
115505
|
+
}
|
|
114140
115506
|
return async (input2) => {
|
|
114141
115507
|
logger.debug(`Running tool: ${prop}`);
|
|
114142
115508
|
return await toolCall({ tool: prop, input: input2 }, {
|
|
@@ -114601,7 +115967,7 @@ var readStdin = async (timeoutMs = COMMAND_CONSTANTS.DEFAULT_STDIN_TIMEOUT_MS) =
|
|
|
114601
115967
|
if (process.stdin.isTTY) {
|
|
114602
115968
|
return "";
|
|
114603
115969
|
}
|
|
114604
|
-
return new Promise((
|
|
115970
|
+
return new Promise((resolve6, reject) => {
|
|
114605
115971
|
let input2 = "";
|
|
114606
115972
|
const cleanup = () => {
|
|
114607
115973
|
if (timeoutId)
|
|
@@ -114610,14 +115976,14 @@ var readStdin = async (timeoutMs = COMMAND_CONSTANTS.DEFAULT_STDIN_TIMEOUT_MS) =
|
|
|
114610
115976
|
};
|
|
114611
115977
|
const timeoutId = setTimeout(() => {
|
|
114612
115978
|
cleanup();
|
|
114613
|
-
|
|
115979
|
+
resolve6(input2);
|
|
114614
115980
|
}, timeoutMs);
|
|
114615
115981
|
process.stdin.on("data", (chunk) => {
|
|
114616
115982
|
input2 += chunk.toString();
|
|
114617
115983
|
});
|
|
114618
115984
|
process.stdin.on("end", () => {
|
|
114619
115985
|
cleanup();
|
|
114620
|
-
|
|
115986
|
+
resolve6(input2);
|
|
114621
115987
|
});
|
|
114622
115988
|
process.stdin.on("error", (err) => {
|
|
114623
115989
|
cleanup();
|
|
@@ -114638,7 +116004,7 @@ async function runCode(task2, _options, command) {
|
|
|
114638
116004
|
try {
|
|
114639
116005
|
const mimeType = $lookup(file2);
|
|
114640
116006
|
if (mimeType) {
|
|
114641
|
-
const buffer = await
|
|
116007
|
+
const buffer = await readFile11(file2);
|
|
114642
116008
|
if (mimeType.startsWith("image/")) {
|
|
114643
116009
|
fileContents.push({
|
|
114644
116010
|
type: "image",
|
|
@@ -114707,7 +116073,7 @@ var fixCommand = new Command("fix").description("Fix issues by running a command
|
|
|
114707
116073
|
// src/commands/init.ts
|
|
114708
116074
|
init_dist18();
|
|
114709
116075
|
init_src3();
|
|
114710
|
-
import { existsSync as
|
|
116076
|
+
import { existsSync as existsSync4, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
|
|
114711
116077
|
import { join as join14 } from "node:path";
|
|
114712
116078
|
init_lodash();
|
|
114713
116079
|
init_dist();
|
|
@@ -114862,54 +116228,56 @@ var initInteractiveWorkflow = async (input2, context) => {
|
|
|
114862
116228
|
const { configPath, scriptName, scriptInstructions, generateScript = false, skipConfirmation = false } = input2;
|
|
114863
116229
|
let generatedConfig = {};
|
|
114864
116230
|
let generatedScriptPath;
|
|
114865
|
-
|
|
114866
|
-
|
|
114867
|
-
|
|
114868
|
-
|
|
114869
|
-
|
|
114870
|
-
|
|
114871
|
-
|
|
114872
|
-
|
|
114873
|
-
|
|
114874
|
-
|
|
114875
|
-
|
|
114876
|
-
|
|
114877
|
-
|
|
114878
|
-
|
|
114879
|
-
|
|
114880
|
-
|
|
114881
|
-
|
|
114882
|
-
|
|
114883
|
-
|
|
114884
|
-
|
|
114885
|
-
|
|
114886
|
-
|
|
114887
|
-
|
|
114888
|
-
|
|
114889
|
-
|
|
114890
|
-
|
|
114891
|
-
|
|
114892
|
-
|
|
116231
|
+
if (!generateScript) {
|
|
116232
|
+
const analyzeResult = await step("analyze-project", async () => {
|
|
116233
|
+
logger.info("Analyzing project structure and configuration...");
|
|
116234
|
+
return await agentWorkflow({
|
|
116235
|
+
systemPrompt: INIT_WORKFLOW_ANALYZE_SYSTEM_PROMPT,
|
|
116236
|
+
userMessage: [
|
|
116237
|
+
{
|
|
116238
|
+
role: "user",
|
|
116239
|
+
content: "Please provide a valid polkacodes YAML configuration for the project."
|
|
116240
|
+
}
|
|
116241
|
+
],
|
|
116242
|
+
tools: [readFile_default, listFiles_default, searchFiles_default],
|
|
116243
|
+
outputSchema: exports_external.object({ yaml: exports_external.string() })
|
|
116244
|
+
}, { logger, tools: tools3, step });
|
|
116245
|
+
});
|
|
116246
|
+
if (analyzeResult.type === "Exit" && analyzeResult.object) {
|
|
116247
|
+
const yamlConfig = analyzeResult.object.yaml;
|
|
116248
|
+
generatedConfig = yamlConfig ? $parse(yamlConfig) : {};
|
|
116249
|
+
}
|
|
116250
|
+
await step("save-config", async () => {
|
|
116251
|
+
const existingConfig = loadConfigAtPath(configPath) ?? {};
|
|
116252
|
+
const finalConfig = {
|
|
116253
|
+
...existingConfig,
|
|
116254
|
+
...generatedConfig
|
|
116255
|
+
};
|
|
116256
|
+
await tools3.writeToFile({ path: configPath, content: $stringify(finalConfig) });
|
|
116257
|
+
logger.info(`✅ Configuration saved to ${configPath}`);
|
|
116258
|
+
if (generatedConfig.scripts) {
|
|
116259
|
+
logger.info(`
|
|
114893
116260
|
\uD83D\uDCDD Generated scripts:`);
|
|
114894
|
-
|
|
114895
|
-
|
|
114896
|
-
|
|
114897
|
-
|
|
114898
|
-
|
|
114899
|
-
|
|
114900
|
-
|
|
114901
|
-
|
|
114902
|
-
|
|
114903
|
-
|
|
114904
|
-
|
|
116261
|
+
Object.entries(generatedConfig.scripts).forEach(([name18, scriptConfig]) => {
|
|
116262
|
+
if (typeof scriptConfig === "string") {
|
|
116263
|
+
logger.info(` - ${name18}: ${scriptConfig}`);
|
|
116264
|
+
} else if (typeof scriptConfig === "object" && scriptConfig !== null) {
|
|
116265
|
+
logger.info(` - ${name18}: ${scriptConfig.description || JSON.stringify(scriptConfig)}`);
|
|
116266
|
+
}
|
|
116267
|
+
});
|
|
116268
|
+
}
|
|
116269
|
+
if (generatedConfig.rules) {
|
|
116270
|
+
const rules = Array.isArray(generatedConfig.rules) ? generatedConfig.rules : [generatedConfig.rules];
|
|
116271
|
+
logger.info(`
|
|
114905
116272
|
\uD83D\uDCCB Identified project rules:`);
|
|
114906
|
-
|
|
114907
|
-
|
|
114908
|
-
|
|
114909
|
-
|
|
114910
|
-
|
|
114911
|
-
|
|
114912
|
-
|
|
116273
|
+
rules.forEach((rule) => {
|
|
116274
|
+
if (typeof rule === "string") {
|
|
116275
|
+
logger.info(` - ${rule}`);
|
|
116276
|
+
}
|
|
116277
|
+
});
|
|
116278
|
+
}
|
|
116279
|
+
});
|
|
116280
|
+
}
|
|
114913
116281
|
if (generateScript && scriptName && scriptInstructions) {
|
|
114914
116282
|
const scriptResult = await step("generate-script", async () => {
|
|
114915
116283
|
logger.info(`
|
|
@@ -114985,7 +116353,7 @@ async function createSkill(name18, logger, interactive) {
|
|
|
114985
116353
|
throw new Error(`Skill name '${name18}' conflicts with a built-in command. ` + `Please choose a different name (e.g., '${name18}-skill' or 'my-${name18}')`);
|
|
114986
116354
|
}
|
|
114987
116355
|
const skillDir = join14(".claude", "skills", name18);
|
|
114988
|
-
if (
|
|
116356
|
+
if (existsSync4(skillDir)) {
|
|
114989
116357
|
if (interactive) {
|
|
114990
116358
|
const proceed = await dist_default4({
|
|
114991
116359
|
message: `Skill '${name18}' already exists. Overwrite?`,
|
|
@@ -115074,7 +116442,7 @@ async function createScript(name18, logger, interactive, isGlobal = false) {
|
|
|
115074
116442
|
const scriptDir = ".polka-scripts";
|
|
115075
116443
|
const scriptPathConfig = `${scriptDir}/${name18}.ts`;
|
|
115076
116444
|
const scriptPathActual = join14(scriptDir, `${name18}.ts`);
|
|
115077
|
-
if (
|
|
116445
|
+
if (existsSync4(scriptPathActual)) {
|
|
115078
116446
|
if (interactive) {
|
|
115079
116447
|
const proceed = await dist_default4({
|
|
115080
116448
|
message: `Script '${scriptPathActual}' already exists. Overwrite?`,
|
|
@@ -115088,7 +116456,7 @@ async function createScript(name18, logger, interactive, isGlobal = false) {
|
|
|
115088
116456
|
throw new Error(`Script already exists: ${scriptPathActual}`);
|
|
115089
116457
|
}
|
|
115090
116458
|
}
|
|
115091
|
-
if (!
|
|
116459
|
+
if (!existsSync4(scriptDir)) {
|
|
115092
116460
|
mkdirSync(scriptDir, { recursive: true });
|
|
115093
116461
|
logger.info(`Created directory: ${scriptDir}`);
|
|
115094
116462
|
}
|
|
@@ -115115,7 +116483,7 @@ if (import.meta.main) {
|
|
|
115115
116483
|
writeFileSync(scriptPathActual, template);
|
|
115116
116484
|
logger.info(`Created script: ${scriptPathActual}`);
|
|
115117
116485
|
const configPath = isGlobal ? getGlobalConfigPath() : localConfigFileName;
|
|
115118
|
-
if (
|
|
116486
|
+
if (existsSync4(configPath)) {
|
|
115119
116487
|
try {
|
|
115120
116488
|
const config4 = readConfig(configPath);
|
|
115121
116489
|
if (!config4.scripts) {
|
|
@@ -115238,7 +116606,7 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
115238
116606
|
}
|
|
115239
116607
|
const scriptDir = ".polka-scripts";
|
|
115240
116608
|
const scriptPath = join14(scriptDir, `${name18}.ts`);
|
|
115241
|
-
if (
|
|
116609
|
+
if (existsSync4(scriptPath)) {
|
|
115242
116610
|
if (interactive) {
|
|
115243
116611
|
const proceed = await dist_default4({
|
|
115244
116612
|
message: `Script '${scriptPath}' already exists. Overwrite?`,
|
|
@@ -115292,7 +116660,7 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
115292
116660
|
const globalConfigPath = getGlobalConfigPath();
|
|
115293
116661
|
let isGlobal = options.global ?? false;
|
|
115294
116662
|
let configPath = isGlobal ? globalConfigPath : localConfigFileName;
|
|
115295
|
-
const exists =
|
|
116663
|
+
const exists = existsSync4(configPath);
|
|
115296
116664
|
if (exists) {
|
|
115297
116665
|
if (interactive) {
|
|
115298
116666
|
const proceed = await dist_default4({
|
|
@@ -115354,7 +116722,7 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
115354
116722
|
}
|
|
115355
116723
|
case "env": {
|
|
115356
116724
|
let envFileContent = "";
|
|
115357
|
-
const envExists =
|
|
116725
|
+
const envExists = existsSync4(".env");
|
|
115358
116726
|
if (envExists) {
|
|
115359
116727
|
envFileContent = readFileSync2(".env", "utf-8");
|
|
115360
116728
|
if (!envFileContent.endsWith(`
|
|
@@ -116045,7 +117413,7 @@ class McpServer {
|
|
|
116045
117413
|
let task2 = createTaskResult.task;
|
|
116046
117414
|
const pollInterval = task2.pollInterval ?? 5000;
|
|
116047
117415
|
while (task2.status !== "completed" && task2.status !== "failed" && task2.status !== "cancelled") {
|
|
116048
|
-
await new Promise((
|
|
117416
|
+
await new Promise((resolve6) => setTimeout(resolve6, pollInterval));
|
|
116049
117417
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
116050
117418
|
if (!updatedTask) {
|
|
116051
117419
|
throw new McpError2(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -116627,12 +117995,12 @@ class StdioServerTransport {
|
|
|
116627
117995
|
this.onclose?.();
|
|
116628
117996
|
}
|
|
116629
117997
|
send(message) {
|
|
116630
|
-
return new Promise((
|
|
117998
|
+
return new Promise((resolve6) => {
|
|
116631
117999
|
const json2 = serializeMessage(message);
|
|
116632
118000
|
if (this._stdout.write(json2)) {
|
|
116633
|
-
|
|
118001
|
+
resolve6();
|
|
116634
118002
|
} else {
|
|
116635
|
-
this._stdout.once("drain",
|
|
118003
|
+
this._stdout.once("drain", resolve6);
|
|
116636
118004
|
}
|
|
116637
118005
|
});
|
|
116638
118006
|
}
|
|
@@ -117049,6 +118417,322 @@ var mcpServerCommand = new Command("mcp-server").description("Start polka-codes
|
|
|
117049
118417
|
process.on("SIGTERM", shutdown);
|
|
117050
118418
|
});
|
|
117051
118419
|
|
|
118420
|
+
// src/commands/memory.ts
|
|
118421
|
+
init_src3();
|
|
118422
|
+
init_src();
|
|
118423
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
118424
|
+
import { mkdir as mkdir8, readFile as readFile12, writeFile as writeFile7 } from "node:fs/promises";
|
|
118425
|
+
import { dirname as dirname7, join as join15, resolve as resolve7, sep as sep2 } from "node:path";
|
|
118426
|
+
async function getMemoryStore() {
|
|
118427
|
+
const globalConfigPath = getGlobalConfigPath();
|
|
118428
|
+
const config4 = await loadConfigAtPath(globalConfigPath);
|
|
118429
|
+
const memoryConfig = config4?.memory || { enabled: true, type: "sqlite", path: "~/.config/polka-codes/memory.sqlite" };
|
|
118430
|
+
if (!memoryConfig.enabled || memoryConfig.type === "memory") {
|
|
118431
|
+
console.error("Memory store is not enabled. Enable it in config with memory.enabled: true");
|
|
118432
|
+
process.exit(1);
|
|
118433
|
+
}
|
|
118434
|
+
const cwd = process.cwd();
|
|
118435
|
+
const scope = detectProjectScope(cwd);
|
|
118436
|
+
const sqliteStore = new SQLiteMemoryStore(memoryConfig, scope);
|
|
118437
|
+
return new MemoryManager(sqliteStore, cwd);
|
|
118438
|
+
}
|
|
118439
|
+
function detectProjectScope(cwd) {
|
|
118440
|
+
const projectPath = findProjectRoot(cwd);
|
|
118441
|
+
if (!projectPath) {
|
|
118442
|
+
return "global";
|
|
118443
|
+
}
|
|
118444
|
+
const normalizedPath = normalizePath(projectPath);
|
|
118445
|
+
return `project:${normalizedPath}`;
|
|
118446
|
+
function findProjectRoot(dir) {
|
|
118447
|
+
let currentDir = resolve7(dir);
|
|
118448
|
+
while (currentDir !== "/") {
|
|
118449
|
+
const configPath = join15(currentDir, ".polkacodes.yml");
|
|
118450
|
+
if (existsSync5(configPath)) {
|
|
118451
|
+
return currentDir;
|
|
118452
|
+
}
|
|
118453
|
+
const parentDir = dirname7(currentDir);
|
|
118454
|
+
if (parentDir === currentDir)
|
|
118455
|
+
break;
|
|
118456
|
+
currentDir = parentDir;
|
|
118457
|
+
if (currentDir.split(sep2).length < 3)
|
|
118458
|
+
break;
|
|
118459
|
+
}
|
|
118460
|
+
return null;
|
|
118461
|
+
}
|
|
118462
|
+
function normalizePath(path12) {
|
|
118463
|
+
const normalized = resolve7(path12).replace(/\/$/, "");
|
|
118464
|
+
if (normalized.includes("..")) {
|
|
118465
|
+
throw new Error(`Path contains parent directory references: ${path12}`);
|
|
118466
|
+
}
|
|
118467
|
+
return normalized;
|
|
118468
|
+
}
|
|
118469
|
+
}
|
|
118470
|
+
async function memoryList(options) {
|
|
118471
|
+
const store = await getMemoryStore();
|
|
118472
|
+
try {
|
|
118473
|
+
const query = {
|
|
118474
|
+
scope: "auto"
|
|
118475
|
+
};
|
|
118476
|
+
if (options.type)
|
|
118477
|
+
query.type = options.type;
|
|
118478
|
+
if (options.status)
|
|
118479
|
+
query.status = options.status;
|
|
118480
|
+
if (options.priority)
|
|
118481
|
+
query.priority = options.priority;
|
|
118482
|
+
if (options.tags)
|
|
118483
|
+
query.tags = options.tags.split(",");
|
|
118484
|
+
if (options.search)
|
|
118485
|
+
query.search = options.search;
|
|
118486
|
+
if (options.limit)
|
|
118487
|
+
query.limit = options.limit;
|
|
118488
|
+
if (options.offset)
|
|
118489
|
+
query.offset = options.offset;
|
|
118490
|
+
if (options.sortBy)
|
|
118491
|
+
query.sortBy = options.sortBy;
|
|
118492
|
+
if (options.sortOrder)
|
|
118493
|
+
query.sortOrder = options.sortOrder;
|
|
118494
|
+
const entries = await store.queryMemory(query, { operation: "select" });
|
|
118495
|
+
if (options.format === "json") {
|
|
118496
|
+
console.log(JSON.stringify(entries, null, 2));
|
|
118497
|
+
} else {
|
|
118498
|
+
if (!Array.isArray(entries) || entries.length === 0) {
|
|
118499
|
+
console.log("No entries found.");
|
|
118500
|
+
return;
|
|
118501
|
+
}
|
|
118502
|
+
console.log(`
|
|
118503
|
+
Memory Entries:`);
|
|
118504
|
+
console.log("─".repeat(80));
|
|
118505
|
+
for (const entry of entries) {
|
|
118506
|
+
console.log(`
|
|
118507
|
+
Name: ${entry.name}`);
|
|
118508
|
+
console.log(`Type: ${entry.entry_type}`);
|
|
118509
|
+
console.log(`Status: ${entry.status || "N/A"}`);
|
|
118510
|
+
console.log(`Priority: ${entry.priority || "N/A"}`);
|
|
118511
|
+
console.log(`Tags: ${entry.tags || "N/A"}`);
|
|
118512
|
+
console.log(`Updated: ${new Date(entry.updated_at).toLocaleString()}`);
|
|
118513
|
+
console.log(`Content:
|
|
118514
|
+
${entry.content}`);
|
|
118515
|
+
console.log("─".repeat(80));
|
|
118516
|
+
}
|
|
118517
|
+
console.log(`
|
|
118518
|
+
Total: ${entries.length} entries`);
|
|
118519
|
+
}
|
|
118520
|
+
} finally {
|
|
118521
|
+
store.close();
|
|
118522
|
+
}
|
|
118523
|
+
}
|
|
118524
|
+
async function memoryRead(name18, options) {
|
|
118525
|
+
const store = await getMemoryStore();
|
|
118526
|
+
try {
|
|
118527
|
+
const content = await store.readMemory(name18);
|
|
118528
|
+
if (!content) {
|
|
118529
|
+
console.error(`Memory entry "${name18}" not found.`);
|
|
118530
|
+
process.exit(1);
|
|
118531
|
+
}
|
|
118532
|
+
if (options.format === "json") {
|
|
118533
|
+
console.log(JSON.stringify({ name: name18, content }, null, 2));
|
|
118534
|
+
} else {
|
|
118535
|
+
console.log(content);
|
|
118536
|
+
}
|
|
118537
|
+
} finally {
|
|
118538
|
+
store.close();
|
|
118539
|
+
}
|
|
118540
|
+
}
|
|
118541
|
+
async function memoryDelete(name18, options) {
|
|
118542
|
+
if (!options.force) {
|
|
118543
|
+
console.log(`Are you sure you want to delete memory entry "${name18}"?`);
|
|
118544
|
+
console.log("This action cannot be undone.");
|
|
118545
|
+
console.log("Use --force to skip this confirmation.");
|
|
118546
|
+
process.exit(1);
|
|
118547
|
+
}
|
|
118548
|
+
const store = await getMemoryStore();
|
|
118549
|
+
try {
|
|
118550
|
+
await store.updateMemory("remove", name18, undefined);
|
|
118551
|
+
console.log(`Memory entry "${name18}" deleted.`);
|
|
118552
|
+
} finally {
|
|
118553
|
+
store.close();
|
|
118554
|
+
}
|
|
118555
|
+
}
|
|
118556
|
+
async function memoryRename(oldName, newName) {
|
|
118557
|
+
const store = await getMemoryStore();
|
|
118558
|
+
try {
|
|
118559
|
+
const oldEntries = await store.queryMemory({ search: oldName }, { operation: "select" });
|
|
118560
|
+
if (!Array.isArray(oldEntries) || oldEntries.length === 0) {
|
|
118561
|
+
console.error(`Memory entry "${oldName}" not found.`);
|
|
118562
|
+
process.exit(1);
|
|
118563
|
+
}
|
|
118564
|
+
const oldEntry = oldEntries[0];
|
|
118565
|
+
const newEntries = await store.queryMemory({ search: newName }, { operation: "select" });
|
|
118566
|
+
if (Array.isArray(newEntries) && newEntries.length > 0) {
|
|
118567
|
+
console.error(`Memory entry "${newName}" already exists.`);
|
|
118568
|
+
process.exit(1);
|
|
118569
|
+
}
|
|
118570
|
+
await store.batchUpdateMemory([
|
|
118571
|
+
{
|
|
118572
|
+
operation: "replace",
|
|
118573
|
+
name: newName,
|
|
118574
|
+
content: oldEntry.content,
|
|
118575
|
+
metadata: {
|
|
118576
|
+
entry_type: oldEntry.entry_type,
|
|
118577
|
+
status: oldEntry.status,
|
|
118578
|
+
priority: oldEntry.priority,
|
|
118579
|
+
tags: oldEntry.tags
|
|
118580
|
+
}
|
|
118581
|
+
},
|
|
118582
|
+
{ operation: "remove", name: oldName }
|
|
118583
|
+
]);
|
|
118584
|
+
console.log(`Memory entry renamed from "${oldName}" to "${newName}".`);
|
|
118585
|
+
} finally {
|
|
118586
|
+
store.close();
|
|
118587
|
+
}
|
|
118588
|
+
}
|
|
118589
|
+
async function memoryExport(options) {
|
|
118590
|
+
const store = await getMemoryStore();
|
|
118591
|
+
try {
|
|
118592
|
+
const query = {};
|
|
118593
|
+
if (options.type)
|
|
118594
|
+
query.type = options.type;
|
|
118595
|
+
if (options.scope === "global") {
|
|
118596
|
+
query.scope = "global";
|
|
118597
|
+
} else if (options.scope === "project") {
|
|
118598
|
+
query.scope = "project";
|
|
118599
|
+
} else {
|
|
118600
|
+
query.scope = "auto";
|
|
118601
|
+
}
|
|
118602
|
+
const entries = await store.queryMemory(query, { operation: "select" });
|
|
118603
|
+
if (!Array.isArray(entries)) {
|
|
118604
|
+
console.error("Failed to export: query did not return entries");
|
|
118605
|
+
return;
|
|
118606
|
+
}
|
|
118607
|
+
const outputPath = options.output ? resolve7(process.cwd(), options.output) : resolve7(process.cwd(), `memory-export-${Date.now()}.json`);
|
|
118608
|
+
await mkdir8(dirname7(outputPath), { recursive: true });
|
|
118609
|
+
await writeFile7(outputPath, JSON.stringify(entries, null, 2));
|
|
118610
|
+
console.log(`Exported ${entries.length} entries to ${outputPath}`);
|
|
118611
|
+
} finally {
|
|
118612
|
+
store.close();
|
|
118613
|
+
}
|
|
118614
|
+
}
|
|
118615
|
+
async function memoryImport(inputFile, options) {
|
|
118616
|
+
const store = await getMemoryStore();
|
|
118617
|
+
try {
|
|
118618
|
+
const inputPath = resolve7(process.cwd(), inputFile);
|
|
118619
|
+
const data = await readFile12(inputPath, "utf-8");
|
|
118620
|
+
let entries;
|
|
118621
|
+
try {
|
|
118622
|
+
entries = JSON.parse(data);
|
|
118623
|
+
} catch (error48) {
|
|
118624
|
+
console.error(`Failed to parse JSON from ${inputPath}:`, error48);
|
|
118625
|
+
process.exit(1);
|
|
118626
|
+
}
|
|
118627
|
+
if (!Array.isArray(entries)) {
|
|
118628
|
+
console.error("Invalid import file format. Expected an array of memory entries.");
|
|
118629
|
+
process.exit(1);
|
|
118630
|
+
}
|
|
118631
|
+
let imported = 0;
|
|
118632
|
+
let skipped = 0;
|
|
118633
|
+
for (const entry of entries) {
|
|
118634
|
+
let entryName;
|
|
118635
|
+
try {
|
|
118636
|
+
if (typeof entry !== "object" || entry === null) {
|
|
118637
|
+
console.error("Skipping invalid entry: not an object");
|
|
118638
|
+
skipped++;
|
|
118639
|
+
continue;
|
|
118640
|
+
}
|
|
118641
|
+
const entryObj = entry;
|
|
118642
|
+
if (!entryObj.name || typeof entryObj.name !== "string") {
|
|
118643
|
+
console.error("Skipping invalid entry: missing or invalid name");
|
|
118644
|
+
skipped++;
|
|
118645
|
+
continue;
|
|
118646
|
+
}
|
|
118647
|
+
entryName = entryObj.name;
|
|
118648
|
+
if (!entryObj.content || typeof entryObj.content !== "string") {
|
|
118649
|
+
console.error(`Skipping entry "${entryName}": missing or invalid content`);
|
|
118650
|
+
skipped++;
|
|
118651
|
+
continue;
|
|
118652
|
+
}
|
|
118653
|
+
const validPriorities = ["low", "medium", "high", "critical"];
|
|
118654
|
+
let priority = entryObj.priority;
|
|
118655
|
+
if (priority && !validPriorities.includes(priority)) {
|
|
118656
|
+
console.warn(`Entry "${entryName}" has invalid priority "${priority}", defaulting to null`);
|
|
118657
|
+
priority = undefined;
|
|
118658
|
+
}
|
|
118659
|
+
const existing = await store.readMemory(entryName);
|
|
118660
|
+
if (existing && !options.merge) {
|
|
118661
|
+
skipped++;
|
|
118662
|
+
continue;
|
|
118663
|
+
}
|
|
118664
|
+
const entryType = entryObj.entry_type;
|
|
118665
|
+
const validatedEntryType = typeof entryType === "string" ? entryType : "note";
|
|
118666
|
+
const status = entryObj.status;
|
|
118667
|
+
const validatedStatus = typeof status === "string" ? status : undefined;
|
|
118668
|
+
const tags = entryObj.tags;
|
|
118669
|
+
const validatedTags = typeof tags === "string" ? tags : undefined;
|
|
118670
|
+
await store.updateMemory("replace", entryName, entryObj.content, {
|
|
118671
|
+
entry_type: validatedEntryType,
|
|
118672
|
+
status: validatedStatus,
|
|
118673
|
+
priority,
|
|
118674
|
+
tags: validatedTags
|
|
118675
|
+
});
|
|
118676
|
+
imported++;
|
|
118677
|
+
} catch (error48) {
|
|
118678
|
+
console.error(`Failed to import entry "${entryName || "unknown"}":`, error48);
|
|
118679
|
+
skipped++;
|
|
118680
|
+
}
|
|
118681
|
+
}
|
|
118682
|
+
console.log(`Imported ${imported} entries, skipped ${skipped} entries.`);
|
|
118683
|
+
} finally {
|
|
118684
|
+
store.close();
|
|
118685
|
+
}
|
|
118686
|
+
}
|
|
118687
|
+
async function memoryStatus() {
|
|
118688
|
+
const store = await getMemoryStore();
|
|
118689
|
+
try {
|
|
118690
|
+
const stats = await store.getStats();
|
|
118691
|
+
const globalConfigPath = getGlobalConfigPath();
|
|
118692
|
+
const config4 = await loadConfigAtPath(globalConfigPath);
|
|
118693
|
+
const memoryConfig = config4?.memory || { path: "~/.config/polka-codes/memory.sqlite" };
|
|
118694
|
+
const dbPath = resolveHomePath(memoryConfig.path || "~/.config/polka-codes/memory.sqlite");
|
|
118695
|
+
console.log(`
|
|
118696
|
+
Memory Store Status:`);
|
|
118697
|
+
console.log("─".repeat(80));
|
|
118698
|
+
console.log(`Database: ${dbPath}`);
|
|
118699
|
+
console.log(`Total entries: ${stats.totalEntries}`);
|
|
118700
|
+
console.log(`Database size: ${(stats.databaseSize / 1024).toFixed(2)} KB`);
|
|
118701
|
+
console.log(`
|
|
118702
|
+
Entries by type:`);
|
|
118703
|
+
for (const [type, count] of Object.entries(stats.entriesByType)) {
|
|
118704
|
+
console.log(` ${type}: ${count}`);
|
|
118705
|
+
}
|
|
118706
|
+
console.log("─".repeat(80));
|
|
118707
|
+
} finally {
|
|
118708
|
+
store.close();
|
|
118709
|
+
}
|
|
118710
|
+
}
|
|
118711
|
+
function registerMemoryCommands(program2) {
|
|
118712
|
+
const memoryCmd = program2.command("memory").description("Memory management commands");
|
|
118713
|
+
memoryCmd.command("list").description("List memory entries").option("--type <type>", "Filter by type").option("--status <status>", "Filter by status").option("--priority <priority>", "Filter by priority").option("--tags <tags>", "Filter by tags (comma-separated)").option("--search <term>", "Search in content and name").option("--limit <number>", "Limit results", parseInt).option("--offset <number>", "Offset results", parseInt).option("--sort-by <field>", "Sort by field (created, updated, accessed, name)").option("--sort-order <order>", "Sort order (asc, desc)", "desc").option("--format <format>", "Output format (json, table)", "table").action(async (options) => {
|
|
118714
|
+
await memoryList(options);
|
|
118715
|
+
});
|
|
118716
|
+
memoryCmd.command("read <name>").description("Read a specific memory entry").option("--format <format>", "Output format (json, text)", "text").action(async (name18, options) => {
|
|
118717
|
+
await memoryRead(name18, options);
|
|
118718
|
+
});
|
|
118719
|
+
memoryCmd.command("delete <name>").description("Delete a memory entry").option("--force", "Skip confirmation").action(async (name18, options) => {
|
|
118720
|
+
await memoryDelete(name18, options);
|
|
118721
|
+
});
|
|
118722
|
+
memoryCmd.command("rename <oldName> <newName>").description("Rename a memory entry").action(async (oldName, newName) => {
|
|
118723
|
+
await memoryRename(oldName, newName);
|
|
118724
|
+
});
|
|
118725
|
+
memoryCmd.command("export").description("Export memory to JSON").option("--output <file>", "Output file path").option("--type <type>", "Filter by type").option("--scope <scope>", "Filter by scope (global, project)").action(async (options) => {
|
|
118726
|
+
await memoryExport(options);
|
|
118727
|
+
});
|
|
118728
|
+
memoryCmd.command("import <file>").description("Import memory from JSON").option("--merge", "Merge with existing data (skip conflicts)").action(async (file2, options) => {
|
|
118729
|
+
await memoryImport(file2, options);
|
|
118730
|
+
});
|
|
118731
|
+
memoryCmd.command("status").description("Show memory statistics").action(async () => {
|
|
118732
|
+
await memoryStatus();
|
|
118733
|
+
});
|
|
118734
|
+
}
|
|
118735
|
+
|
|
117052
118736
|
// src/commands/meta.ts
|
|
117053
118737
|
init_src3();
|
|
117054
118738
|
import { execSync as execSync2 } from "node:child_process";
|
|
@@ -117057,8 +118741,8 @@ import { execSync as execSync2 } from "node:child_process";
|
|
|
117057
118741
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
117058
118742
|
|
|
117059
118743
|
// src/script/runner.ts
|
|
117060
|
-
import { existsSync as
|
|
117061
|
-
import { relative as relative3, resolve as
|
|
118744
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
118745
|
+
import { relative as relative3, resolve as resolve8 } from "node:path";
|
|
117062
118746
|
import { pathToFileURL } from "node:url";
|
|
117063
118747
|
|
|
117064
118748
|
class ScriptValidationError extends Error {
|
|
@@ -117085,13 +118769,13 @@ class ScriptExecutionError extends Error {
|
|
|
117085
118769
|
}
|
|
117086
118770
|
}
|
|
117087
118771
|
function validateScriptPath(scriptPath, projectRoot2 = process.cwd()) {
|
|
117088
|
-
const normalizedRoot =
|
|
117089
|
-
const normalizedScript =
|
|
118772
|
+
const normalizedRoot = resolve8(projectRoot2);
|
|
118773
|
+
const normalizedScript = resolve8(projectRoot2, scriptPath);
|
|
117090
118774
|
const relativePath = relative3(normalizedRoot, normalizedScript);
|
|
117091
118775
|
if (relativePath.startsWith("..")) {
|
|
117092
118776
|
throw new ScriptValidationError(`Script path '${scriptPath}' is outside project directory`);
|
|
117093
118777
|
}
|
|
117094
|
-
if (!
|
|
118778
|
+
if (!existsSync6(normalizedScript)) {
|
|
117095
118779
|
throw new ScriptValidationError(`Script file not found: ${scriptPath}`);
|
|
117096
118780
|
}
|
|
117097
118781
|
const validExtensions = [".ts", ".js", ".mjs", ".cjs"];
|
|
@@ -117106,9 +118790,9 @@ function validateScriptPermissions(script, logger) {
|
|
|
117106
118790
|
}
|
|
117107
118791
|
if ("script" in script && script.permissions) {
|
|
117108
118792
|
logger?.warn("Script permissions are currently advisory only. Scripts run with full process permissions.");
|
|
117109
|
-
const { fs:
|
|
117110
|
-
if (
|
|
117111
|
-
throw new ScriptValidationError(`Invalid fs permission: ${
|
|
118793
|
+
const { fs: fs13, network, subprocess } = script.permissions;
|
|
118794
|
+
if (fs13 && !["read", "write", "none"].includes(fs13)) {
|
|
118795
|
+
throw new ScriptValidationError(`Invalid fs permission: ${fs13}. Must be 'read', 'write', or 'none'`);
|
|
117112
118796
|
}
|
|
117113
118797
|
if (typeof network !== "boolean" && network !== undefined) {
|
|
117114
118798
|
throw new ScriptValidationError(`Invalid network permission: must be true or false`);
|
|
@@ -117129,7 +118813,7 @@ class ScriptRunner {
|
|
|
117129
118813
|
try {
|
|
117130
118814
|
const returnValue = await this.withTimeout(timeout, async () => {
|
|
117131
118815
|
const projectRoot2 = context.projectRoot || process.cwd();
|
|
117132
|
-
const absolutePath =
|
|
118816
|
+
const absolutePath = resolve8(projectRoot2, scriptPath);
|
|
117133
118817
|
const cacheBustUrl = `${pathToFileURL(absolutePath).href}?t=${Date.now()}`;
|
|
117134
118818
|
const scriptModule = await import(cacheBustUrl);
|
|
117135
118819
|
if (typeof scriptModule.main !== "function") {
|
|
@@ -117418,7 +119102,7 @@ var prCommand = new Command("pr").description("Create a GitHub pull request").ar
|
|
|
117418
119102
|
|
|
117419
119103
|
// src/commands/review.ts
|
|
117420
119104
|
init_dist18();
|
|
117421
|
-
import { existsSync as
|
|
119105
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
117422
119106
|
init_workflow_utils();
|
|
117423
119107
|
var reviewCommand = new Command("review").description("Review a GitHub pull request or local changes").argument("[files...]", "Specific files to review (use --context for review instructions)").option("--pr <pr>", "The pull request number to review", (value) => {
|
|
117424
119108
|
const parsedValue = parseInt(value, 10);
|
|
@@ -117441,7 +119125,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
117441
119125
|
let changesAppliedInThisIteration = false;
|
|
117442
119126
|
let context = contextOption;
|
|
117443
119127
|
let filesToReview = files;
|
|
117444
|
-
if (files.length === 1 && !
|
|
119128
|
+
if (files.length === 1 && !existsSync7(files[0]) && files[0].includes(" ") && !context) {
|
|
117445
119129
|
if (!json2) {
|
|
117446
119130
|
console.warn("Warning: The argument looks like context but was passed as a file. Treating it as context. Please use --context for review instructions in the future.");
|
|
117447
119131
|
}
|
|
@@ -117480,7 +119164,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
117480
119164
|
if (yes) {
|
|
117481
119165
|
shouldRunTask = true;
|
|
117482
119166
|
} else if (process.stdin.isTTY && !json2) {
|
|
117483
|
-
await new Promise((
|
|
119167
|
+
await new Promise((resolve9) => setTimeout(resolve9, 50));
|
|
117484
119168
|
try {
|
|
117485
119169
|
const answer = await dist_default7({
|
|
117486
119170
|
message: "Do you wish polka-codes to address the review results?",
|
|
@@ -117866,6 +119550,7 @@ program2.addCommand(runCommand);
|
|
|
117866
119550
|
program2.addCommand(skillsCommand);
|
|
117867
119551
|
program2.addCommand(mcpServerCommand);
|
|
117868
119552
|
program2.addCommand(workflowCommand);
|
|
119553
|
+
registerMemoryCommands(program2);
|
|
117869
119554
|
addSharedOptions(program2);
|
|
117870
119555
|
if (__require.main == __require.module) {
|
|
117871
119556
|
program2.parse();
|