@suchitraswain/nightcode-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/nightcode.cjs +10 -0
- package/bin/nightcode.ts +5 -0
- package/package.json +50 -0
- package/src/bootstrap-env.ts +33 -0
- package/src/components/border.tsx +18 -0
- package/src/components/command-menu/commands.tsx +147 -0
- package/src/components/command-menu/filter-commands.ts +8 -0
- package/src/components/command-menu/index.tsx +74 -0
- package/src/components/command-menu/types.ts +20 -0
- package/src/components/command-menu/use-command-menu.ts +113 -0
- package/src/components/dialog-search-list.tsx +127 -0
- package/src/components/dialogs/agents-dialog.tsx +47 -0
- package/src/components/dialogs/index.tsx +4 -0
- package/src/components/dialogs/models-dialog.tsx +41 -0
- package/src/components/dialogs/sessions-dialog.tsx +94 -0
- package/src/components/dialogs/theme-dialog.tsx +58 -0
- package/src/components/header.tsx +10 -0
- package/src/components/input-bar.tsx +611 -0
- package/src/components/messages/bot-message.tsx +160 -0
- package/src/components/messages/error-message.tsx +36 -0
- package/src/components/messages/index.tsx +3 -0
- package/src/components/messages/user-message.tsx +36 -0
- package/src/components/session-shell.tsx +65 -0
- package/src/components/spinner.tsx +14 -0
- package/src/components/status-bar.tsx +23 -0
- package/src/hooks/use-chat.ts +107 -0
- package/src/hosted-config.ts +6 -0
- package/src/index.tsx +29 -0
- package/src/layouts/root-layout.tsx +25 -0
- package/src/layouts/themed-root.tsx +21 -0
- package/src/lib/api-client.ts +25 -0
- package/src/lib/auth.ts +38 -0
- package/src/lib/http-errors.ts +18 -0
- package/src/lib/local-tools.ts +170 -0
- package/src/lib/oauth.ts +166 -0
- package/src/lib/upgrade.ts +27 -0
- package/src/providers/dialog/index.tsx +123 -0
- package/src/providers/dialog/types.ts +6 -0
- package/src/providers/keyboard-layer/index.tsx +98 -0
- package/src/providers/prompt-config/index.tsx +52 -0
- package/src/providers/theme/index.tsx +75 -0
- package/src/providers/toast/index.tsx +118 -0
- package/src/providers/toast/types.ts +9 -0
- package/src/screens/home.tsx +39 -0
- package/src/screens/new-session.tsx +82 -0
- package/src/screens/session.tsx +171 -0
- package/src/theme.ts +568 -0
- package/vendor/shared/api-types.ts +11 -0
- package/vendor/shared/index.ts +20 -0
- package/vendor/shared/models.ts +72 -0
- package/vendor/shared/schemas.ts +87 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { tool } from "ai";
|
|
3
|
+
|
|
4
|
+
export const Mode = {
|
|
5
|
+
BUILD: "BUILD",
|
|
6
|
+
PLAN: "PLAN",
|
|
7
|
+
} as const;
|
|
8
|
+
|
|
9
|
+
export const modeSchema = z.enum([Mode.BUILD, Mode.PLAN]);
|
|
10
|
+
|
|
11
|
+
export type ModeType = (typeof Mode)[keyof typeof Mode];
|
|
12
|
+
|
|
13
|
+
export const toolInputSchemas = {
|
|
14
|
+
readFile: z.object({
|
|
15
|
+
path: z.string().describe("Relative path to the file to read"),
|
|
16
|
+
}),
|
|
17
|
+
listDirectory: z.object({
|
|
18
|
+
path: z.string().default(".").describe("Relative directory path to list"),
|
|
19
|
+
}),
|
|
20
|
+
glob: z.object({
|
|
21
|
+
pattern: z.string().describe("Glob pattern to match files"),
|
|
22
|
+
path: z.string().default(".").describe("Directory to search from"),
|
|
23
|
+
}),
|
|
24
|
+
grep: z.object({
|
|
25
|
+
pattern: z.string().describe("Regex pattern to search for"),
|
|
26
|
+
path: z.string().default(".").describe("Directory to search from"),
|
|
27
|
+
include: z.string().optional().describe("Optional glob for files to include"),
|
|
28
|
+
}),
|
|
29
|
+
writeFile: z.object({
|
|
30
|
+
path: z.string().describe("Relative path to write"),
|
|
31
|
+
content: z.string().describe("File contents"),
|
|
32
|
+
}),
|
|
33
|
+
editFile: z.object({
|
|
34
|
+
path: z.string().describe("Relative path to edit"),
|
|
35
|
+
oldString: z.string().describe("Exact text to replace; must be unique"),
|
|
36
|
+
newString: z.string().describe("Replacement text"),
|
|
37
|
+
}),
|
|
38
|
+
bash: z.object({
|
|
39
|
+
command: z.string().describe("Shell command to run"),
|
|
40
|
+
description: z.string().optional().describe("Short description of the command"),
|
|
41
|
+
timeout: z.number().optional().describe("Timeout in milliseconds"),
|
|
42
|
+
}),
|
|
43
|
+
} as const;
|
|
44
|
+
|
|
45
|
+
export const readOnlyToolContracts = {
|
|
46
|
+
readFile: tool({
|
|
47
|
+
description: "Read a file from the current project directory.",
|
|
48
|
+
inputSchema: toolInputSchemas.readFile,
|
|
49
|
+
}),
|
|
50
|
+
listDirectory: tool({
|
|
51
|
+
description: "List entries in a directory under the current project directory.",
|
|
52
|
+
inputSchema: toolInputSchemas.listDirectory,
|
|
53
|
+
}),
|
|
54
|
+
glob: tool({
|
|
55
|
+
description: "Find files matching a glob pattern under the current project directory.",
|
|
56
|
+
inputSchema: toolInputSchemas.glob,
|
|
57
|
+
}),
|
|
58
|
+
grep: tool({
|
|
59
|
+
description:
|
|
60
|
+
"Search file contents with a regular expression under the current project directory.",
|
|
61
|
+
inputSchema: toolInputSchemas.grep,
|
|
62
|
+
}),
|
|
63
|
+
} as const;
|
|
64
|
+
|
|
65
|
+
export const buildToolContracts = {
|
|
66
|
+
...readOnlyToolContracts,
|
|
67
|
+
writeFile: tool({
|
|
68
|
+
description: "Create or overwrite a file under the current project directory.",
|
|
69
|
+
inputSchema: toolInputSchemas.writeFile,
|
|
70
|
+
}),
|
|
71
|
+
editFile: tool({
|
|
72
|
+
description: "Replace exact text in a file under the current project directory.",
|
|
73
|
+
inputSchema: toolInputSchemas.editFile,
|
|
74
|
+
}),
|
|
75
|
+
bash: tool({
|
|
76
|
+
description: "Run a shell command in the current project directory.",
|
|
77
|
+
inputSchema: toolInputSchemas.bash,
|
|
78
|
+
}),
|
|
79
|
+
} as const;
|
|
80
|
+
|
|
81
|
+
export type ToolContracts = typeof buildToolContracts;
|
|
82
|
+
|
|
83
|
+
export function getToolContracts(mode: ModeType) {
|
|
84
|
+
return mode === Mode.PLAN
|
|
85
|
+
? readOnlyToolContracts
|
|
86
|
+
: buildToolContracts;
|
|
87
|
+
};
|