@travisennis/acai 0.0.12 → 0.0.14
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 +5 -2
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +91 -5
- package/dist/commands/history/types.d.ts +3 -2
- package/dist/commands/history/types.d.ts.map +1 -1
- package/dist/commands/init-project/utils.d.ts +0 -1
- package/dist/commands/init-project/utils.d.ts.map +1 -1
- package/dist/commands/init-project/utils.js +1 -1
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +0 -18
- package/dist/commands/share/html-renderer.d.ts.map +1 -1
- package/dist/commands/share/html-renderer.js +54 -48
- package/dist/commands/tools/index.js +39 -38
- package/dist/config/index.d.ts +0 -2
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +3 -7
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +94 -76
- package/dist/models/manager.d.ts +1 -10
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +2 -2
- package/dist/models/opencode-go-provider.d.ts +6 -4
- package/dist/models/opencode-go-provider.d.ts.map +1 -1
- package/dist/models/opencode-go-provider.js +55 -35
- package/dist/models/providers.d.ts +1 -1
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/prompts/system-prompt.d.ts +0 -2
- package/dist/prompts/system-prompt.d.ts.map +1 -1
- package/dist/prompts/system-prompt.js +6 -10
- package/dist/repl/index.d.ts +27 -11
- package/dist/repl/index.d.ts.map +1 -1
- package/dist/repl/index.js +238 -254
- package/dist/sessions/manager.d.ts +41 -0
- package/dist/sessions/manager.d.ts.map +1 -1
- package/dist/sessions/manager.js +53 -0
- package/dist/sessions/summary.d.ts.map +1 -1
- package/dist/sessions/summary.js +18 -0
- package/dist/skills/index.d.ts +12 -2
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +123 -73
- package/dist/terminal/control.d.ts +1 -21
- package/dist/terminal/control.d.ts.map +1 -1
- package/dist/terminal/control.js +1 -32
- package/dist/terminal/formatting.d.ts +0 -33
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +0 -91
- package/dist/terminal/highlight/theme.d.ts +0 -37
- package/dist/terminal/highlight/theme.d.ts.map +1 -1
- package/dist/terminal/highlight/theme.js +1 -79
- package/dist/terminal/keys.d.ts +0 -97
- package/dist/terminal/keys.d.ts.map +1 -1
- package/dist/terminal/keys.js +0 -194
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +65 -51
- package/dist/terminal/style.d.ts +1 -1
- package/dist/terminal/style.d.ts.map +1 -1
- package/dist/terminal/supports-color.d.ts.map +1 -1
- package/dist/terminal/supports-color.js +38 -20
- package/dist/terminal/supports-hyperlinks.d.ts +3 -0
- package/dist/terminal/supports-hyperlinks.d.ts.map +1 -1
- package/dist/terminal/supports-hyperlinks.js +72 -31
- package/dist/terminal/table/layout-manager.d.ts +0 -20
- package/dist/terminal/table/layout-manager.d.ts.map +1 -1
- package/dist/terminal/table/layout-manager.js +68 -44
- package/dist/terminal/table/utils.d.ts +0 -1
- package/dist/terminal/table/utils.d.ts.map +1 -1
- package/dist/terminal/table/utils.js +2 -4
- package/dist/tools/apply-patch.d.ts +5 -3
- package/dist/tools/apply-patch.d.ts.map +1 -1
- package/dist/tools/apply-patch.js +154 -123
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +11 -8
- package/dist/tools/dynamic-tool-loader.d.ts +6 -1
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +154 -135
- package/dist/tools/index.d.ts +3 -133
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +0 -20
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +32 -13
- package/dist/tools/skill.d.ts.map +1 -1
- package/dist/tools/skill.js +20 -13
- package/dist/tools/web-fetch.d.ts +2 -6
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +59 -36
- package/dist/tools/web-search.d.ts +0 -4
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +40 -32
- package/dist/tui/autocomplete/utils.d.ts +0 -15
- package/dist/tui/autocomplete/utils.d.ts.map +1 -1
- package/dist/tui/autocomplete/utils.js +0 -85
- package/dist/tui/autocomplete.d.ts +1 -1
- package/dist/tui/autocomplete.d.ts.map +1 -1
- package/dist/tui/autocomplete.js +1 -1
- package/dist/tui/components/editor.d.ts +12 -0
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +181 -195
- package/dist/tui/components/input.d.ts +4 -0
- package/dist/tui/components/input.d.ts.map +1 -1
- package/dist/tui/components/input.js +33 -31
- package/dist/tui/components/markdown.d.ts +30 -0
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +274 -242
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +11 -11
- package/dist/tui/components/select-list.d.ts +5 -0
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +69 -98
- package/dist/tui/components/table.d.ts +6 -0
- package/dist/tui/components/table.d.ts.map +1 -1
- package/dist/tui/components/table.js +61 -52
- package/dist/tui/index.d.ts +1 -8
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +0 -8
- package/dist/tui/tui.d.ts +9 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +78 -48
- package/dist/tui/utils.d.ts +7 -0
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +117 -53
- package/dist/utils/bash.d.ts.map +1 -1
- package/dist/utils/bash.js +156 -104
- package/dist/utils/command-protection.d.ts +3 -6
- package/dist/utils/command-protection.d.ts.map +1 -1
- package/dist/utils/command-protection.js +213 -100
- package/dist/utils/filesystem/operations.d.ts +0 -15
- package/dist/utils/filesystem/operations.d.ts.map +1 -1
- package/dist/utils/filesystem/operations.js +1 -38
- package/dist/utils/filesystem/security.d.ts.map +1 -1
- package/dist/utils/filesystem/security.js +22 -15
- package/dist/utils/filetype-detection.d.ts +0 -1
- package/dist/utils/filetype-detection.d.ts.map +1 -1
- package/dist/utils/filetype-detection.js +0 -12
- package/dist/utils/formatting.d.ts +0 -30
- package/dist/utils/formatting.d.ts.map +1 -1
- package/dist/utils/formatting.js +0 -44
- package/dist/utils/git.d.ts +4 -6
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +36 -46
- package/dist/utils/ignore.d.ts +1 -1
- package/dist/utils/ignore.d.ts.map +1 -1
- package/dist/utils/ignore.js +1 -1
- package/dist/utils/process.d.ts.map +1 -1
- package/dist/utils/process.js +77 -79
- package/dist/utils/yaml.d.ts +0 -1
- package/dist/utils/yaml.d.ts.map +1 -1
- package/dist/utils/yaml.js +80 -89
- package/dist/utils/zod.d.ts +0 -3
- package/dist/utils/zod.d.ts.map +1 -1
- package/dist/utils/zod.js +0 -7
- package/package.json +25 -24
- package/dist/agent/sub-agent.d.ts +0 -23
- package/dist/agent/sub-agent.d.ts.map +0 -1
- package/dist/agent/sub-agent.js +0 -109
- package/dist/commands/add-directory/index.d.ts +0 -3
- package/dist/commands/add-directory/index.d.ts.map +0 -1
- package/dist/commands/add-directory/index.js +0 -50
- package/dist/commands/add-directory/utils.d.ts +0 -3
- package/dist/commands/add-directory/utils.d.ts.map +0 -1
- package/dist/commands/add-directory/utils.js +0 -15
- package/dist/commands/clear/index.d.ts +0 -3
- package/dist/commands/clear/index.d.ts.map +0 -1
- package/dist/commands/clear/index.js +0 -13
- package/dist/commands/generate-rules/index.d.ts +0 -3
- package/dist/commands/generate-rules/index.d.ts.map +0 -1
- package/dist/commands/generate-rules/index.js +0 -206
- package/dist/commands/generate-rules/service.d.ts +0 -22
- package/dist/commands/generate-rules/service.d.ts.map +0 -1
- package/dist/commands/generate-rules/service.js +0 -103
- package/dist/commands/generate-rules/utils.d.ts +0 -5
- package/dist/commands/generate-rules/utils.d.ts.map +0 -1
- package/dist/commands/generate-rules/utils.js +0 -25
- package/dist/commands/handoff/index.d.ts +0 -3
- package/dist/commands/handoff/index.d.ts.map +0 -1
- package/dist/commands/handoff/index.js +0 -97
- package/dist/commands/handoff/utils.d.ts +0 -4
- package/dist/commands/handoff/utils.d.ts.map +0 -1
- package/dist/commands/handoff/utils.js +0 -123
- package/dist/commands/list-directories/index.d.ts +0 -3
- package/dist/commands/list-directories/index.d.ts.map +0 -1
- package/dist/commands/list-directories/index.js +0 -35
- package/dist/commands/pickup/index.d.ts +0 -3
- package/dist/commands/pickup/index.d.ts.map +0 -1
- package/dist/commands/pickup/index.js +0 -141
- package/dist/commands/pickup/types.d.ts +0 -6
- package/dist/commands/pickup/types.d.ts.map +0 -1
- package/dist/commands/pickup/types.js +0 -1
- package/dist/commands/pickup/utils.d.ts +0 -7
- package/dist/commands/pickup/utils.d.ts.map +0 -1
- package/dist/commands/pickup/utils.js +0 -56
- package/dist/commands/remove-directory/index.d.ts +0 -3
- package/dist/commands/remove-directory/index.d.ts.map +0 -1
- package/dist/commands/remove-directory/index.js +0 -55
- package/dist/commands/review/index.d.ts +0 -3
- package/dist/commands/review/index.d.ts.map +0 -1
- package/dist/commands/review/index.js +0 -12
- package/dist/commands/review/review-panel.d.ts +0 -3
- package/dist/commands/review/review-panel.d.ts.map +0 -1
- package/dist/commands/review/review-panel.js +0 -186
- package/dist/commands/review/utils.d.ts +0 -18
- package/dist/commands/review/utils.d.ts.map +0 -1
- package/dist/commands/review/utils.js +0 -146
- package/dist/commands/shell/index.d.ts +0 -3
- package/dist/commands/shell/index.d.ts.map +0 -1
- package/dist/commands/shell/index.js +0 -96
- package/dist/subagents/index.d.ts +0 -16
- package/dist/subagents/index.d.ts.map +0 -1
- package/dist/subagents/index.js +0 -231
- package/dist/terminal/index.d.ts +0 -9
- package/dist/terminal/index.d.ts.map +0 -1
- package/dist/terminal/index.js +0 -8
- package/dist/tools/agent.d.ts +0 -27
- package/dist/tools/agent.d.ts.map +0 -1
- package/dist/tools/agent.js +0 -81
- package/dist/tools/directory-tree.d.ts +0 -28
- package/dist/tools/directory-tree.d.ts.map +0 -1
- package/dist/tools/directory-tree.js +0 -154
- package/dist/tools/glob.d.ts +0 -35
- package/dist/tools/glob.d.ts.map +0 -1
- package/dist/tools/glob.js +0 -167
- package/dist/tools/grep.d.ts +0 -100
- package/dist/tools/grep.d.ts.map +0 -1
- package/dist/tools/grep.js +0 -608
- package/dist/tools/ls.d.ts +0 -26
- package/dist/tools/ls.d.ts.map +0 -1
- package/dist/tools/ls.js +0 -83
- package/dist/tui/components/header.d.ts +0 -21
- package/dist/tui/components/header.d.ts.map +0 -1
- package/dist/tui/components/header.js +0 -63
- package/dist/utils/bash/parse.d.ts +0 -19
- package/dist/utils/bash/parse.d.ts.map +0 -1
- package/dist/utils/bash/parse.js +0 -223
- package/dist/utils/bash/quote.d.ts +0 -6
- package/dist/utils/bash/quote.d.ts.map +0 -1
- package/dist/utils/bash/quote.js +0 -23
- package/dist/utils/generators.d.ts +0 -3
- package/dist/utils/generators.d.ts.map +0 -1
- package/dist/utils/generators.js +0 -25
- package/dist/utils/glob.d.ts +0 -52
- package/dist/utils/glob.d.ts.map +0 -1
- package/dist/utils/glob.js +0 -376
package/dist/utils/git.d.ts
CHANGED
|
@@ -3,17 +3,14 @@ export declare function getDiffStat(): Promise<{
|
|
|
3
3
|
insertions: number;
|
|
4
4
|
deletions: number;
|
|
5
5
|
}>;
|
|
6
|
-
|
|
6
|
+
interface GitCounts {
|
|
7
7
|
added: number;
|
|
8
8
|
modified: number;
|
|
9
9
|
deleted: number;
|
|
10
10
|
untracked: number;
|
|
11
|
-
}
|
|
11
|
+
}
|
|
12
|
+
export declare function getGitStatus(): Promise<GitCounts>;
|
|
12
13
|
export declare const inGitDirectory: () => Promise<boolean>;
|
|
13
|
-
/**
|
|
14
|
-
* Check if there are uncommitted changes
|
|
15
|
-
*/
|
|
16
|
-
export declare function hasUncommittedChanges(): Promise<boolean>;
|
|
17
14
|
/**
|
|
18
15
|
* Get the current git branch name
|
|
19
16
|
*/
|
|
@@ -22,4 +19,5 @@ export declare function getCurrentBranch(): Promise<string | null>;
|
|
|
22
19
|
* Count commits that exist locally but haven't been pushed to the remote branch
|
|
23
20
|
*/
|
|
24
21
|
export declare function getUnpushedCommitsCount(): Promise<number>;
|
|
22
|
+
export {};
|
|
25
23
|
//# sourceMappingURL=git.d.ts.map
|
package/dist/utils/git.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../source/utils/git.ts"],"names":[],"mappings":"AAIA,wBAAsB,WAAW;;;;GAyDhC;AAED,
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../source/utils/git.ts"],"names":[],"mappings":"AAIA,wBAAsB,WAAW;;;;GAyDhC;AAED,UAAU,SAAS;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,SAAS,CAAC,CAuBvD;AAyBD,eAAO,MAAM,cAAc,QAAqB,OAAO,CAAC,OAAO,CAS7D,CAAC;AAEH;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkB/D;AAED;;GAEG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC,CAmC/D"}
|
package/dist/utils/git.js
CHANGED
|
@@ -56,41 +56,47 @@ export async function getDiffStat() {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
export async function getGitStatus() {
|
|
59
|
-
// Git status processing (optimized)
|
|
60
59
|
const result = await executeCommand(["git", "status", "--porcelain"], {
|
|
61
60
|
cwd: process.cwd(),
|
|
62
61
|
throwOnError: false,
|
|
63
62
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const lines = result.stdout.split("\n");
|
|
70
|
-
for (const line of lines) {
|
|
71
|
-
if (!line)
|
|
72
|
-
continue;
|
|
73
|
-
const s = line.slice(0, 2);
|
|
74
|
-
if (s[0] === "A" || s === "M ")
|
|
75
|
-
added++;
|
|
76
|
-
else if (s[1] === "M" || s === " M")
|
|
77
|
-
modified++;
|
|
78
|
-
else if (s[0] === "D" || s === " D")
|
|
79
|
-
deleted++;
|
|
80
|
-
else if (s === "??")
|
|
81
|
-
untracked++;
|
|
82
|
-
}
|
|
83
|
-
// if (added) gitStatus += ` +${added}`;
|
|
84
|
-
// if (modified) gitStatus += ` ~${modified}`;
|
|
85
|
-
// if (deleted) gitStatus += ` -${deleted}`;
|
|
86
|
-
// if (untracked) gitStatus += ` ?${untracked}`;
|
|
87
|
-
}
|
|
88
|
-
return {
|
|
89
|
-
added,
|
|
90
|
-
modified,
|
|
91
|
-
deleted,
|
|
92
|
-
untracked,
|
|
63
|
+
const counts = {
|
|
64
|
+
added: 0,
|
|
65
|
+
modified: 0,
|
|
66
|
+
deleted: 0,
|
|
67
|
+
untracked: 0,
|
|
93
68
|
};
|
|
69
|
+
if (result.code !== 0) {
|
|
70
|
+
return counts;
|
|
71
|
+
}
|
|
72
|
+
const lines = result.stdout.split("\n");
|
|
73
|
+
for (const line of lines) {
|
|
74
|
+
incrementCountsFromStatusLine(line, counts);
|
|
75
|
+
}
|
|
76
|
+
return counts;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Parse a single git status --porcelain line and increment the appropriate counter.
|
|
80
|
+
*/
|
|
81
|
+
function incrementCountsFromStatusLine(line, counts) {
|
|
82
|
+
if (!line)
|
|
83
|
+
return;
|
|
84
|
+
const s = line.slice(0, 2);
|
|
85
|
+
if (s === "??") {
|
|
86
|
+
counts.untracked++;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (s[0] === "A" || s === "M ") {
|
|
90
|
+
counts.added++;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (s[1] === "M" || s === " M") {
|
|
94
|
+
counts.modified++;
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (s[0] === "D" || s === " D") {
|
|
98
|
+
counts.deleted++;
|
|
99
|
+
}
|
|
94
100
|
}
|
|
95
101
|
export const inGitDirectory = memoize(async () => {
|
|
96
102
|
const { code } = await executeCommand(["git", "rev-parse", "--is-inside-work-tree"], {
|
|
@@ -99,22 +105,6 @@ export const inGitDirectory = memoize(async () => {
|
|
|
99
105
|
});
|
|
100
106
|
return code === 0;
|
|
101
107
|
});
|
|
102
|
-
/**
|
|
103
|
-
* Check if there are uncommitted changes
|
|
104
|
-
*/
|
|
105
|
-
export async function hasUncommittedChanges() {
|
|
106
|
-
try {
|
|
107
|
-
const result = await executeCommand(["git", "status", "--porcelain"], {
|
|
108
|
-
cwd: process.cwd(),
|
|
109
|
-
throwOnError: false,
|
|
110
|
-
});
|
|
111
|
-
// If there are uncommitted changes, --porcelain will output lines for each changed file
|
|
112
|
-
return result.stdout.trim().length > 0;
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
108
|
/**
|
|
119
109
|
* Get the current git branch name
|
|
120
110
|
*/
|
package/dist/utils/ignore.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ignore.d.ts","sourceRoot":"","sources":["../../source/utils/ignore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqWH,UAAU,UAAU;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,UAAU,aAAa;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,cAAM,UAAU;IACd,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,IAAI,CAAC,EAAE,OAAO,CAAC;IAC/B,SAAgB,QAAQ,EAAE,OAAO,CAAC;IAElC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAU;IACrC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAGrC,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,WAAW,CAAC,CAAS;gBAG3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,OAAO,GAAG,SAAS,EACzB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,OAAO,EACnB,QAAQ,EAAE,OAAO,EACjB,WAAW,EAAE,MAAM;IASrB,IAAI,KAAK,IAAI,MAAM,CAKlB;IAED,IAAI,UAAU,IAAI,MAAM,CAKvB;IAED,OAAO,CAAC,YAAY;CAWrB;AA0MD,UAAU,aAAa;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,
|
|
1
|
+
{"version":3,"file":"ignore.d.ts","sourceRoot":"","sources":["../../source/utils/ignore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqWH,UAAU,UAAU;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,UAAU,aAAa;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,cAAM,UAAU;IACd,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,IAAI,CAAC,EAAE,OAAO,CAAC;IAC/B,SAAgB,QAAQ,EAAE,OAAO,CAAC;IAElC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAU;IACrC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAGrC,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,WAAW,CAAC,CAAS;gBAG3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,OAAO,GAAG,SAAS,EACzB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,OAAO,EACnB,QAAQ,EAAE,OAAO,EACjB,WAAW,EAAE,MAAM;IASrB,IAAI,KAAK,IAAI,MAAM,CAKlB;IAED,IAAI,UAAU,IAAI,MAAM,CAKvB;IAED,OAAO,CAAC,YAAY;CAWrB;AA0MD,UAAU,aAAa;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,cAAM,MAAM;IACV,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;IACrC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAU;IAC3C,OAAO,CAAC,YAAY,CAAkC;IACtD,OAAO,CAAC,UAAU,CAAkC;IAEpD;;;;;;OAMG;gBACS,EACV,UAAiB,EACjB,UAAuB,EACvB,kBAA0B,GAC3B,GAAE,aAAkB;IASrB,OAAO,CAAC,UAAU;IAQlB;;OAEG;IACH,UAAU,IAAI,IAAI;IAKlB;;;;OAIG;IACH,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,aAAa,GAAG,IAAI;IAW9D;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,aAAa,GAAG,IAAI;IAKrE,OAAO,CAAC,KAAK;IAuBb;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IA0BrC,OAAO,CAAC,EAAE;IAgDV;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI9B;;;OAGG;IACH,YAAY,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO;IAIzC;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE;IAI1C;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAI9B;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;CAKjC;AAED,QAAA,MAAM,OAAO;eAAc,aAAa,GAAG,MAAM;;CAAuB,CAAC;AA6BzE,eAAe,OAAO,CAAC"}
|
package/dist/utils/ignore.js
CHANGED
|
@@ -458,7 +458,7 @@ const isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path);
|
|
|
458
458
|
checkPath.isNotRelative = isNotRelative;
|
|
459
459
|
// On windows, the following function will be replaced
|
|
460
460
|
checkPath.convert = (p) => p;
|
|
461
|
-
|
|
461
|
+
class Ignore {
|
|
462
462
|
_rules;
|
|
463
463
|
_strictPathCheck;
|
|
464
464
|
_ignoreCache = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../source/utils/process.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../source/utils/process.ts"],"names":[],"mappings":"AA2EA,UAAU,cAAc;IACtB,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,sDAAsD;IACtD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,2EAA2E;IAC3E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mGAAmG;IACnG,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,aAAa;IACrB,uCAAuC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;CACzB;AAED,KAAK,WAAW,GACZ;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAA;CAAE,GACzC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AA6KjC,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAiBpD;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,EACvC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,aAAa,CAAC,CA4CxB"}
|
package/dist/utils/process.js
CHANGED
|
@@ -1,8 +1,46 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
2
3
|
import { isUndefined } from "@travisennis/stdlib/typeguards";
|
|
3
4
|
const MS_IN_SECOND = 1000;
|
|
4
5
|
const SECONDS_IN_MINUTE = 60;
|
|
5
6
|
const DEFAULT_TIMEOUT = 2 * SECONDS_IN_MINUTE * MS_IN_SECOND;
|
|
7
|
+
/**
|
|
8
|
+
* Returns an error result or rejects based on throwOnError flag.
|
|
9
|
+
*/
|
|
10
|
+
function earlyError(throwOnError, message, code) {
|
|
11
|
+
const result = { stdout: "", stderr: message, code };
|
|
12
|
+
if (throwOnError) {
|
|
13
|
+
return Promise.reject(new Error(message));
|
|
14
|
+
}
|
|
15
|
+
return Promise.resolve(result);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Handles an error from execFile and returns an ExecuteResult.
|
|
19
|
+
* May throw if throwOnError is true.
|
|
20
|
+
*/
|
|
21
|
+
function handleExecError(error, throwOnError, preserveOutputOnError) {
|
|
22
|
+
const execError = error;
|
|
23
|
+
let errorCode = typeof execError.code === "number" ? execError.code : 1;
|
|
24
|
+
let errorSignal = execError.signal ?? undefined;
|
|
25
|
+
if (execError.name === "AbortError") {
|
|
26
|
+
errorCode = 130;
|
|
27
|
+
errorSignal = "SIGINT";
|
|
28
|
+
}
|
|
29
|
+
const result = {
|
|
30
|
+
stdout: preserveOutputOnError ? (execError.stdout ?? "") : "",
|
|
31
|
+
stderr: preserveOutputOnError ? (execError.stderr ?? "") : "",
|
|
32
|
+
code: errorCode,
|
|
33
|
+
signal: errorSignal,
|
|
34
|
+
};
|
|
35
|
+
if (throwOnError) {
|
|
36
|
+
throw Object.assign(execError, { result });
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Wraps execFile in a Promise for async/await usage.
|
|
42
|
+
*/
|
|
43
|
+
const execFilePromise = promisify(execFile);
|
|
6
44
|
/**
|
|
7
45
|
* Checks for shell-only constructs that are not allowed.
|
|
8
46
|
*/
|
|
@@ -71,8 +109,11 @@ function handleEscape(input, i, ch, inSingle, inDouble, buf) {
|
|
|
71
109
|
}
|
|
72
110
|
return null;
|
|
73
111
|
}
|
|
74
|
-
|
|
75
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Tokenizes the input string into arguments, handling quotes and escapes.
|
|
114
|
+
* Contains the core while-loop parsing logic.
|
|
115
|
+
*/
|
|
116
|
+
function tokenizeArgv(input) {
|
|
76
117
|
const argv = [];
|
|
77
118
|
let buf = "";
|
|
78
119
|
let i = 0;
|
|
@@ -109,7 +150,7 @@ export function parseArgv(input) {
|
|
|
109
150
|
// Handle escape sequences
|
|
110
151
|
const escapeResult = handleEscape(input, i, ch, inSingle, inDouble, buf);
|
|
111
152
|
if (escapeResult) {
|
|
112
|
-
if ("
|
|
153
|
+
if ("error" in escapeResult) {
|
|
113
154
|
return escapeResult;
|
|
114
155
|
}
|
|
115
156
|
buf = escapeResult.buf;
|
|
@@ -119,17 +160,26 @@ export function parseArgv(input) {
|
|
|
119
160
|
buf += ch;
|
|
120
161
|
i += 1;
|
|
121
162
|
}
|
|
122
|
-
|
|
163
|
+
return { ok: true, argv, buf, inSingle, inDouble };
|
|
164
|
+
}
|
|
165
|
+
// Quote/escape-aware argv tokenizer that forbids command substitution
|
|
166
|
+
export function parseArgv(input) {
|
|
167
|
+
const result = tokenizeArgv(input);
|
|
168
|
+
if (!result.ok)
|
|
169
|
+
return result;
|
|
170
|
+
if (result.inSingle || result.inDouble) {
|
|
123
171
|
return { ok: false, error: "Unterminated quote" };
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
172
|
+
}
|
|
173
|
+
if (result.buf.length > 0)
|
|
174
|
+
result.argv.push(result.buf);
|
|
175
|
+
if (result.argv.length === 0) {
|
|
127
176
|
return { ok: false, error: "Empty command" };
|
|
128
|
-
|
|
177
|
+
}
|
|
178
|
+
const first = result.argv[0];
|
|
129
179
|
if (typeof first !== "string" || first.trim() === "") {
|
|
130
180
|
return { ok: false, error: "Missing command" };
|
|
131
181
|
}
|
|
132
|
-
return { ok: true, argv: argv };
|
|
182
|
+
return { ok: true, argv: result.argv };
|
|
133
183
|
}
|
|
134
184
|
/**
|
|
135
185
|
* Executes a command and returns the result, providing unified error handling
|
|
@@ -139,7 +189,7 @@ export function parseArgv(input) {
|
|
|
139
189
|
* @param options Execution options
|
|
140
190
|
* @returns Promise resolving to an object containing stdout, stderr, and exit code
|
|
141
191
|
*/
|
|
142
|
-
export function executeCommand(command, options) {
|
|
192
|
+
export async function executeCommand(command, options) {
|
|
143
193
|
const { cwd = process.cwd(), timeout = DEFAULT_TIMEOUT, abortSignal, shell = false, throwOnError = false, preserveOutputOnError = true, maxBuffer = 1_000_000, } = options || {};
|
|
144
194
|
let cmd;
|
|
145
195
|
let args;
|
|
@@ -149,79 +199,27 @@ export function executeCommand(command, options) {
|
|
|
149
199
|
else {
|
|
150
200
|
const parsed = parseArgv(command);
|
|
151
201
|
if (!parsed.ok) {
|
|
152
|
-
|
|
153
|
-
stdout: "",
|
|
154
|
-
stderr: parsed.error,
|
|
155
|
-
code: 1,
|
|
156
|
-
};
|
|
157
|
-
return throwOnError
|
|
158
|
-
? Promise.reject(new Error(parsed.error))
|
|
159
|
-
: Promise.resolve(result);
|
|
202
|
+
return earlyError(throwOnError, parsed.error, 1);
|
|
160
203
|
}
|
|
161
204
|
[cmd, ...args] = parsed.argv;
|
|
162
205
|
}
|
|
163
206
|
if (isUndefined(cmd) || cmd.trim() === "") {
|
|
164
|
-
|
|
165
|
-
stdout: "",
|
|
166
|
-
stderr: "Missing command",
|
|
167
|
-
code: 1,
|
|
168
|
-
};
|
|
169
|
-
return throwOnError
|
|
170
|
-
? Promise.reject(new Error("Missing command"))
|
|
171
|
-
: Promise.resolve(result);
|
|
207
|
+
return earlyError(throwOnError, "Missing command", 1);
|
|
172
208
|
}
|
|
173
209
|
if (abortSignal?.aborted) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
shell,
|
|
190
|
-
maxBuffer,
|
|
191
|
-
}, (error, stdout, stderr) => {
|
|
192
|
-
if (error) {
|
|
193
|
-
let errorCode = typeof error.code === "number" ? error.code : 1;
|
|
194
|
-
let errorSignal = error.signal ?? undefined;
|
|
195
|
-
if (error.name === "AbortError") {
|
|
196
|
-
errorCode = 130;
|
|
197
|
-
errorSignal = "SIGINT";
|
|
198
|
-
}
|
|
199
|
-
const result = {
|
|
200
|
-
stdout: preserveOutputOnError ? stdout : "",
|
|
201
|
-
stderr: preserveOutputOnError ? stderr : "",
|
|
202
|
-
code: errorCode,
|
|
203
|
-
signal: errorSignal,
|
|
204
|
-
};
|
|
205
|
-
if (throwOnError) {
|
|
206
|
-
reject(Object.assign(error, { result }));
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
resolve(result);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
resolve({ stdout, stderr, code: 0 });
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
catch (error) {
|
|
218
|
-
const result = { stdout: "", stderr: "", code: 1 };
|
|
219
|
-
if (throwOnError) {
|
|
220
|
-
reject(error);
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
resolve(result);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
});
|
|
210
|
+
return earlyError(throwOnError, "Command execution aborted", 130);
|
|
211
|
+
}
|
|
212
|
+
try {
|
|
213
|
+
const { stdout, stderr } = await execFilePromise(cmd, args, {
|
|
214
|
+
cwd,
|
|
215
|
+
timeout,
|
|
216
|
+
signal: abortSignal,
|
|
217
|
+
shell,
|
|
218
|
+
maxBuffer,
|
|
219
|
+
});
|
|
220
|
+
return { stdout, stderr, code: 0 };
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
return handleExecError(error, throwOnError, preserveOutputOnError);
|
|
224
|
+
}
|
|
227
225
|
}
|
package/dist/utils/yaml.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ type YamlValue = string | number | boolean | null | YamlObject | YamlValue[];
|
|
|
2
2
|
type YamlObject = {
|
|
3
3
|
[key: string]: YamlValue;
|
|
4
4
|
};
|
|
5
|
-
export declare function parseYaml(input: string): YamlObject;
|
|
6
5
|
export declare function parseFrontMatter(markdown: string): {
|
|
7
6
|
data: YamlObject;
|
|
8
7
|
content: string;
|
package/dist/utils/yaml.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../source/utils/yaml.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,UAAU,GAAG,SAAS,EAAE,CAAC;AAC7E,KAAK,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../source/utils/yaml.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,UAAU,GAAG,SAAS,EAAE,CAAC;AAC7E,KAAK,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AA4P/C,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG;IAClD,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAwBA"}
|
package/dist/utils/yaml.js
CHANGED
|
@@ -1,59 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
function parseYaml(input) {
|
|
2
2
|
const lines = input.split("\n");
|
|
3
3
|
const result = {};
|
|
4
4
|
let i = 0;
|
|
5
5
|
while (i < lines.length) {
|
|
6
6
|
const line = lines[i];
|
|
7
7
|
const trimmed = line.trim();
|
|
8
|
-
// Skip empty lines and comments
|
|
9
8
|
if (!trimmed || trimmed.startsWith("#")) {
|
|
10
9
|
i++;
|
|
11
10
|
continue;
|
|
12
11
|
}
|
|
13
|
-
// Check for key-value pair
|
|
14
12
|
const colonIndex = line.indexOf(":");
|
|
15
13
|
if (colonIndex === -1) {
|
|
16
14
|
i++;
|
|
17
15
|
continue;
|
|
18
16
|
}
|
|
19
|
-
const indent = getIndent(line);
|
|
20
17
|
const key = line.slice(0, colonIndex).trim();
|
|
21
18
|
const afterColon = line.slice(colonIndex + 1).trim();
|
|
22
19
|
if (afterColon) {
|
|
23
|
-
// Inline value
|
|
24
20
|
result[key] = parseValue(afterColon);
|
|
25
21
|
i++;
|
|
26
22
|
}
|
|
27
23
|
else {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const nextLine = lines[i];
|
|
32
|
-
const nextIndent = getIndent(nextLine);
|
|
33
|
-
const nextTrimmed = nextLine.trim();
|
|
34
|
-
if (nextTrimmed.startsWith("-")) {
|
|
35
|
-
// Array
|
|
36
|
-
const [arr, newIndex] = parseArray(lines, i, nextIndent);
|
|
37
|
-
result[key] = arr;
|
|
38
|
-
i = newIndex;
|
|
39
|
-
}
|
|
40
|
-
else if (nextIndent > indent && nextTrimmed.includes(":")) {
|
|
41
|
-
// Nested object
|
|
42
|
-
const [obj, newIndex] = parseObject(lines, i, nextIndent);
|
|
43
|
-
result[key] = obj;
|
|
44
|
-
i = newIndex;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
result[key] = null;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
result[key] = null;
|
|
52
|
-
}
|
|
24
|
+
const [value, newIndex] = parseNestedContent(lines, i + 1, getIndent(line));
|
|
25
|
+
result[key] = value;
|
|
26
|
+
i = newIndex;
|
|
53
27
|
}
|
|
54
28
|
}
|
|
55
29
|
return result;
|
|
56
30
|
}
|
|
31
|
+
function parseNestedContent(lines, startIdx, parentIndent) {
|
|
32
|
+
if (startIdx >= lines.length) {
|
|
33
|
+
return [null, startIdx];
|
|
34
|
+
}
|
|
35
|
+
const nextLine = lines[startIdx];
|
|
36
|
+
const nextIndent = getIndent(nextLine);
|
|
37
|
+
const nextTrimmed = nextLine.trim();
|
|
38
|
+
if (nextTrimmed.startsWith("-")) {
|
|
39
|
+
return parseArray(lines, startIdx, nextIndent);
|
|
40
|
+
}
|
|
41
|
+
if (nextIndent > parentIndent && nextTrimmed.includes(":")) {
|
|
42
|
+
return parseObject(lines, startIdx, nextIndent);
|
|
43
|
+
}
|
|
44
|
+
return [null, startIdx];
|
|
45
|
+
}
|
|
57
46
|
function parseObject(lines, start, baseIndent) {
|
|
58
47
|
const obj = {};
|
|
59
48
|
let i = start;
|
|
@@ -68,42 +57,14 @@ function parseObject(lines, start, baseIndent) {
|
|
|
68
57
|
if (indent < baseIndent) {
|
|
69
58
|
break;
|
|
70
59
|
}
|
|
71
|
-
if (indent
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (afterColon) {
|
|
80
|
-
obj[key] = parseValue(afterColon);
|
|
81
|
-
i++;
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
i++;
|
|
85
|
-
if (i < lines.length) {
|
|
86
|
-
const nextLine = lines[i];
|
|
87
|
-
const nextIndent = getIndent(nextLine);
|
|
88
|
-
const nextTrimmed = nextLine.trim();
|
|
89
|
-
if (nextTrimmed.startsWith("-")) {
|
|
90
|
-
const [arr, newIndex] = parseArray(lines, i, nextIndent);
|
|
91
|
-
obj[key] = arr;
|
|
92
|
-
i = newIndex;
|
|
93
|
-
}
|
|
94
|
-
else if (nextIndent > indent && nextTrimmed.includes(":")) {
|
|
95
|
-
const [nested, newIndex] = parseObject(lines, i, nextIndent);
|
|
96
|
-
obj[key] = nested;
|
|
97
|
-
i = newIndex;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
obj[key] = null;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
obj[key] = null;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
60
|
+
if (indent !== baseIndent) {
|
|
61
|
+
i++;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const result = processObjectLine(lines, i, indent);
|
|
65
|
+
if (result !== null) {
|
|
66
|
+
obj[result.key] = result.value;
|
|
67
|
+
i = result.nextIndex;
|
|
107
68
|
}
|
|
108
69
|
else {
|
|
109
70
|
i++;
|
|
@@ -111,6 +72,58 @@ function parseObject(lines, start, baseIndent) {
|
|
|
111
72
|
}
|
|
112
73
|
return [obj, i];
|
|
113
74
|
}
|
|
75
|
+
function processObjectLine(lines, currentIndex, indent) {
|
|
76
|
+
const line = lines[currentIndex];
|
|
77
|
+
const colonIndex = line.indexOf(":");
|
|
78
|
+
if (colonIndex === -1) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
const key = line.slice(0, colonIndex).trim();
|
|
82
|
+
const afterColon = line.slice(colonIndex + 1).trim();
|
|
83
|
+
if (afterColon) {
|
|
84
|
+
return { key, value: parseValue(afterColon), nextIndex: currentIndex + 1 };
|
|
85
|
+
}
|
|
86
|
+
// Empty value after colon - look at next line for nested content
|
|
87
|
+
const nextIndex = currentIndex + 1;
|
|
88
|
+
if (nextIndex >= lines.length) {
|
|
89
|
+
return { key, value: null, nextIndex };
|
|
90
|
+
}
|
|
91
|
+
const nextLine = lines[nextIndex];
|
|
92
|
+
const nextIndent = getIndent(nextLine);
|
|
93
|
+
const nextTrimmed = nextLine.trim();
|
|
94
|
+
if (nextTrimmed.startsWith("-")) {
|
|
95
|
+
const [arr, newIndex] = parseArray(lines, nextIndex, nextIndent);
|
|
96
|
+
return { key, value: arr, nextIndex: newIndex };
|
|
97
|
+
}
|
|
98
|
+
if (nextIndent > indent && nextTrimmed.includes(":")) {
|
|
99
|
+
const [nested, newIndex] = parseObject(lines, nextIndex, nextIndent);
|
|
100
|
+
return { key, value: nested, nextIndex: newIndex };
|
|
101
|
+
}
|
|
102
|
+
return { key, value: null, nextIndex };
|
|
103
|
+
}
|
|
104
|
+
function parseArrayItem(lines, currentIndex, arr) {
|
|
105
|
+
const line = lines[currentIndex];
|
|
106
|
+
const trimmed = line.trim();
|
|
107
|
+
const afterDash = trimmed.slice(1).trim();
|
|
108
|
+
if (afterDash) {
|
|
109
|
+
arr.push(parseValue(afterDash));
|
|
110
|
+
return currentIndex + 1;
|
|
111
|
+
}
|
|
112
|
+
// Empty dash - check next line for nested content
|
|
113
|
+
const nextIndex = currentIndex + 1;
|
|
114
|
+
if (nextIndex >= lines.length) {
|
|
115
|
+
return nextIndex;
|
|
116
|
+
}
|
|
117
|
+
const nextLine = lines[nextIndex];
|
|
118
|
+
const nextIndent = getIndent(nextLine);
|
|
119
|
+
const nextTrimmed = nextLine.trim();
|
|
120
|
+
if (nextTrimmed.includes(":")) {
|
|
121
|
+
const [obj, newIndex] = parseObject(lines, nextIndex, nextIndent);
|
|
122
|
+
arr.push(obj);
|
|
123
|
+
return newIndex;
|
|
124
|
+
}
|
|
125
|
+
return nextIndex + 1;
|
|
126
|
+
}
|
|
114
127
|
function parseArray(lines, start, baseIndent) {
|
|
115
128
|
const arr = [];
|
|
116
129
|
let i = start;
|
|
@@ -126,29 +139,7 @@ function parseArray(lines, start, baseIndent) {
|
|
|
126
139
|
break;
|
|
127
140
|
}
|
|
128
141
|
if (indent === baseIndent && trimmed.startsWith("-")) {
|
|
129
|
-
|
|
130
|
-
if (afterDash) {
|
|
131
|
-
// Inline array item
|
|
132
|
-
arr.push(parseValue(afterDash));
|
|
133
|
-
i++;
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
// Check next line for nested content
|
|
137
|
-
i++;
|
|
138
|
-
if (i < lines.length) {
|
|
139
|
-
const nextLine = lines[i];
|
|
140
|
-
const nextIndent = getIndent(nextLine);
|
|
141
|
-
const nextTrimmed = nextLine.trim();
|
|
142
|
-
if (nextTrimmed.includes(":")) {
|
|
143
|
-
const [obj, newIndex] = parseObject(lines, i, nextIndent);
|
|
144
|
-
arr.push(obj);
|
|
145
|
-
i = newIndex;
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
i++;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
142
|
+
i = parseArrayItem(lines, i, arr);
|
|
152
143
|
}
|
|
153
144
|
else {
|
|
154
145
|
i++;
|
package/dist/utils/zod.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import { ZodType } from "zod";
|
|
2
|
-
export declare function isZodSchema(obj: unknown): obj is ZodType<unknown>;
|
|
3
|
-
export declare function zodToJsonSchema(schema: ZodType<unknown>): Record<string, unknown>;
|
|
4
1
|
export declare const convertNullString: (value: unknown) => unknown;
|
|
5
2
|
//# sourceMappingURL=zod.d.ts.map
|
package/dist/utils/zod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../source/utils/zod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../source/utils/zod.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,GAAI,OAAO,OAAO,KAAG,OAgBlD,CAAC"}
|
package/dist/utils/zod.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import z, { ZodType } from "zod";
|
|
2
|
-
export function isZodSchema(obj) {
|
|
3
|
-
return obj instanceof ZodType;
|
|
4
|
-
}
|
|
5
|
-
export function zodToJsonSchema(schema) {
|
|
6
|
-
return z.toJSONSchema(schema);
|
|
7
|
-
}
|
|
8
1
|
// Many models do not reliably pass null to optional tool fields. Instead they pass "null", "None", "undefined", or empty strings.
|
|
9
2
|
// This function will coerce all of those values into null.
|
|
10
3
|
export const convertNullString = (value) => {
|