@nghyane/arcane 0.1.13 → 0.1.15
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/CHANGELOG.md +28 -0
- package/package.json +21 -70
- package/scripts/format-prompts.ts +1 -3
- package/src/cli/args.ts +2 -7
- package/src/cli/config-cli.ts +1 -1
- package/src/cli/plugin-cli.ts +1 -1
- package/src/cli/setup-cli.ts +1 -1
- package/src/cli/update-cli.ts +1 -1
- package/src/cli/web-search-cli.ts +1 -1
- package/src/cli.ts +0 -1
- package/src/commands/config.ts +1 -1
- package/src/commands/grep.ts +1 -1
- package/src/commands/jupyter.ts +1 -1
- package/src/commands/plugin.ts +1 -1
- package/src/commands/setup.ts +1 -1
- package/src/commands/shell.ts +1 -1
- package/src/commands/ssh.ts +1 -1
- package/src/commands/stats.ts +1 -1
- package/src/commands/update.ts +1 -1
- package/src/config/model-registry.ts +3 -4
- package/src/config/model-resolver.ts +36 -9
- package/src/config/prompt-templates.ts +1 -9
- package/src/config/settings-schema.ts +32 -88
- package/src/config/settings.ts +3 -4
- package/src/debug/index.ts +1 -1
- package/src/debug/log-formatting.ts +1 -1
- package/src/debug/log-viewer.ts +2 -2
- package/src/discovery/helpers.ts +13 -3
- package/src/exa/index.ts +1 -35
- package/src/exa/render.ts +30 -190
- package/src/export/html/index.ts +1 -1
- package/src/extensibility/custom-tools/loader.ts +1 -1
- package/src/extensibility/custom-tools/types.ts +5 -1
- package/src/extensibility/custom-tools/wrapper.ts +1 -1
- package/src/extensibility/extensions/runner.ts +1 -1
- package/src/extensibility/extensions/types.ts +1 -1
- package/src/extensibility/extensions/wrapper.ts +7 -15
- package/src/extensibility/hooks/runner.ts +1 -1
- package/src/extensibility/hooks/types.ts +1 -1
- package/src/extensibility/plugins/doctor.ts +1 -1
- package/src/index.ts +13 -13
- package/src/lsp/index.ts +77 -24
- package/src/lsp/render.ts +34 -583
- package/src/lsp/types.ts +3 -3
- package/src/lsp/utils.ts +1 -1
- package/src/main.ts +1 -1
- package/src/mcp/tool-bridge.ts +1 -24
- package/src/modes/components/assistant-message.ts +7 -7
- package/src/modes/components/bash-execution.ts +50 -112
- package/src/modes/components/bordered-loader.ts +1 -1
- package/src/modes/components/branch-summary-message.ts +16 -10
- package/src/modes/components/compaction-summary-message.ts +20 -12
- package/src/modes/components/context-group.ts +106 -0
- package/src/modes/components/custom-message.ts +4 -5
- package/src/modes/components/diff.ts +2 -2
- package/src/modes/components/dynamic-border.ts +1 -1
- package/src/modes/components/extensions/extension-dashboard.ts +1 -1
- package/src/modes/components/extensions/extension-list.ts +1 -1
- package/src/modes/components/extensions/inspector-panel.ts +1 -1
- package/src/modes/components/footer.ts +2 -2
- package/src/modes/components/history-search.ts +1 -1
- package/src/modes/components/hook-editor.ts +1 -1
- package/src/modes/components/hook-input.ts +1 -1
- package/src/modes/components/hook-message.ts +4 -5
- package/src/modes/components/hook-selector.ts +1 -1
- package/src/modes/components/index.ts +0 -2
- package/src/modes/components/keybinding-hints.ts +1 -1
- package/src/modes/components/login-dialog.ts +1 -1
- package/src/modes/components/mcp-add-wizard.ts +1 -1
- package/src/modes/components/model-selector.ts +1 -1
- package/src/modes/components/oauth-selector.ts +1 -1
- package/src/modes/components/plugin-settings.ts +1 -1
- package/src/modes/components/python-execution.ts +51 -91
- package/src/modes/components/queue-mode-selector.ts +1 -1
- package/src/modes/components/session-selector.ts +1 -1
- package/src/modes/components/settings-defs.ts +5 -10
- package/src/modes/components/settings-selector.ts +1 -1
- package/src/modes/components/show-images-selector.ts +1 -1
- package/src/modes/components/skill-message.ts +4 -4
- package/src/modes/components/status-line/segments.ts +2 -2
- package/src/modes/components/status-line/separators.ts +1 -1
- package/src/modes/components/status-line-segment-editor.ts +1 -1
- package/src/modes/components/status-line.ts +1 -1
- package/src/modes/components/theme-selector.ts +1 -1
- package/src/modes/components/thinking-selector.ts +1 -1
- package/src/modes/components/todo-display.ts +2 -4
- package/src/modes/components/todo-reminder.ts +4 -4
- package/src/modes/components/tool-execution.ts +118 -440
- package/src/modes/components/tool-image-display.ts +107 -0
- package/src/modes/components/tree-selector.ts +2 -2
- package/src/modes/components/ttsr-notification.ts +4 -17
- package/src/modes/components/user-message-selector.ts +1 -1
- package/src/modes/components/user-message.ts +9 -10
- package/src/modes/components/welcome.ts +1 -1
- package/src/modes/controllers/command-controller.ts +1 -1
- package/src/modes/controllers/event-controller.ts +58 -187
- package/src/modes/controllers/extension-ui-controller.ts +1 -1
- package/src/modes/controllers/input-controller.ts +3 -1
- package/src/modes/controllers/mcp-command-controller.ts +1 -1
- package/src/modes/controllers/selector-controller.ts +3 -26
- package/src/modes/controllers/ssh-command-controller.ts +1 -1
- package/src/modes/interactive-mode.ts +3 -7
- package/src/modes/print-mode.ts +5 -5
- package/src/modes/rpc/rpc-mode.ts +1 -1
- package/src/modes/types.ts +1 -2
- package/src/modes/utils/ui-helpers.ts +34 -32
- package/src/patch/edit-tool.ts +742 -0
- package/src/patch/index.ts +32 -898
- package/src/patch/schemas.ts +208 -0
- package/src/patch/shared.ts +83 -151
- package/src/prompts/agents/explore.md +22 -37
- package/src/prompts/agents/init.md +1 -1
- package/src/prompts/agents/librarian.md +29 -20
- package/src/prompts/agents/oracle.md +9 -2
- package/src/prompts/agents/reviewer.md +14 -48
- package/src/prompts/agents/task.md +16 -8
- package/src/prompts/compaction/branch-summary.md +4 -1
- package/src/prompts/compaction/compaction-summary.md +4 -1
- package/src/prompts/system/subagent-system-prompt.md +1 -1
- package/src/prompts/system/system-prompt.md +162 -178
- package/src/prompts/system/verification-reminder.md +6 -0
- package/src/sdk.ts +0 -9
- package/src/session/agent-session.ts +244 -1459
- package/src/session/model-controller.ts +406 -0
- package/src/session/retry-utils.ts +71 -0
- package/src/session/session-manager.ts +22 -186
- package/src/session/session-types.ts +312 -0
- package/src/session/stats.ts +387 -0
- package/src/session/streaming-edit.ts +258 -0
- package/src/session/ttsr.ts +213 -0
- package/src/slash-commands/builtin-registry.ts +0 -8
- package/src/stt/recorder.ts +2 -2
- package/src/system-prompt.ts +1 -14
- package/src/task/agents.ts +7 -33
- package/src/task/executor.ts +50 -438
- package/src/task/index.ts +104 -71
- package/src/task/progress-tracker.ts +390 -0
- package/src/task/render.ts +371 -187
- package/src/task/subprocess-tool-registry.ts +1 -1
- package/src/task/types.ts +14 -47
- package/src/tools/ask.ts +31 -42
- package/src/tools/bash-interactive.ts +2 -2
- package/src/tools/bash-interceptor.ts +2 -2
- package/src/tools/bash-normalize.ts +1 -1
- package/src/tools/bash-skill-urls.ts +2 -2
- package/src/tools/bash.ts +87 -136
- package/src/tools/browser.ts +54 -84
- package/src/tools/create-tools.ts +186 -0
- package/src/tools/default-renderer.ts +104 -0
- package/src/tools/explore.ts +11 -10
- package/src/tools/fetch.ts +24 -114
- package/src/tools/find.ts +48 -132
- package/src/tools/gemini-image.ts +5 -15
- package/src/tools/github.ts +450 -0
- package/src/tools/grep.ts +43 -179
- package/src/tools/index.ts +35 -198
- package/src/tools/json-tree.ts +3 -3
- package/src/tools/librarian.ts +18 -18
- package/src/tools/list-limit.ts +2 -2
- package/src/tools/notebook.ts +35 -87
- package/src/tools/oracle.ts +25 -25
- package/src/tools/output-meta.ts +89 -4
- package/src/tools/output-utils.ts +2 -2
- package/src/tools/python.ts +86 -637
- package/src/tools/read.ts +36 -119
- package/src/tools/reviewer-tool.ts +19 -21
- package/src/tools/search-code.ts +128 -0
- package/src/tools/ssh.ts +67 -126
- package/src/tools/subagent-tool.ts +197 -123
- package/src/tools/todo-write.ts +15 -31
- package/src/tools/tool-errors.ts +0 -30
- package/src/tools/undo-edit.ts +30 -67
- package/src/tools/write.ts +78 -127
- package/src/tui/code-cell.ts +4 -4
- package/src/tui/file-list.ts +2 -2
- package/src/tui/output-block.ts +1 -1
- package/src/tui/status-line.ts +1 -1
- package/src/tui/tree-list.ts +2 -2
- package/src/tui/types.ts +1 -1
- package/src/tui/utils.ts +1 -1
- package/src/{tools → ui}/render-utils.ts +87 -126
- package/src/utils/external-editor.ts +4 -4
- package/src/utils/file-mentions.ts +1 -1
- package/src/utils/index.ts +30 -0
- package/src/utils/tools-manager.ts +9 -19
- package/src/web/github-client.ts +290 -0
- package/src/web/scrapers/github.ts +11 -62
- package/src/web/search/auth.ts +1 -3
- package/src/web/search/index.ts +82 -46
- package/src/web/search/provider.ts +11 -16
- package/src/web/search/providers/grep.ts +160 -0
- package/src/web/search/render.ts +48 -235
- package/src/web/search/types.ts +1 -1
- package/src/commands/commit.ts +0 -36
- package/src/commit/agentic/agent.ts +0 -311
- package/src/commit/agentic/fallback.ts +0 -96
- package/src/commit/agentic/index.ts +0 -359
- package/src/commit/agentic/prompts/analyze-file.md +0 -22
- package/src/commit/agentic/prompts/session-user.md +0 -25
- package/src/commit/agentic/prompts/split-confirm.md +0 -1
- package/src/commit/agentic/prompts/system.md +0 -38
- package/src/commit/agentic/state.ts +0 -69
- package/src/commit/agentic/tools/analyze-file.ts +0 -118
- package/src/commit/agentic/tools/git-file-diff.ts +0 -194
- package/src/commit/agentic/tools/git-hunk.ts +0 -50
- package/src/commit/agentic/tools/git-overview.ts +0 -84
- package/src/commit/agentic/tools/index.ts +0 -56
- package/src/commit/agentic/tools/propose-changelog.ts +0 -128
- package/src/commit/agentic/tools/propose-commit.ts +0 -154
- package/src/commit/agentic/tools/recent-commits.ts +0 -81
- package/src/commit/agentic/tools/split-commit.ts +0 -280
- package/src/commit/agentic/topo-sort.ts +0 -44
- package/src/commit/agentic/trivial.ts +0 -51
- package/src/commit/agentic/validation.ts +0 -200
- package/src/commit/analysis/conventional.ts +0 -165
- package/src/commit/analysis/index.ts +0 -4
- package/src/commit/analysis/scope.ts +0 -242
- package/src/commit/analysis/summary.ts +0 -112
- package/src/commit/analysis/validation.ts +0 -66
- package/src/commit/changelog/detect.ts +0 -37
- package/src/commit/changelog/generate.ts +0 -110
- package/src/commit/changelog/index.ts +0 -234
- package/src/commit/changelog/parse.ts +0 -44
- package/src/commit/cli.ts +0 -93
- package/src/commit/git/diff.ts +0 -148
- package/src/commit/git/errors.ts +0 -9
- package/src/commit/git/index.ts +0 -211
- package/src/commit/git/operations.ts +0 -54
- package/src/commit/index.ts +0 -5
- package/src/commit/map-reduce/index.ts +0 -64
- package/src/commit/map-reduce/map-phase.ts +0 -178
- package/src/commit/map-reduce/reduce-phase.ts +0 -145
- package/src/commit/map-reduce/utils.ts +0 -9
- package/src/commit/message.ts +0 -11
- package/src/commit/model-selection.ts +0 -69
- package/src/commit/pipeline.ts +0 -243
- package/src/commit/prompts/analysis-system.md +0 -148
- package/src/commit/prompts/analysis-user.md +0 -38
- package/src/commit/prompts/changelog-system.md +0 -50
- package/src/commit/prompts/changelog-user.md +0 -18
- package/src/commit/prompts/file-observer-system.md +0 -24
- package/src/commit/prompts/file-observer-user.md +0 -8
- package/src/commit/prompts/reduce-system.md +0 -50
- package/src/commit/prompts/reduce-user.md +0 -17
- package/src/commit/prompts/summary-retry.md +0 -3
- package/src/commit/prompts/summary-system.md +0 -38
- package/src/commit/prompts/summary-user.md +0 -13
- package/src/commit/prompts/types-description.md +0 -2
- package/src/commit/types.ts +0 -109
- package/src/commit/utils/exclusions.ts +0 -42
- package/src/mcp/render.ts +0 -123
- package/src/modes/components/agent-dashboard.ts +0 -1130
- package/src/modes/components/codemode-group.ts +0 -369
- package/src/modes/components/read-tool-group.ts +0 -119
- package/src/modes/components/visual-truncate.ts +0 -63
- package/src/prompts/system/subagent-user-prompt.md +0 -8
- package/src/prompts/tools/ask.md +0 -44
- package/src/prompts/tools/bash.md +0 -24
- package/src/prompts/tools/browser.md +0 -33
- package/src/prompts/tools/calculator.md +0 -12
- package/src/prompts/tools/explore.md +0 -29
- package/src/prompts/tools/fetch.md +0 -16
- package/src/prompts/tools/find.md +0 -18
- package/src/prompts/tools/gemini-image.md +0 -23
- package/src/prompts/tools/grep.md +0 -28
- package/src/prompts/tools/hashline.md +0 -232
- package/src/prompts/tools/librarian.md +0 -24
- package/src/prompts/tools/lsp.md +0 -28
- package/src/prompts/tools/oracle.md +0 -26
- package/src/prompts/tools/patch.md +0 -74
- package/src/prompts/tools/python.md +0 -66
- package/src/prompts/tools/read.md +0 -36
- package/src/prompts/tools/replace.md +0 -38
- package/src/prompts/tools/reviewer.md +0 -41
- package/src/prompts/tools/ssh.md +0 -51
- package/src/prompts/tools/task-summary.md +0 -28
- package/src/prompts/tools/task.md +0 -146
- package/src/prompts/tools/todo-write.md +0 -65
- package/src/prompts/tools/undo-edit.md +0 -7
- package/src/prompts/tools/web-search.md +0 -19
- package/src/prompts/tools/write.md +0 -18
- package/src/task/batch.ts +0 -102
- package/src/task/discovery.ts +0 -126
- package/src/task/parallel.ts +0 -84
- package/src/task/template.ts +0 -32
- package/src/tools/calculator.ts +0 -537
- package/src/tools/jtd-to-typescript.ts +0 -198
- package/src/tools/renderers.ts +0 -60
- package/src/tools/tool-result.ts +0 -86
- /package/src/{modes/theme → theme}/dark.json +0 -0
- /package/src/{modes/theme → theme}/defaults/dark-catppuccin.json +0 -0
- /package/src/{modes/theme → theme}/defaults/dark-dracula.json +0 -0
- /package/src/{modes/theme → theme}/defaults/dark-gruvbox.json +0 -0
- /package/src/{modes/theme → theme}/defaults/dark-solarized.json +0 -0
- /package/src/{modes/theme → theme}/defaults/dark-tokyo-night.json +0 -0
- /package/src/{modes/theme → theme}/defaults/index.ts +0 -0
- /package/src/{modes/theme → theme}/defaults/light-catppuccin.json +0 -0
- /package/src/{modes/theme → theme}/defaults/light-github.json +0 -0
- /package/src/{modes/theme → theme}/defaults/light-solarized.json +0 -0
- /package/src/{modes/theme → theme}/light.json +0 -0
- /package/src/{modes/theme → theme}/mermaid-cache.ts +0 -0
- /package/src/{modes/theme → theme}/theme-schema.json +0 -0
- /package/src/{modes/theme → theme}/theme.ts +0 -0
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert JSON Type Definition (JTD) to TypeScript interface notation.
|
|
3
|
-
*
|
|
4
|
-
* Produces human-readable TypeScript for embedding in system prompts,
|
|
5
|
-
* helping models understand expected output structure.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
type JTDPrimitive =
|
|
9
|
-
| "boolean"
|
|
10
|
-
| "string"
|
|
11
|
-
| "timestamp"
|
|
12
|
-
| "float32"
|
|
13
|
-
| "float64"
|
|
14
|
-
| "int8"
|
|
15
|
-
| "uint8"
|
|
16
|
-
| "int16"
|
|
17
|
-
| "uint16"
|
|
18
|
-
| "int32"
|
|
19
|
-
| "uint32";
|
|
20
|
-
|
|
21
|
-
interface JTDType {
|
|
22
|
-
type: JTDPrimitive;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface JTDEnum {
|
|
26
|
-
enum: string[];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface JTDElements {
|
|
30
|
-
elements: JTDSchema;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface JTDValues {
|
|
34
|
-
values: JTDSchema;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
interface JTDProperties {
|
|
38
|
-
properties?: Record<string, JTDSchema>;
|
|
39
|
-
optionalProperties?: Record<string, JTDSchema>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface JTDDiscriminator {
|
|
43
|
-
discriminator: string;
|
|
44
|
-
mapping: Record<string, JTDProperties>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface JTDRef {
|
|
48
|
-
ref: string;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
type JTDSchema = JTDType | JTDEnum | JTDElements | JTDValues | JTDProperties | JTDDiscriminator | JTDRef | object;
|
|
52
|
-
|
|
53
|
-
const primitiveMap: Record<JTDPrimitive, string> = {
|
|
54
|
-
boolean: "boolean",
|
|
55
|
-
string: "string",
|
|
56
|
-
timestamp: "string",
|
|
57
|
-
float32: "number",
|
|
58
|
-
float64: "number",
|
|
59
|
-
int8: "number",
|
|
60
|
-
uint8: "number",
|
|
61
|
-
int16: "number",
|
|
62
|
-
uint16: "number",
|
|
63
|
-
int32: "number",
|
|
64
|
-
uint32: "number",
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
function isJTDType(schema: unknown): schema is JTDType {
|
|
68
|
-
return typeof schema === "object" && schema !== null && "type" in schema;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function isJTDEnum(schema: unknown): schema is JTDEnum {
|
|
72
|
-
return typeof schema === "object" && schema !== null && "enum" in schema && Array.isArray((schema as JTDEnum).enum);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function isJTDElements(schema: unknown): schema is JTDElements {
|
|
76
|
-
return typeof schema === "object" && schema !== null && "elements" in schema;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function isJTDValues(schema: unknown): schema is JTDValues {
|
|
80
|
-
return typeof schema === "object" && schema !== null && "values" in schema;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function isJTDProperties(schema: unknown): schema is JTDProperties {
|
|
84
|
-
return typeof schema === "object" && schema !== null && ("properties" in schema || "optionalProperties" in schema);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function isJTDDiscriminator(schema: unknown): schema is JTDDiscriminator {
|
|
88
|
-
return typeof schema === "object" && schema !== null && "discriminator" in schema && "mapping" in schema;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function isJTDRef(schema: unknown): schema is JTDRef {
|
|
92
|
-
return typeof schema === "object" && schema !== null && "ref" in schema;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function convertToTypeScript(schema: unknown, inline = false): string {
|
|
96
|
-
if (schema === null || schema === undefined || (typeof schema === "object" && Object.keys(schema).length === 0)) {
|
|
97
|
-
return "unknown";
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (isJTDType(schema)) {
|
|
101
|
-
const tsType = primitiveMap[schema.type as JTDPrimitive];
|
|
102
|
-
return tsType ?? "unknown";
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (isJTDEnum(schema)) {
|
|
106
|
-
return schema.enum.map(v => `"${v}"`).join(" | ");
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (isJTDElements(schema)) {
|
|
110
|
-
const itemType = convertToTypeScript(schema.elements, true);
|
|
111
|
-
if (itemType.includes("\n") || itemType.length > 40) {
|
|
112
|
-
return `Array<${itemType}>`;
|
|
113
|
-
}
|
|
114
|
-
return `${itemType}[]`;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (isJTDValues(schema)) {
|
|
118
|
-
const valueType = convertToTypeScript(schema.values, true);
|
|
119
|
-
return `Record<string, ${valueType}>`;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (isJTDProperties(schema)) {
|
|
123
|
-
const lines: string[] = [];
|
|
124
|
-
lines.push("{");
|
|
125
|
-
|
|
126
|
-
if (schema.properties) {
|
|
127
|
-
for (const [key, value] of Object.entries(schema.properties)) {
|
|
128
|
-
const propType = convertToTypeScript(value, true);
|
|
129
|
-
const safeName = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? key : `"${key}"`;
|
|
130
|
-
lines.push(` ${safeName}: ${propType};`);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (schema.optionalProperties) {
|
|
135
|
-
for (const [key, value] of Object.entries(schema.optionalProperties)) {
|
|
136
|
-
const propType = convertToTypeScript(value, true);
|
|
137
|
-
const safeName = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? key : `"${key}"`;
|
|
138
|
-
lines.push(` ${safeName}?: ${propType};`);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
lines.push("}");
|
|
143
|
-
|
|
144
|
-
if (inline && lines.length <= 4) {
|
|
145
|
-
// Compact single-line for small objects
|
|
146
|
-
const props = lines.slice(1, -1).map(l => l.trim());
|
|
147
|
-
if (props.join(" ").length < 60) {
|
|
148
|
-
return `{ ${props.join(" ")} }`;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return lines.join("\n");
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (isJTDDiscriminator(schema)) {
|
|
156
|
-
const variants: string[] = [];
|
|
157
|
-
for (const [tag, props] of Object.entries(schema.mapping)) {
|
|
158
|
-
const propsType = convertToTypeScript(props, true);
|
|
159
|
-
if (propsType === "{}") {
|
|
160
|
-
variants.push(`{ ${schema.discriminator}: "${tag}" }`);
|
|
161
|
-
} else {
|
|
162
|
-
// Merge discriminator into props
|
|
163
|
-
const inner = propsType.slice(1, -1).trim();
|
|
164
|
-
variants.push(`{ ${schema.discriminator}: "${tag}"; ${inner} }`);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return variants.join(" | ");
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (isJTDRef(schema)) {
|
|
171
|
-
return schema.ref;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return "unknown";
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Convert JTD schema to TypeScript interface string.
|
|
179
|
-
*
|
|
180
|
-
* @example
|
|
181
|
-
* ```ts
|
|
182
|
-
* const schema = {
|
|
183
|
-
* properties: {
|
|
184
|
-
* name: { type: "string" },
|
|
185
|
-
* count: { type: "int32" }
|
|
186
|
-
* }
|
|
187
|
-
* };
|
|
188
|
-
* jtdToTypeScript(schema);
|
|
189
|
-
* // Returns:
|
|
190
|
-
* // {
|
|
191
|
-
* // name: string;
|
|
192
|
-
* // count: number;
|
|
193
|
-
* // }
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
export function jtdToTypeScript(schema: unknown): string {
|
|
197
|
-
return convertToTypeScript(schema, false);
|
|
198
|
-
}
|
package/src/tools/renderers.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TUI renderers for built-in tools.
|
|
3
|
-
*
|
|
4
|
-
* These provide rich visualization for tool calls and results in the TUI.
|
|
5
|
-
*/
|
|
6
|
-
import type { Component } from "@nghyane/arcane-tui";
|
|
7
|
-
import type { RenderResultOptions } from "../extensibility/custom-tools/types";
|
|
8
|
-
import { lspToolRenderer } from "../lsp/render";
|
|
9
|
-
import type { Theme } from "../modes/theme/theme";
|
|
10
|
-
import { editToolRenderer } from "../patch";
|
|
11
|
-
import { taskToolRenderer } from "../task/render";
|
|
12
|
-
import { webSearchToolRenderer } from "../web/search/render";
|
|
13
|
-
import { askToolRenderer } from "./ask";
|
|
14
|
-
import { bashToolRenderer } from "./bash";
|
|
15
|
-
import { calculatorToolRenderer } from "./calculator";
|
|
16
|
-
import { fetchToolRenderer } from "./fetch";
|
|
17
|
-
import { findToolRenderer } from "./find";
|
|
18
|
-
import { grepToolRenderer } from "./grep";
|
|
19
|
-
import { notebookToolRenderer } from "./notebook";
|
|
20
|
-
import { pythonToolRenderer } from "./python";
|
|
21
|
-
import { readToolRenderer } from "./read";
|
|
22
|
-
import { sshToolRenderer } from "./ssh";
|
|
23
|
-
import { todoWriteToolRenderer } from "./todo-write";
|
|
24
|
-
import { undoEditToolRenderer } from "./undo-edit";
|
|
25
|
-
import { writeToolRenderer } from "./write";
|
|
26
|
-
|
|
27
|
-
type ToolRenderer = {
|
|
28
|
-
renderCall: (args: unknown, options: RenderResultOptions, theme: Theme) => Component;
|
|
29
|
-
renderResult: (
|
|
30
|
-
result: { content: Array<{ type: string; text?: string }>; details?: unknown; isError?: boolean },
|
|
31
|
-
options: RenderResultOptions & { renderContext?: Record<string, unknown> },
|
|
32
|
-
theme: Theme,
|
|
33
|
-
args?: unknown,
|
|
34
|
-
) => Component;
|
|
35
|
-
mergeCallAndResult?: boolean;
|
|
36
|
-
/** Render without background box, inline in the response flow */
|
|
37
|
-
inline?: boolean;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const toolRenderers: Record<string, ToolRenderer> = {
|
|
41
|
-
ask: askToolRenderer as ToolRenderer,
|
|
42
|
-
bash: bashToolRenderer as ToolRenderer,
|
|
43
|
-
python: pythonToolRenderer as ToolRenderer,
|
|
44
|
-
calc: calculatorToolRenderer as ToolRenderer,
|
|
45
|
-
edit: editToolRenderer as ToolRenderer,
|
|
46
|
-
find: findToolRenderer as ToolRenderer,
|
|
47
|
-
grep: grepToolRenderer as ToolRenderer,
|
|
48
|
-
lsp: lspToolRenderer as ToolRenderer,
|
|
49
|
-
notebook: notebookToolRenderer as ToolRenderer,
|
|
50
|
-
read: readToolRenderer as ToolRenderer,
|
|
51
|
-
ssh: sshToolRenderer as ToolRenderer,
|
|
52
|
-
task: taskToolRenderer as ToolRenderer,
|
|
53
|
-
explore: taskToolRenderer as ToolRenderer,
|
|
54
|
-
review: taskToolRenderer as ToolRenderer,
|
|
55
|
-
todo_write: todoWriteToolRenderer as ToolRenderer,
|
|
56
|
-
undo_edit: undoEditToolRenderer as ToolRenderer,
|
|
57
|
-
fetch: fetchToolRenderer as ToolRenderer,
|
|
58
|
-
web_search: webSearchToolRenderer as ToolRenderer,
|
|
59
|
-
write: writeToolRenderer as ToolRenderer,
|
|
60
|
-
};
|
package/src/tools/tool-result.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import type { AgentToolResult } from "@nghyane/arcane-agent";
|
|
2
|
-
import type { ImageContent, TextContent } from "@nghyane/arcane-ai";
|
|
3
|
-
import type { OutputSummary, TruncationResult } from "../session/streaming-output";
|
|
4
|
-
import type { OutputMeta, TruncationOptions, TruncationSummaryOptions, TruncationTextOptions } from "./output-meta";
|
|
5
|
-
import { outputMeta } from "./output-meta";
|
|
6
|
-
|
|
7
|
-
type ToolContent = Array<TextContent | ImageContent>;
|
|
8
|
-
|
|
9
|
-
type DetailsWithMeta = { meta?: OutputMeta };
|
|
10
|
-
|
|
11
|
-
export class ToolResultBuilder<TDetails extends DetailsWithMeta> {
|
|
12
|
-
#details: TDetails;
|
|
13
|
-
#meta = outputMeta();
|
|
14
|
-
#content: ToolContent = [];
|
|
15
|
-
|
|
16
|
-
constructor(details?: TDetails) {
|
|
17
|
-
this.#details = details ?? ({} as TDetails);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
text(text: string): this {
|
|
21
|
-
this.#content = [{ type: "text", text }];
|
|
22
|
-
return this;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
content(content: ToolContent): this {
|
|
26
|
-
this.#content = content;
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
truncation(result: TruncationResult, options: TruncationOptions): this {
|
|
31
|
-
this.#meta.truncation(result, options);
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
truncationFromSummary(summary: OutputSummary, options: TruncationSummaryOptions): this {
|
|
36
|
-
this.#meta.truncationFromSummary(summary, options);
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
truncationFromText(text: string, options: TruncationTextOptions): this {
|
|
41
|
-
this.#meta.truncationFromText(text, options);
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
limits(limits: { matchLimit?: number; resultLimit?: number; headLimit?: number; columnMax?: number }): this {
|
|
46
|
-
this.#meta.limits(limits);
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
sourceUrl(value: string): this {
|
|
51
|
-
this.#meta.sourceUrl(value);
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
sourcePath(value: string): this {
|
|
56
|
-
this.#meta.sourcePath(value);
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
sourceInternal(value: string): this {
|
|
61
|
-
this.#meta.sourceInternal(value);
|
|
62
|
-
return this;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
diagnostics(summary: string, messages: string[]): this {
|
|
66
|
-
this.#meta.diagnostics(summary, messages);
|
|
67
|
-
return this;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
done(): AgentToolResult<TDetails> {
|
|
71
|
-
const meta = this.#meta.get();
|
|
72
|
-
if (meta) {
|
|
73
|
-
this.#details.meta = meta;
|
|
74
|
-
}
|
|
75
|
-
const hasDetails = Object.entries(this.#details).some(([, value]) => value !== undefined);
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
content: this.#content,
|
|
79
|
-
details: hasDetails ? this.#details : undefined,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function toolResult<TDetails extends DetailsWithMeta>(details?: TDetails): ToolResultBuilder<TDetails> {
|
|
85
|
-
return new ToolResultBuilder(details);
|
|
86
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|