codebuff 1.0.99
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/README.md +70 -0
- package/dist/chat-storage.d.ts +29 -0
- package/dist/chat-storage.js +125 -0
- package/dist/chat-storage.js.map +1 -0
- package/dist/cli.d.ts +37 -0
- package/dist/cli.js +416 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +41 -0
- package/dist/client.js +443 -0
- package/dist/client.js.map +1 -0
- package/dist/code-map/languages.d.ts +12 -0
- package/dist/code-map/languages.js +129 -0
- package/dist/code-map/languages.js.map +1 -0
- package/dist/code-map/parse.d.ts +11 -0
- package/dist/code-map/parse.js +127 -0
- package/dist/code-map/parse.js.map +1 -0
- package/dist/code-map/test-langs/test.d.ts +11 -0
- package/dist/code-map/test-langs/test.js +23 -0
- package/dist/code-map/test-langs/test.js.map +1 -0
- package/dist/code-map/tree-sitter-queries/readme.md +23 -0
- package/dist/code-map/tree-sitter-queries/tree-sitter-c-tags.scm +11 -0
- package/dist/code-map/tree-sitter-queries/tree-sitter-c_sharp-tags.scm +13 -0
- package/dist/code-map/tree-sitter-queries/tree-sitter-cpp-tags.scm +17 -0
- package/dist/code-map/tree-sitter-queries/tree-sitter-go-tags.scm +26 -0
- package/dist/code-map/tree-sitter-queries/tree-sitter-java-tags.scm +19 -0
- package/dist/code-map/tree-sitter-queries/tree-sitter-javascript-tags.scm +15 -0
- package/dist/code-map/tree-sitter-queries/tree-sitter-php-tags.scm +26 -0
- package/dist/code-map/tree-sitter-queries/tree-sitter-python-tags.scm +9 -0
- package/dist/code-map/tree-sitter-queries/tree-sitter-ruby-tags.scm +58 -0
- package/dist/code-map/tree-sitter-queries/tree-sitter-rust-tags.scm +26 -0
- package/dist/code-map/tree-sitter-queries/tree-sitter-typescript-tags.scm +15 -0
- package/dist/code-map/tsconfig.tsbuildinfo +1 -0
- package/dist/common/actions.d.ts +1062 -0
- package/dist/common/actions.js +180 -0
- package/dist/common/actions.js.map +1 -0
- package/dist/common/billing/quota-manager.d.ts +59 -0
- package/dist/common/billing/quota-manager.js +200 -0
- package/dist/common/billing/quota-manager.js.map +1 -0
- package/dist/common/constants.d.ts +24 -0
- package/dist/common/constants.js +73 -0
- package/dist/common/constants.js.map +1 -0
- package/dist/common/db/drizzle.config.d.ts +2 -0
- package/dist/common/db/drizzle.config.js +17 -0
- package/dist/common/db/drizzle.config.js.map +1 -0
- package/dist/common/db/env.d.mts +1 -0
- package/dist/common/db/env.mjs +26 -0
- package/dist/common/db/env.mjs.map +1 -0
- package/dist/common/db/index.d.ts +6 -0
- package/dist/common/db/index.js +35 -0
- package/dist/common/db/index.js.map +1 -0
- package/dist/common/db/schema.d.ts +994 -0
- package/dist/common/db/schema.js +113 -0
- package/dist/common/db/schema.js.map +1 -0
- package/dist/common/env.d.mts +1 -0
- package/dist/common/env.mjs +34 -0
- package/dist/common/env.mjs.map +1 -0
- package/dist/common/project-file-tree.d.ts +9 -0
- package/dist/common/project-file-tree.js +157 -0
- package/dist/common/project-file-tree.js.map +1 -0
- package/dist/common/types/referral.d.ts +2 -0
- package/dist/common/types/referral.js +5 -0
- package/dist/common/types/referral.js.map +1 -0
- package/dist/common/types/usage.d.ts +21 -0
- package/dist/common/types/usage.js +12 -0
- package/dist/common/types/usage.js.map +1 -0
- package/dist/common/util/__tests__/string.test.d.ts +1 -0
- package/dist/common/util/__tests__/string.test.js +83 -0
- package/dist/common/util/__tests__/string.test.js.map +1 -0
- package/dist/common/util/array.d.ts +6 -0
- package/dist/common/util/array.js +32 -0
- package/dist/common/util/array.js.map +1 -0
- package/dist/common/util/changes.d.ts +6 -0
- package/dist/common/util/changes.js +72 -0
- package/dist/common/util/changes.js.map +1 -0
- package/dist/common/util/credentials.d.ts +25 -0
- package/dist/common/util/credentials.js +24 -0
- package/dist/common/util/credentials.js.map +1 -0
- package/dist/common/util/dates.d.ts +1 -0
- package/dist/common/util/dates.js +13 -0
- package/dist/common/util/dates.js.map +1 -0
- package/dist/common/util/file.d.ts +106 -0
- package/dist/common/util/file.js +138 -0
- package/dist/common/util/file.js.map +1 -0
- package/dist/common/util/git.d.ts +4 -0
- package/dist/common/util/git.js +40 -0
- package/dist/common/util/git.js.map +1 -0
- package/dist/common/util/helpers.d.ts +1 -0
- package/dist/common/util/helpers.js +6 -0
- package/dist/common/util/helpers.js.map +1 -0
- package/dist/common/util/object.d.ts +18 -0
- package/dist/common/util/object.js +91 -0
- package/dist/common/util/object.js.map +1 -0
- package/dist/common/util/patch.d.ts +1 -0
- package/dist/common/util/patch.js +215 -0
- package/dist/common/util/patch.js.map +1 -0
- package/dist/common/util/promise.d.ts +1 -0
- package/dist/common/util/promise.js +33 -0
- package/dist/common/util/promise.js.map +1 -0
- package/dist/common/util/referral.d.ts +1 -0
- package/dist/common/util/referral.js +6 -0
- package/dist/common/util/referral.js.map +1 -0
- package/dist/common/util/server/referral.d.ts +14 -0
- package/dist/common/util/server/referral.js +85 -0
- package/dist/common/util/server/referral.js.map +1 -0
- package/dist/common/util/string.d.ts +3 -0
- package/dist/common/util/string.js +60 -0
- package/dist/common/util/string.js.map +1 -0
- package/dist/common/util/stripe.d.ts +2 -0
- package/dist/common/util/stripe.js +19 -0
- package/dist/common/util/stripe.js.map +1 -0
- package/dist/common/util/tools.d.ts +2 -0
- package/dist/common/util/tools.js +13 -0
- package/dist/common/util/tools.js.map +1 -0
- package/dist/common/websockets/websocket-client.d.ts +40 -0
- package/dist/common/websockets/websocket-client.js +187 -0
- package/dist/common/websockets/websocket-client.js.map +1 -0
- package/dist/common/websockets/websocket-schema.d.ts +2530 -0
- package/dist/common/websockets/websocket-schema.js +55 -0
- package/dist/common/websockets/websocket-schema.js.map +1 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +8 -0
- package/dist/config.js.map +1 -0
- package/dist/credentials.d.ts +3 -0
- package/dist/credentials.js +33 -0
- package/dist/credentials.js.map +1 -0
- package/dist/fingerprint.d.ts +1 -0
- package/dist/fingerprint.js +43 -0
- package/dist/fingerprint.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/dist/manifold-api.d.ts +8 -0
- package/dist/manifold-api.js +32 -0
- package/dist/manifold-api.js.map +1 -0
- package/dist/menu.d.ts +1 -0
- package/dist/menu.js +92 -0
- package/dist/menu.js.map +1 -0
- package/dist/project-files.d.ts +48 -0
- package/dist/project-files.js +324 -0
- package/dist/project-files.js.map +1 -0
- package/dist/tool-handlers.d.ts +11 -0
- package/dist/tool-handlers.js +131 -0
- package/dist/tool-handlers.js.map +1 -0
- package/dist/update-manicode.d.ts +1 -0
- package/dist/update-manicode.js +151 -0
- package/dist/update-manicode.js.map +1 -0
- package/dist/web-scraper.d.ts +3 -0
- package/dist/web-scraper.js +79 -0
- package/dist/web-scraper.js.map +1 -0
- package/dist/worker-script-project-context.d.ts +1 -0
- package/dist/worker-script-project-context.js +13 -0
- package/dist/worker-script-project-context.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const userSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
email: z.ZodString;
|
|
5
|
+
name: z.ZodNullable<z.ZodString>;
|
|
6
|
+
authToken: z.ZodString;
|
|
7
|
+
fingerprintId: z.ZodString;
|
|
8
|
+
fingerprintHash: z.ZodString;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
email: string;
|
|
11
|
+
name: string | null;
|
|
12
|
+
id: string;
|
|
13
|
+
authToken: string;
|
|
14
|
+
fingerprintId: string;
|
|
15
|
+
fingerprintHash: string;
|
|
16
|
+
}, {
|
|
17
|
+
email: string;
|
|
18
|
+
name: string | null;
|
|
19
|
+
id: string;
|
|
20
|
+
authToken: string;
|
|
21
|
+
fingerprintId: string;
|
|
22
|
+
fingerprintHash: string;
|
|
23
|
+
}>;
|
|
24
|
+
export type User = z.infer<typeof userSchema>;
|
|
25
|
+
export declare const genAuthCode: (fingerprintId: string, expiresAt: string, secret: string) => string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.genAuthCode = exports.userSchema = void 0;
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
9
|
+
exports.userSchema = zod_1.z.object({
|
|
10
|
+
id: zod_1.z.string(),
|
|
11
|
+
email: zod_1.z.string(),
|
|
12
|
+
name: zod_1.z.string().nullable(),
|
|
13
|
+
authToken: zod_1.z.string(),
|
|
14
|
+
fingerprintId: zod_1.z.string(),
|
|
15
|
+
fingerprintHash: zod_1.z.string(),
|
|
16
|
+
});
|
|
17
|
+
const genAuthCode = (fingerprintId, expiresAt, secret) => node_crypto_1.default
|
|
18
|
+
.createHash('sha256')
|
|
19
|
+
.update(secret)
|
|
20
|
+
.update(fingerprintId)
|
|
21
|
+
.update(expiresAt)
|
|
22
|
+
.digest('hex');
|
|
23
|
+
exports.genAuthCode = genAuthCode;
|
|
24
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/util/credentials.ts"],"names":[],"mappings":";;;;;;AAAA,6BAAuB;AACvB,8DAAgC;AAEnB,QAAA,UAAU,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;IACd,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;IACrB,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE;IACzB,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE;CAC5B,CAAC,CAAA;AAIK,MAAM,WAAW,GAAG,CACzB,aAAqB,EACrB,SAAiB,EACjB,MAAc,EACd,EAAE,CACF,qBAAM;KACH,UAAU,CAAC,QAAQ,CAAC;KACpB,MAAM,CAAC,MAAM,CAAC;KACd,MAAM,CAAC,aAAa,CAAC;KACrB,MAAM,CAAC,SAAS,CAAC;KACjB,MAAM,CAAC,KAAK,CAAC,CAAA;AAVL,QAAA,WAAW,eAUN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getNextQuotaReset: (currentQuotaReset: Date | null) => Date;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNextQuotaReset = void 0;
|
|
4
|
+
const getNextQuotaReset = (currentQuotaReset) => {
|
|
5
|
+
const now = new Date();
|
|
6
|
+
let nextMonth = new Date(currentQuotaReset ?? now);
|
|
7
|
+
while (nextMonth <= now) {
|
|
8
|
+
nextMonth.setMonth(nextMonth.getMonth() + 1);
|
|
9
|
+
}
|
|
10
|
+
return nextMonth;
|
|
11
|
+
};
|
|
12
|
+
exports.getNextQuotaReset = getNextQuotaReset;
|
|
13
|
+
//# sourceMappingURL=dates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dates.js","sourceRoot":"","sources":["../../src/util/dates.ts"],"names":[],"mappings":";;;AAAO,MAAM,iBAAiB,GAAG,CAAC,iBAA8B,EAAQ,EAAE;IACxE,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IACtB,IAAI,SAAS,GAAG,IAAI,IAAI,CAAC,iBAAiB,IAAI,GAAG,CAAC,CAAA;IAClD,OAAO,SAAS,IAAI,GAAG,EAAE,CAAC;QACxB,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAA;IAC9C,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAPY,QAAA,iBAAiB,qBAO7B"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const FileTreeNodeSchema: z.ZodType<FileTreeNode>;
|
|
3
|
+
export interface FileTreeNode {
|
|
4
|
+
name: string;
|
|
5
|
+
type: 'file' | 'directory';
|
|
6
|
+
filePath: string;
|
|
7
|
+
lastReadTime?: number;
|
|
8
|
+
children?: FileTreeNode[];
|
|
9
|
+
}
|
|
10
|
+
export interface DirectoryNode extends FileTreeNode {
|
|
11
|
+
type: 'directory';
|
|
12
|
+
children: FileTreeNode[];
|
|
13
|
+
}
|
|
14
|
+
export interface FileNode extends FileTreeNode {
|
|
15
|
+
type: 'file';
|
|
16
|
+
lastReadTime: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const FileVersionSchema: z.ZodObject<{
|
|
19
|
+
path: z.ZodString;
|
|
20
|
+
content: z.ZodString;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
path: string;
|
|
23
|
+
content: string;
|
|
24
|
+
}, {
|
|
25
|
+
path: string;
|
|
26
|
+
content: string;
|
|
27
|
+
}>;
|
|
28
|
+
export type FileVersion = z.infer<typeof FileVersionSchema>;
|
|
29
|
+
export declare const ProjectFileContextSchema: z.ZodObject<{
|
|
30
|
+
currentWorkingDirectory: z.ZodString;
|
|
31
|
+
fileTree: z.ZodArray<z.ZodType<FileTreeNode, z.ZodTypeDef, FileTreeNode>, "many">;
|
|
32
|
+
fileTokenScores: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
33
|
+
knowledgeFiles: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
34
|
+
gitChanges: z.ZodObject<{
|
|
35
|
+
status: z.ZodString;
|
|
36
|
+
diff: z.ZodString;
|
|
37
|
+
diffCached: z.ZodString;
|
|
38
|
+
lastCommitMessages: z.ZodString;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
status: string;
|
|
41
|
+
diff: string;
|
|
42
|
+
diffCached: string;
|
|
43
|
+
lastCommitMessages: string;
|
|
44
|
+
}, {
|
|
45
|
+
status: string;
|
|
46
|
+
diff: string;
|
|
47
|
+
diffCached: string;
|
|
48
|
+
lastCommitMessages: string;
|
|
49
|
+
}>;
|
|
50
|
+
changesSinceLastChat: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
51
|
+
shellConfigFiles: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
52
|
+
fileVersions: z.ZodArray<z.ZodArray<z.ZodObject<{
|
|
53
|
+
path: z.ZodString;
|
|
54
|
+
content: z.ZodString;
|
|
55
|
+
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
path: string;
|
|
57
|
+
content: string;
|
|
58
|
+
}, {
|
|
59
|
+
path: string;
|
|
60
|
+
content: string;
|
|
61
|
+
}>, "many">, "many">;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
currentWorkingDirectory: string;
|
|
64
|
+
fileTree: FileTreeNode[];
|
|
65
|
+
fileTokenScores: Record<string, Record<string, number>>;
|
|
66
|
+
knowledgeFiles: Record<string, string>;
|
|
67
|
+
gitChanges: {
|
|
68
|
+
status: string;
|
|
69
|
+
diff: string;
|
|
70
|
+
diffCached: string;
|
|
71
|
+
lastCommitMessages: string;
|
|
72
|
+
};
|
|
73
|
+
changesSinceLastChat: Record<string, string>;
|
|
74
|
+
shellConfigFiles: Record<string, string>;
|
|
75
|
+
fileVersions: {
|
|
76
|
+
path: string;
|
|
77
|
+
content: string;
|
|
78
|
+
}[][];
|
|
79
|
+
}, {
|
|
80
|
+
currentWorkingDirectory: string;
|
|
81
|
+
fileTree: FileTreeNode[];
|
|
82
|
+
fileTokenScores: Record<string, Record<string, number>>;
|
|
83
|
+
knowledgeFiles: Record<string, string>;
|
|
84
|
+
gitChanges: {
|
|
85
|
+
status: string;
|
|
86
|
+
diff: string;
|
|
87
|
+
diffCached: string;
|
|
88
|
+
lastCommitMessages: string;
|
|
89
|
+
};
|
|
90
|
+
changesSinceLastChat: Record<string, string>;
|
|
91
|
+
shellConfigFiles: Record<string, string>;
|
|
92
|
+
fileVersions: {
|
|
93
|
+
path: string;
|
|
94
|
+
content: string;
|
|
95
|
+
}[][];
|
|
96
|
+
}>;
|
|
97
|
+
export type ProjectFileContext = z.infer<typeof ProjectFileContextSchema>;
|
|
98
|
+
export declare const createFileBlock: (filePath: string, content: string) => string;
|
|
99
|
+
export declare const createFileBlockWithoutPath: (content: string) => string;
|
|
100
|
+
export declare const fileRegex: RegExp;
|
|
101
|
+
export declare const fileWithNoPathRegex: RegExp;
|
|
102
|
+
export declare const parseFileBlocks: (fileBlocks: string) => Record<string, string>;
|
|
103
|
+
export declare const parseFileBlocksWithoutPath: (fileBlocks: string) => string[];
|
|
104
|
+
export declare function printFileTree(nodes: FileTreeNode[], depth?: number): string;
|
|
105
|
+
export declare function printFileTreeWithTokens(nodes: FileTreeNode[], fileTokenScores: Record<string, Record<string, number>>, path?: string[]): string;
|
|
106
|
+
export declare const ensureDirectoryExists: (baseDir: string) => void;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ensureDirectoryExists = exports.parseFileBlocksWithoutPath = exports.parseFileBlocks = exports.fileWithNoPathRegex = exports.fileRegex = exports.createFileBlockWithoutPath = exports.createFileBlock = exports.ProjectFileContextSchema = exports.FileVersionSchema = exports.FileTreeNodeSchema = void 0;
|
|
27
|
+
exports.printFileTree = printFileTree;
|
|
28
|
+
exports.printFileTreeWithTokens = printFileTreeWithTokens;
|
|
29
|
+
const fs = __importStar(require("fs"));
|
|
30
|
+
const zod_1 = require("zod");
|
|
31
|
+
exports.FileTreeNodeSchema = zod_1.z.object({
|
|
32
|
+
name: zod_1.z.string(),
|
|
33
|
+
type: zod_1.z.enum(['file', 'directory']),
|
|
34
|
+
children: zod_1.z.lazy(() => zod_1.z.array(exports.FileTreeNodeSchema).optional()),
|
|
35
|
+
filePath: zod_1.z.string(),
|
|
36
|
+
});
|
|
37
|
+
exports.FileVersionSchema = zod_1.z.object({
|
|
38
|
+
path: zod_1.z.string(),
|
|
39
|
+
content: zod_1.z.string(),
|
|
40
|
+
});
|
|
41
|
+
exports.ProjectFileContextSchema = zod_1.z.object({
|
|
42
|
+
currentWorkingDirectory: zod_1.z.string(),
|
|
43
|
+
fileTree: zod_1.z.array(zod_1.z.custom()),
|
|
44
|
+
fileTokenScores: zod_1.z.record(zod_1.z.string(), zod_1.z.record(zod_1.z.string(), zod_1.z.number())),
|
|
45
|
+
knowledgeFiles: zod_1.z.record(zod_1.z.string(), zod_1.z.string()),
|
|
46
|
+
gitChanges: zod_1.z.object({
|
|
47
|
+
status: zod_1.z.string(),
|
|
48
|
+
diff: zod_1.z.string(),
|
|
49
|
+
diffCached: zod_1.z.string(),
|
|
50
|
+
lastCommitMessages: zod_1.z.string(),
|
|
51
|
+
}),
|
|
52
|
+
changesSinceLastChat: zod_1.z.record(zod_1.z.string(), zod_1.z.string()),
|
|
53
|
+
shellConfigFiles: zod_1.z.record(zod_1.z.string(), zod_1.z.string()),
|
|
54
|
+
fileVersions: zod_1.z.array(zod_1.z.array(exports.FileVersionSchema)),
|
|
55
|
+
});
|
|
56
|
+
const createFileBlock = (filePath, content) => {
|
|
57
|
+
return ('<' +
|
|
58
|
+
`edit_file path="${filePath}">
|
|
59
|
+
${content}
|
|
60
|
+
</edit_file` +
|
|
61
|
+
'>');
|
|
62
|
+
};
|
|
63
|
+
exports.createFileBlock = createFileBlock;
|
|
64
|
+
const createFileBlockWithoutPath = (content) => {
|
|
65
|
+
return ('<' +
|
|
66
|
+
`edit_file>
|
|
67
|
+
${content}
|
|
68
|
+
</edit_file` +
|
|
69
|
+
'>');
|
|
70
|
+
};
|
|
71
|
+
exports.createFileBlockWithoutPath = createFileBlockWithoutPath;
|
|
72
|
+
exports.fileRegex = /<edit_file path="([^"]+)">([\s\S]*?)<\/edit_file>/g;
|
|
73
|
+
exports.fileWithNoPathRegex = /<edit_file>([\s\S]*?)<\/edit_file>/g;
|
|
74
|
+
const parseFileBlocks = (fileBlocks) => {
|
|
75
|
+
let fileMatch;
|
|
76
|
+
const files = {};
|
|
77
|
+
while ((fileMatch = exports.fileRegex.exec(fileBlocks)) !== null) {
|
|
78
|
+
const [, filePath, fileContent] = fileMatch;
|
|
79
|
+
files[filePath] = fileContent.startsWith('\n')
|
|
80
|
+
? fileContent.slice(1)
|
|
81
|
+
: fileContent;
|
|
82
|
+
}
|
|
83
|
+
return files;
|
|
84
|
+
};
|
|
85
|
+
exports.parseFileBlocks = parseFileBlocks;
|
|
86
|
+
const parseFileBlocksWithoutPath = (fileBlocks) => {
|
|
87
|
+
let fileMatch;
|
|
88
|
+
const files = [];
|
|
89
|
+
while ((fileMatch = exports.fileWithNoPathRegex.exec(fileBlocks)) !== null) {
|
|
90
|
+
const [, fileContent] = fileMatch;
|
|
91
|
+
files.push(fileContent.startsWith('\n') ? fileContent.slice(1) : fileContent);
|
|
92
|
+
}
|
|
93
|
+
return files;
|
|
94
|
+
};
|
|
95
|
+
exports.parseFileBlocksWithoutPath = parseFileBlocksWithoutPath;
|
|
96
|
+
function printFileTree(nodes, depth = 0) {
|
|
97
|
+
let result = '';
|
|
98
|
+
const indentation = ' '.repeat(depth);
|
|
99
|
+
for (const node of nodes) {
|
|
100
|
+
result += `${indentation}${node.name}${node.type === 'directory' ? '/' : ''}\n`;
|
|
101
|
+
if (node.type === 'directory' && node.children) {
|
|
102
|
+
result += printFileTree(node.children, depth + 1);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
function printFileTreeWithTokens(nodes, fileTokenScores, path = []) {
|
|
108
|
+
let result = '';
|
|
109
|
+
const depth = path.length;
|
|
110
|
+
const indentToken = ' ';
|
|
111
|
+
const indentation = indentToken.repeat(depth);
|
|
112
|
+
const indentationWithFile = indentToken.repeat(depth + 1);
|
|
113
|
+
for (const node of nodes) {
|
|
114
|
+
result += `${indentation}${node.name}${node.type === 'directory' ? '/' : ''}`;
|
|
115
|
+
path.push(node.name);
|
|
116
|
+
const filePath = path.join('/');
|
|
117
|
+
const tokenScores = fileTokenScores[filePath];
|
|
118
|
+
if (node.type === 'file' && tokenScores) {
|
|
119
|
+
const tokens = Object.keys(tokenScores);
|
|
120
|
+
if (tokens.length > 0) {
|
|
121
|
+
result += `\n${indentationWithFile}${tokens.join(' ')}`;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
result += '\n';
|
|
125
|
+
if (node.type === 'directory' && node.children) {
|
|
126
|
+
result += printFileTreeWithTokens(node.children, fileTokenScores, path);
|
|
127
|
+
}
|
|
128
|
+
path.pop();
|
|
129
|
+
}
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
const ensureDirectoryExists = (baseDir) => {
|
|
133
|
+
if (!fs.existsSync(baseDir)) {
|
|
134
|
+
fs.mkdirSync(baseDir, { recursive: true });
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
exports.ensureDirectoryExists = ensureDirectoryExists;
|
|
138
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/util/file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmGA,sCAaC;AAED,0DA4BC;AA9ID,uCAAwB;AACxB,6BAAuB;AAEV,QAAA,kBAAkB,GAA4B,OAAC,CAAC,MAAM,CAAC;IAClE,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnC,QAAQ,EAAE,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAC,CAAC,KAAK,CAAC,0BAAkB,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC9D,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;CACrB,CAAC,CAAA;AAoBW,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAA;AAIW,QAAA,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC/C,uBAAuB,EAAE,OAAC,CAAC,MAAM,EAAE;IACnC,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAgB,C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AM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;YACzD,CAAC;QACH,CAAC;QACD,MAAM,IAAI,IAAI,CAAA;QACd,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC/C,MAAM,IAAI,uBAAuB,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,EAAE,IAAI,CAAC,CAAA;QACzE,CAAC;QACD,IAAI,CAAC,GAAG,EAAE,CAAA;IACZ,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAEM,MAAM,qBAAqB,GAAG,CAAC,OAAe,EAAE,EAAE;IACvD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC5C,CAAC;AACH,CAAC,CAAA;AAJY,QAAA,qBAAqB,yBAIjC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasStagedChanges = hasStagedChanges;
|
|
4
|
+
exports.getStagedChanges = getStagedChanges;
|
|
5
|
+
exports.commitChanges = commitChanges;
|
|
6
|
+
exports.stageAllChanges = stageAllChanges;
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
function hasStagedChanges() {
|
|
9
|
+
try {
|
|
10
|
+
(0, child_process_1.execSync)('git diff --staged --quiet', { stdio: 'ignore' });
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function getStagedChanges() {
|
|
18
|
+
try {
|
|
19
|
+
return (0, child_process_1.execSync)('git diff --staged').toString();
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function commitChanges(commitMessage) {
|
|
26
|
+
try {
|
|
27
|
+
(0, child_process_1.execSync)(`git commit -m "${commitMessage}"`, { stdio: 'ignore' });
|
|
28
|
+
}
|
|
29
|
+
catch (error) { }
|
|
30
|
+
}
|
|
31
|
+
function stageAllChanges() {
|
|
32
|
+
try {
|
|
33
|
+
(0, child_process_1.execSync)('git add -A', { stdio: 'pipe' });
|
|
34
|
+
return hasStagedChanges();
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/util/git.ts"],"names":[],"mappings":";;AAEA,4CAOC;AAED,4CAMC;AAED,sCAIC;AAED,0CAOC;AAhCD,iDAAwC;AAExC,SAAgB,gBAAgB;IAC9B,IAAI,CAAC;QACH,IAAA,wBAAQ,EAAC,2BAA2B,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;QAC1D,OAAO,KAAK,CAAA;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC;AAED,SAAgB,gBAAgB;IAC9B,IAAI,CAAC;QACH,OAAO,IAAA,wBAAQ,EAAC,mBAAmB,CAAC,CAAC,QAAQ,EAAE,CAAA;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC;AAED,SAAgB,aAAa,CAAC,aAAqB;IACjD,IAAI,CAAC;QACH,IAAA,wBAAQ,EAAC,kBAAkB,aAAa,GAAG,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;IACnE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC,CAAA,CAAC;AACpB,CAAC;AAED,SAAgB,eAAe;IAC7B,IAAI,CAAC;QACH,IAAA,wBAAQ,EAAC,YAAY,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;QACzC,OAAO,gBAAgB,EAAE,CAAA;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sleep: (ms: number) => Promise<unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/util/helpers.ts"],"names":[],"mappings":";;;AAAO,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;AAA7D,QAAA,KAAK,SAAwD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const removeUndefinedProps: <T extends object>(obj: T) => T;
|
|
2
|
+
export declare const removeNullOrUndefinedProps: <T extends object>(obj: T, exceptions?: string[]) => T;
|
|
3
|
+
export declare const addObjects: <T extends {
|
|
4
|
+
[key: string]: number;
|
|
5
|
+
}>(obj1: T, obj2: T) => T;
|
|
6
|
+
export declare const subtractObjects: <T extends {
|
|
7
|
+
[key: string]: number;
|
|
8
|
+
}>(obj1: T, obj2: T) => T;
|
|
9
|
+
export declare const hasChanges: <T extends object>(obj: T, partial: Partial<T>) => boolean;
|
|
10
|
+
export declare const hasSignificantDeepChanges: <T extends object>(obj: T, partial: Partial<T>, epsilonForNumbers: number) => boolean;
|
|
11
|
+
export declare const filterObject: <T extends object>(obj: T, predicate: (value: any, key: keyof T) => boolean) => { [P in keyof T]: T[P]; };
|
|
12
|
+
/**
|
|
13
|
+
* Asserts that a condition is true. If the condition is false, it throws an error with the provided message.
|
|
14
|
+
* @param condition The condition to check
|
|
15
|
+
* @param message The error message to display if the condition is false
|
|
16
|
+
* @throws {Error} If the condition is false
|
|
17
|
+
*/
|
|
18
|
+
export declare function assert(condition: boolean, message: string): asserts condition;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterObject = exports.hasSignificantDeepChanges = exports.hasChanges = exports.subtractObjects = exports.addObjects = exports.removeNullOrUndefinedProps = exports.removeUndefinedProps = void 0;
|
|
4
|
+
exports.assert = assert;
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const removeUndefinedProps = (obj) => {
|
|
7
|
+
const newObj = {};
|
|
8
|
+
for (const key of Object.keys(obj)) {
|
|
9
|
+
if (obj[key] !== undefined)
|
|
10
|
+
newObj[key] = obj[key];
|
|
11
|
+
}
|
|
12
|
+
return newObj;
|
|
13
|
+
};
|
|
14
|
+
exports.removeUndefinedProps = removeUndefinedProps;
|
|
15
|
+
const removeNullOrUndefinedProps = (obj, exceptions) => {
|
|
16
|
+
const newObj = {};
|
|
17
|
+
for (const key of Object.keys(obj)) {
|
|
18
|
+
if ((obj[key] !== undefined && obj[key] !== null) ||
|
|
19
|
+
(exceptions ?? []).includes(key))
|
|
20
|
+
newObj[key] = obj[key];
|
|
21
|
+
}
|
|
22
|
+
return newObj;
|
|
23
|
+
};
|
|
24
|
+
exports.removeNullOrUndefinedProps = removeNullOrUndefinedProps;
|
|
25
|
+
const addObjects = (obj1, obj2) => {
|
|
26
|
+
const keys = (0, lodash_1.union)(Object.keys(obj1), Object.keys(obj2));
|
|
27
|
+
const newObj = {};
|
|
28
|
+
for (const key of keys) {
|
|
29
|
+
newObj[key] = (obj1[key] ?? 0) + (obj2[key] ?? 0);
|
|
30
|
+
}
|
|
31
|
+
return newObj;
|
|
32
|
+
};
|
|
33
|
+
exports.addObjects = addObjects;
|
|
34
|
+
const subtractObjects = (obj1, obj2) => {
|
|
35
|
+
const keys = (0, lodash_1.union)(Object.keys(obj1), Object.keys(obj2));
|
|
36
|
+
const newObj = {};
|
|
37
|
+
for (const key of keys) {
|
|
38
|
+
newObj[key] = (obj1[key] ?? 0) - (obj2[key] ?? 0);
|
|
39
|
+
}
|
|
40
|
+
return newObj;
|
|
41
|
+
};
|
|
42
|
+
exports.subtractObjects = subtractObjects;
|
|
43
|
+
const hasChanges = (obj, partial) => {
|
|
44
|
+
const currValues = (0, lodash_1.mapValues)(partial, (_, key) => obj[key]);
|
|
45
|
+
return !(0, lodash_1.isEqual)(currValues, partial);
|
|
46
|
+
};
|
|
47
|
+
exports.hasChanges = hasChanges;
|
|
48
|
+
const hasSignificantDeepChanges = (obj, partial, epsilonForNumbers) => {
|
|
49
|
+
const compareValues = (currValue, partialValue) => {
|
|
50
|
+
if (typeof currValue === 'number' && typeof partialValue === 'number') {
|
|
51
|
+
return Math.abs(currValue - partialValue) > epsilonForNumbers;
|
|
52
|
+
}
|
|
53
|
+
if (typeof currValue === 'object' && typeof partialValue === 'object') {
|
|
54
|
+
return (0, exports.hasSignificantDeepChanges)(currValue, partialValue, epsilonForNumbers);
|
|
55
|
+
}
|
|
56
|
+
return !(0, lodash_1.isEqual)(currValue, partialValue);
|
|
57
|
+
};
|
|
58
|
+
for (const key in partial) {
|
|
59
|
+
if (Object.prototype.hasOwnProperty.call(partial, key)) {
|
|
60
|
+
if (compareValues(obj[key], partial[key])) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
};
|
|
67
|
+
exports.hasSignificantDeepChanges = hasSignificantDeepChanges;
|
|
68
|
+
const filterObject = (obj, predicate) => {
|
|
69
|
+
const result = {};
|
|
70
|
+
for (const key in obj) {
|
|
71
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
72
|
+
if (predicate(obj[key], key)) {
|
|
73
|
+
result[key] = obj[key];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
};
|
|
79
|
+
exports.filterObject = filterObject;
|
|
80
|
+
/**
|
|
81
|
+
* Asserts that a condition is true. If the condition is false, it throws an error with the provided message.
|
|
82
|
+
* @param condition The condition to check
|
|
83
|
+
* @param message The error message to display if the condition is false
|
|
84
|
+
* @throws {Error} If the condition is false
|
|
85
|
+
*/
|
|
86
|
+
function assert(condition, message) {
|
|
87
|
+
if (!condition) {
|
|
88
|
+
throw new Error(`Assertion failed: ${message}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../src/util/object.ts"],"names":[],"mappings":";;;AA6GA,wBAIC;AAjHD,mCAAkD;AAE3C,MAAM,oBAAoB,GAAG,CAAmB,GAAM,EAAK,EAAE;IAClE,MAAM,MAAM,GAAQ,EAAE,CAAA;IAEtB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,IAAK,GAAW,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,MAAM,CAAC,GAAG,CAAC,GAAI,GAAW,CAAC,GAAG,CAAC,CAAA;IACtE,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AARY,QAAA,oBAAoB,wBAQhC;AAEM,MAAM,0BAA0B,GAAG,CACxC,GAAM,EACN,UAAqB,EAClB,EAAE;IACL,MAAM,MAAM,GAAQ,EAAE,CAAA;IAEtB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,IACE,CAAE,GAAW,CAAC,GAAG,CAAC,KAAK,SAAS,IAAK,GAAW,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;YAC/D,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,GA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