bioscode 0.1.5
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/LICENSE +306 -0
- package/NOTICE +45 -0
- package/README.md +277 -0
- package/dist/auth/index.d.ts +202 -0
- package/dist/brand/index.d.ts +7 -0
- package/dist/brand/loader.d.ts +463 -0
- package/dist/brand/rules.d.ts +25 -0
- package/dist/brand/schema.d.ts +246 -0
- package/dist/bus/bus-event.d.ts +10 -0
- package/dist/bus/global.d.ts +7 -0
- package/dist/bus/index.d.ts +26 -0
- package/dist/cli/auth.d.ts +23 -0
- package/dist/cli/brand.d.ts +6 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/ui.d.ts +26 -0
- package/dist/command/index.d.ts +54 -0
- package/dist/config/config.d.ts +6036 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/markdown.d.ts +415 -0
- package/dist/constants/index.d.ts +6 -0
- package/dist/constants/version.d.ts +5 -0
- package/dist/diff/engine.d.ts +15 -0
- package/dist/diff/index.d.ts +8 -0
- package/dist/diff/types.d.ts +66 -0
- package/dist/file/ignore.d.ts +7 -0
- package/dist/flag/index.d.ts +19 -0
- package/dist/gateway/bridge.d.ts +11 -0
- package/dist/gateway/handlers/llm.d.ts +7 -0
- package/dist/gateway/handlers/permission.d.ts +15 -0
- package/dist/gateway/handlers/session.d.ts +7 -0
- package/dist/gateway/handlers/system.d.ts +7 -0
- package/dist/gateway/handlers/tool.d.ts +7 -0
- package/dist/gateway/index.d.ts +18 -0
- package/dist/gateway/protocol.d.ts +159 -0
- package/dist/gateway/router.d.ts +7 -0
- package/dist/gateway/server.d.ts +24 -0
- package/dist/global/index.d.ts +23 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +34 -0
- package/dist/permission/index.d.ts +2 -0
- package/dist/permission/permission.d.ts +172 -0
- package/dist/permission/types.d.ts +109 -0
- package/dist/project/index.d.ts +3 -0
- package/dist/project/instance.d.ts +33 -0
- package/dist/project/project.d.ts +82 -0
- package/dist/project/state.d.ts +4 -0
- package/dist/prompt/index.d.ts +5 -0
- package/dist/prompt/system.d.ts +29 -0
- package/dist/prompt/template.d.ts +24 -0
- package/dist/provider/index.d.ts +3 -0
- package/dist/provider/models.d.ts +14 -0
- package/dist/provider/provider.d.ts +848 -0
- package/dist/provider/types.d.ts +328 -0
- package/dist/server/index.d.ts +21 -0
- package/dist/server/routes/api.d.ts +2 -0
- package/dist/server/routes/auth.d.ts +2 -0
- package/dist/server/routes/events.d.ts +2 -0
- package/dist/server/routes/health.d.ts +2 -0
- package/dist/server/routes/sessions.d.ts +2 -0
- package/dist/server/services/agent.d.ts +40 -0
- package/dist/server/services/permission.d.ts +43 -0
- package/dist/server/sse/emitter.d.ts +57 -0
- package/dist/session/context-cache.d.ts +75 -0
- package/dist/session/context-optimization.d.ts +165 -0
- package/dist/session/index.d.ts +5 -0
- package/dist/session/llm.d.ts +68 -0
- package/dist/session/message-optimizer.d.ts +32 -0
- package/dist/session/session.d.ts +524 -0
- package/dist/session/title-generator.d.ts +11 -0
- package/dist/session/types.d.ts +713 -0
- package/dist/snapshot/index.d.ts +40 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/storage.d.ts +34 -0
- package/dist/theme.d.ts +64 -0
- package/dist/tool/bash.d.ts +19 -0
- package/dist/tool/edit.d.ts +21 -0
- package/dist/tool/glob.d.ts +15 -0
- package/dist/tool/grep.d.ts +20 -0
- package/dist/tool/image.d.ts +22 -0
- package/dist/tool/index.d.ts +11 -0
- package/dist/tool/ls.d.ts +14 -0
- package/dist/tool/read.d.ts +17 -0
- package/dist/tool/registry.d.ts +30 -0
- package/dist/tool/think.d.ts +11 -0
- package/dist/tool/todo.d.ts +76 -0
- package/dist/tool/tool.d.ts +65 -0
- package/dist/tool/webfetch.d.ts +15 -0
- package/dist/tool/write.d.ts +16 -0
- package/dist/tui/App.d.ts +10 -0
- package/dist/tui/components/Header.d.ts +13 -0
- package/dist/tui/components/LoadingIndicator.d.ts +26 -0
- package/dist/tui/components/Message/AssistantMessage.d.ts +11 -0
- package/dist/tui/components/Message/ReasoningMessage.d.ts +21 -0
- package/dist/tui/components/Message/ToolCallMessage.d.ts +26 -0
- package/dist/tui/components/Message/UserMessage.d.ts +12 -0
- package/dist/tui/components/Message/index.d.ts +16 -0
- package/dist/tui/components/PermissionPrompt.d.ts +6 -0
- package/dist/tui/components/PromptInput.d.ts +33 -0
- package/dist/tui/components/REPL.d.ts +22 -0
- package/dist/tui/components/Spinner.d.ts +13 -0
- package/dist/tui/components/StatusBar.d.ts +13 -0
- package/dist/tui/components/TodoList.d.ts +17 -0
- package/dist/tui/components/WelcomeBox.d.ts +13 -0
- package/dist/tui/components/dialogs/DiagnosticsPanel.d.ts +12 -0
- package/dist/tui/components/dialogs/HelpPanel.d.ts +11 -0
- package/dist/tui/components/dialogs/ModelSelector.d.ts +14 -0
- package/dist/tui/components/dialogs/PermissionPrompt.d.ts +17 -0
- package/dist/tui/components/dialogs/SessionPicker.d.ts +20 -0
- package/dist/tui/components/dialogs/index.d.ts +10 -0
- package/dist/tui/components/diff/DiffHunk.d.ts +12 -0
- package/dist/tui/components/diff/DiffLine.d.ts +14 -0
- package/dist/tui/components/diff/DiffStats.d.ts +12 -0
- package/dist/tui/components/diff/DiffView.d.ts +15 -0
- package/dist/tui/components/diff/index.d.ts +9 -0
- package/dist/tui/hooks/useAnimatedLabel.d.ts +12 -0
- package/dist/tui/hooks/usePermission.d.ts +34 -0
- package/dist/tui/hooks/useTermWidth.d.ts +13 -0
- package/dist/tui/index.d.ts +20 -0
- package/dist/tui/theme.d.ts +8 -0
- package/dist/tui/utils/Cursor.d.ts +37 -0
- package/dist/tui/utils/clipboard.d.ts +3 -0
- package/dist/tui/utils/keypress.d.ts +39 -0
- package/dist/tui/utils/markdown.d.ts +13 -0
- package/dist/tui/utils/openContent.d.ts +22 -0
- package/dist/util/ascii.d.ts +22 -0
- package/dist/util/bell.d.ts +14 -0
- package/dist/util/color.d.ts +28 -0
- package/dist/util/context.d.ts +10 -0
- package/dist/util/debug.d.ts +51 -0
- package/dist/util/error.d.ts +294 -0
- package/dist/util/example-commands.d.ts +18 -0
- package/dist/util/filesystem.d.ts +17 -0
- package/dist/util/id.d.ts +24 -0
- package/dist/util/iife.d.ts +1 -0
- package/dist/util/index.d.ts +7 -0
- package/dist/util/lazy.d.ts +1 -0
- package/dist/util/log.d.ts +26 -0
- package/dist/util/paths.d.ts +45 -0
- package/dist/util/shell.d.ts +36 -0
- package/dist/util/timeout.d.ts +1 -0
- package/dist/util/wildcard.d.ts +8 -0
- package/package.json +87 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import type { PermissionRequest, PermissionResponse, ToolPermissions } from "./types";
|
|
3
|
+
export type PermissionMode = "auto" | "ask" | "plan";
|
|
4
|
+
export declare namespace Permission {
|
|
5
|
+
/**
|
|
6
|
+
* Load allowed patterns from config file
|
|
7
|
+
*/
|
|
8
|
+
function loadPatterns(): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Set the current permission mode
|
|
11
|
+
* Clears session-scoped remembered permissions but keeps permanent ones
|
|
12
|
+
*/
|
|
13
|
+
function setMode(mode: PermissionMode): void;
|
|
14
|
+
/**
|
|
15
|
+
* Get the current permission mode
|
|
16
|
+
*/
|
|
17
|
+
function getMode(): PermissionMode;
|
|
18
|
+
/**
|
|
19
|
+
* Permission events
|
|
20
|
+
*/
|
|
21
|
+
const Event: {
|
|
22
|
+
Request: {
|
|
23
|
+
type: "permission.request";
|
|
24
|
+
properties: z.ZodObject<{
|
|
25
|
+
request: z.ZodType<{
|
|
26
|
+
id: string;
|
|
27
|
+
tool: string;
|
|
28
|
+
action: string;
|
|
29
|
+
description: string;
|
|
30
|
+
risk: "low" | "medium" | "high";
|
|
31
|
+
details?: Record<string, any> | undefined;
|
|
32
|
+
}, z.ZodTypeDef, {
|
|
33
|
+
id: string;
|
|
34
|
+
tool: string;
|
|
35
|
+
action: string;
|
|
36
|
+
description: string;
|
|
37
|
+
risk: "low" | "medium" | "high";
|
|
38
|
+
details?: Record<string, any> | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
request: {
|
|
42
|
+
id: string;
|
|
43
|
+
tool: string;
|
|
44
|
+
action: string;
|
|
45
|
+
description: string;
|
|
46
|
+
risk: "low" | "medium" | "high";
|
|
47
|
+
details?: Record<string, any> | undefined;
|
|
48
|
+
};
|
|
49
|
+
}, {
|
|
50
|
+
request: {
|
|
51
|
+
id: string;
|
|
52
|
+
tool: string;
|
|
53
|
+
action: string;
|
|
54
|
+
description: string;
|
|
55
|
+
risk: "low" | "medium" | "high";
|
|
56
|
+
details?: Record<string, any> | undefined;
|
|
57
|
+
};
|
|
58
|
+
}>;
|
|
59
|
+
};
|
|
60
|
+
Response: {
|
|
61
|
+
type: "permission.response";
|
|
62
|
+
properties: z.ZodObject<{
|
|
63
|
+
response: z.ZodType<{
|
|
64
|
+
id: string;
|
|
65
|
+
granted: boolean;
|
|
66
|
+
remember: boolean;
|
|
67
|
+
}, z.ZodTypeDef, {
|
|
68
|
+
id: string;
|
|
69
|
+
granted: boolean;
|
|
70
|
+
remember: boolean;
|
|
71
|
+
}>;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
response: {
|
|
74
|
+
id: string;
|
|
75
|
+
granted: boolean;
|
|
76
|
+
remember: boolean;
|
|
77
|
+
};
|
|
78
|
+
}, {
|
|
79
|
+
response: {
|
|
80
|
+
id: string;
|
|
81
|
+
granted: boolean;
|
|
82
|
+
remember: boolean;
|
|
83
|
+
};
|
|
84
|
+
}>;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Get effective permissions based on current mode and config
|
|
89
|
+
*/
|
|
90
|
+
function getPermissions(): Promise<ToolPermissions>;
|
|
91
|
+
/**
|
|
92
|
+
* Check if a file path is within the project directory
|
|
93
|
+
*/
|
|
94
|
+
function isInProject(filepath: string): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Check permission for file edit
|
|
97
|
+
*/
|
|
98
|
+
function checkEdit(filepath: string): Promise<boolean>;
|
|
99
|
+
/**
|
|
100
|
+
* Check permission for file write
|
|
101
|
+
*/
|
|
102
|
+
function checkWrite(filepath: string): Promise<boolean>;
|
|
103
|
+
/**
|
|
104
|
+
* Check permission for bash command
|
|
105
|
+
*
|
|
106
|
+
* Bash commands are ALWAYS validated against stored patterns,
|
|
107
|
+
* regardless of permission mode. This ensures security even in auto mode.
|
|
108
|
+
*/
|
|
109
|
+
function checkBash(command: string): Promise<boolean>;
|
|
110
|
+
/**
|
|
111
|
+
* Check permission for web fetch
|
|
112
|
+
*/
|
|
113
|
+
function checkWebFetch(url: string): Promise<boolean>;
|
|
114
|
+
/**
|
|
115
|
+
* Respond to a permission request (called by UI)
|
|
116
|
+
*/
|
|
117
|
+
function respond(response: PermissionResponse): void;
|
|
118
|
+
/**
|
|
119
|
+
* Grant a pending permission request
|
|
120
|
+
*/
|
|
121
|
+
function grant(id: string, remember?: boolean): void;
|
|
122
|
+
/**
|
|
123
|
+
* Deny a pending permission request
|
|
124
|
+
*/
|
|
125
|
+
function deny(id: string, remember?: boolean): void;
|
|
126
|
+
/**
|
|
127
|
+
* Clear remembered permissions
|
|
128
|
+
*/
|
|
129
|
+
function clearRemembered(): void;
|
|
130
|
+
/**
|
|
131
|
+
* Clear all permissions (remembered and permanent)
|
|
132
|
+
* Also resets the patterns loaded flag for testing
|
|
133
|
+
*/
|
|
134
|
+
function clearAll(): void;
|
|
135
|
+
/**
|
|
136
|
+
* Get all pending permission requests
|
|
137
|
+
*/
|
|
138
|
+
function getPending(): PermissionRequest[];
|
|
139
|
+
/**
|
|
140
|
+
* Get all permanent permissions (allowed patterns)
|
|
141
|
+
*/
|
|
142
|
+
function getPermanentPermissions(): string[];
|
|
143
|
+
/**
|
|
144
|
+
* Grant a permission permanently for a pattern
|
|
145
|
+
* Saves the pattern to the project config file
|
|
146
|
+
*/
|
|
147
|
+
function grantPermanent(id: string, pattern: string): void;
|
|
148
|
+
/**
|
|
149
|
+
* Deny a permission permanently for a pattern
|
|
150
|
+
* Saves the pattern to the project config file
|
|
151
|
+
*/
|
|
152
|
+
function denyPermanent(id: string, pattern: string): void;
|
|
153
|
+
/**
|
|
154
|
+
* Match a permission key against a pattern
|
|
155
|
+
* Supports wildcards: * matches one segment, ** matches any depth
|
|
156
|
+
*/
|
|
157
|
+
function matchPermissionPattern(key: string, pattern: string): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Generate a permission key for a tool and target
|
|
160
|
+
*/
|
|
161
|
+
function generatePermissionKey(tool: string, target: string): string;
|
|
162
|
+
/**
|
|
163
|
+
* Infer a pattern from a tool and target
|
|
164
|
+
* Returns a reasonable pattern that could be used for "allow always"
|
|
165
|
+
*/
|
|
166
|
+
function inferPattern(tool: string, target: string): string;
|
|
167
|
+
/**
|
|
168
|
+
* Suggest possible patterns for a tool and target
|
|
169
|
+
* Returns patterns from most specific to least specific
|
|
170
|
+
*/
|
|
171
|
+
function suggestPatterns(tool: string, target: string): string[];
|
|
172
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Permission System Types
|
|
4
|
+
*
|
|
5
|
+
* Defines permission levels and rules for tool execution.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Permission level for an action
|
|
9
|
+
*/
|
|
10
|
+
export declare const PermissionLevel: z.ZodEnum<["allow", "ask", "deny"]>;
|
|
11
|
+
export type PermissionLevel = z.infer<typeof PermissionLevel>;
|
|
12
|
+
/**
|
|
13
|
+
* Permission rule with optional pattern matching
|
|
14
|
+
*/
|
|
15
|
+
export declare const PermissionRule: z.ZodObject<{
|
|
16
|
+
pattern: z.ZodString;
|
|
17
|
+
level: z.ZodEnum<["allow", "ask", "deny"]>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
pattern: string;
|
|
20
|
+
level: "ask" | "allow" | "deny";
|
|
21
|
+
}, {
|
|
22
|
+
pattern: string;
|
|
23
|
+
level: "ask" | "allow" | "deny";
|
|
24
|
+
}>;
|
|
25
|
+
export type PermissionRule = z.infer<typeof PermissionRule>;
|
|
26
|
+
/**
|
|
27
|
+
* Tool-specific permissions
|
|
28
|
+
*/
|
|
29
|
+
export declare const ToolPermissions: z.ZodObject<{
|
|
30
|
+
edit: z.ZodDefault<z.ZodEnum<["allow", "ask", "deny"]>>;
|
|
31
|
+
write: z.ZodDefault<z.ZodEnum<["allow", "ask", "deny"]>>;
|
|
32
|
+
bash: z.ZodDefault<z.ZodUnion<[z.ZodEnum<["allow", "ask", "deny"]>, z.ZodRecord<z.ZodString, z.ZodEnum<["allow", "ask", "deny"]>>]>>;
|
|
33
|
+
webfetch: z.ZodDefault<z.ZodEnum<["allow", "ask", "deny"]>>;
|
|
34
|
+
externalDirectory: z.ZodDefault<z.ZodEnum<["allow", "ask", "deny"]>>;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
write: "ask" | "allow" | "deny";
|
|
37
|
+
bash: "ask" | "allow" | "deny" | Record<string, "ask" | "allow" | "deny">;
|
|
38
|
+
edit: "ask" | "allow" | "deny";
|
|
39
|
+
webfetch: "ask" | "allow" | "deny";
|
|
40
|
+
externalDirectory: "ask" | "allow" | "deny";
|
|
41
|
+
}, {
|
|
42
|
+
write?: "ask" | "allow" | "deny" | undefined;
|
|
43
|
+
bash?: "ask" | "allow" | "deny" | Record<string, "ask" | "allow" | "deny"> | undefined;
|
|
44
|
+
edit?: "ask" | "allow" | "deny" | undefined;
|
|
45
|
+
webfetch?: "ask" | "allow" | "deny" | undefined;
|
|
46
|
+
externalDirectory?: "ask" | "allow" | "deny" | undefined;
|
|
47
|
+
}>;
|
|
48
|
+
export type ToolPermissions = z.infer<typeof ToolPermissions>;
|
|
49
|
+
/**
|
|
50
|
+
* Stored allowed patterns for bash commands
|
|
51
|
+
* Persisted to project-level config file
|
|
52
|
+
*/
|
|
53
|
+
export declare const AllowedPatterns: z.ZodObject<{
|
|
54
|
+
bash: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
55
|
+
edit: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
56
|
+
write: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
write: string[];
|
|
59
|
+
bash: string[];
|
|
60
|
+
edit: string[];
|
|
61
|
+
}, {
|
|
62
|
+
write?: string[] | undefined;
|
|
63
|
+
bash?: string[] | undefined;
|
|
64
|
+
edit?: string[] | undefined;
|
|
65
|
+
}>;
|
|
66
|
+
export type AllowedPatterns = z.infer<typeof AllowedPatterns>;
|
|
67
|
+
/**
|
|
68
|
+
* Permission request for user confirmation
|
|
69
|
+
*/
|
|
70
|
+
export declare const PermissionRequest: z.ZodObject<{
|
|
71
|
+
id: z.ZodString;
|
|
72
|
+
tool: z.ZodString;
|
|
73
|
+
action: z.ZodString;
|
|
74
|
+
description: z.ZodString;
|
|
75
|
+
risk: z.ZodDefault<z.ZodEnum<["low", "medium", "high"]>>;
|
|
76
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
id: string;
|
|
79
|
+
tool: string;
|
|
80
|
+
action: string;
|
|
81
|
+
description: string;
|
|
82
|
+
risk: "low" | "medium" | "high";
|
|
83
|
+
details?: Record<string, any> | undefined;
|
|
84
|
+
}, {
|
|
85
|
+
id: string;
|
|
86
|
+
tool: string;
|
|
87
|
+
action: string;
|
|
88
|
+
description: string;
|
|
89
|
+
risk?: "low" | "medium" | "high" | undefined;
|
|
90
|
+
details?: Record<string, any> | undefined;
|
|
91
|
+
}>;
|
|
92
|
+
export type PermissionRequest = z.infer<typeof PermissionRequest>;
|
|
93
|
+
/**
|
|
94
|
+
* Permission response from user
|
|
95
|
+
*/
|
|
96
|
+
export declare const PermissionResponse: z.ZodObject<{
|
|
97
|
+
id: z.ZodString;
|
|
98
|
+
granted: z.ZodBoolean;
|
|
99
|
+
remember: z.ZodDefault<z.ZodBoolean>;
|
|
100
|
+
}, "strip", z.ZodTypeAny, {
|
|
101
|
+
id: string;
|
|
102
|
+
granted: boolean;
|
|
103
|
+
remember: boolean;
|
|
104
|
+
}, {
|
|
105
|
+
id: string;
|
|
106
|
+
granted: boolean;
|
|
107
|
+
remember?: boolean | undefined;
|
|
108
|
+
}>;
|
|
109
|
+
export type PermissionResponse = z.infer<typeof PermissionResponse>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Project } from "./project";
|
|
2
|
+
export declare const Instance: {
|
|
3
|
+
/**
|
|
4
|
+
* Provide an instance context for a given directory
|
|
5
|
+
* Supports two signatures:
|
|
6
|
+
* 1. { directory, init?, fn } - auto-detects project
|
|
7
|
+
* 2. { project, directory, worktree }, fn - explicit context (for testing)
|
|
8
|
+
*/
|
|
9
|
+
provide<R>(input: {
|
|
10
|
+
directory: string;
|
|
11
|
+
init?: () => Promise<any>;
|
|
12
|
+
fn: () => R;
|
|
13
|
+
} | {
|
|
14
|
+
project: Project.Info;
|
|
15
|
+
directory: string;
|
|
16
|
+
worktree: string;
|
|
17
|
+
}, fn?: () => R): Promise<R>;
|
|
18
|
+
readonly directory: string;
|
|
19
|
+
readonly worktree: string;
|
|
20
|
+
readonly project: {
|
|
21
|
+
id: string;
|
|
22
|
+
worktree: string;
|
|
23
|
+
time: {
|
|
24
|
+
created: number;
|
|
25
|
+
updated: number;
|
|
26
|
+
};
|
|
27
|
+
vcs?: "git" | undefined;
|
|
28
|
+
name?: string | undefined;
|
|
29
|
+
};
|
|
30
|
+
state<S>(init: () => S, dispose?: (state: Awaited<S>) => Promise<void>): () => S;
|
|
31
|
+
dispose(): Promise<void>;
|
|
32
|
+
disposeAll(): Promise<void>;
|
|
33
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
export declare namespace Project {
|
|
3
|
+
const Info: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
worktree: z.ZodString;
|
|
6
|
+
vcs: z.ZodOptional<z.ZodLiteral<"git">>;
|
|
7
|
+
name: z.ZodOptional<z.ZodString>;
|
|
8
|
+
time: z.ZodObject<{
|
|
9
|
+
created: z.ZodNumber;
|
|
10
|
+
updated: z.ZodNumber;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
created: number;
|
|
13
|
+
updated: number;
|
|
14
|
+
}, {
|
|
15
|
+
created: number;
|
|
16
|
+
updated: number;
|
|
17
|
+
}>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
id: string;
|
|
20
|
+
worktree: string;
|
|
21
|
+
time: {
|
|
22
|
+
created: number;
|
|
23
|
+
updated: number;
|
|
24
|
+
};
|
|
25
|
+
vcs?: "git" | undefined;
|
|
26
|
+
name?: string | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
id: string;
|
|
29
|
+
worktree: string;
|
|
30
|
+
time: {
|
|
31
|
+
created: number;
|
|
32
|
+
updated: number;
|
|
33
|
+
};
|
|
34
|
+
vcs?: "git" | undefined;
|
|
35
|
+
name?: string | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
type Info = z.infer<typeof Info>;
|
|
38
|
+
const Event: {
|
|
39
|
+
Updated: {
|
|
40
|
+
type: "project.updated";
|
|
41
|
+
properties: z.ZodObject<{
|
|
42
|
+
id: z.ZodString;
|
|
43
|
+
worktree: z.ZodString;
|
|
44
|
+
vcs: z.ZodOptional<z.ZodLiteral<"git">>;
|
|
45
|
+
name: z.ZodOptional<z.ZodString>;
|
|
46
|
+
time: z.ZodObject<{
|
|
47
|
+
created: z.ZodNumber;
|
|
48
|
+
updated: z.ZodNumber;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
created: number;
|
|
51
|
+
updated: number;
|
|
52
|
+
}, {
|
|
53
|
+
created: number;
|
|
54
|
+
updated: number;
|
|
55
|
+
}>;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
id: string;
|
|
58
|
+
worktree: string;
|
|
59
|
+
time: {
|
|
60
|
+
created: number;
|
|
61
|
+
updated: number;
|
|
62
|
+
};
|
|
63
|
+
vcs?: "git" | undefined;
|
|
64
|
+
name?: string | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
id: string;
|
|
67
|
+
worktree: string;
|
|
68
|
+
time: {
|
|
69
|
+
created: number;
|
|
70
|
+
updated: number;
|
|
71
|
+
};
|
|
72
|
+
vcs?: "git" | undefined;
|
|
73
|
+
name?: string | undefined;
|
|
74
|
+
}>;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
function fromDirectory(directory: string): Promise<Info>;
|
|
78
|
+
/**
|
|
79
|
+
* Alias for fromDirectory for compatibility
|
|
80
|
+
*/
|
|
81
|
+
const detect: typeof fromDirectory;
|
|
82
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { SystemPrompt, type OperationMode } from "./system";
|
|
2
|
+
export { default as PROMPT_TITLE } from "./title.txt";
|
|
3
|
+
export { default as PROMPT_SUMMARY } from "./summary.txt";
|
|
4
|
+
export { default as PROMPT_CONTEXT_OPTIMIZATION } from "./context-optimization.txt";
|
|
5
|
+
export { default as PROMPT_EXPLORE } from "./explore.txt";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System Prompt Management
|
|
3
|
+
*
|
|
4
|
+
* Assembles system prompts from templates, environment info, and custom rules.
|
|
5
|
+
* Different prompts are used based on the model provider for optimal behavior.
|
|
6
|
+
*/
|
|
7
|
+
export type OperationMode = "ask" | "auto" | "plan";
|
|
8
|
+
export declare namespace SystemPrompt {
|
|
9
|
+
/**
|
|
10
|
+
* Get planning mode prompt
|
|
11
|
+
*/
|
|
12
|
+
function forPlanMode(): string[];
|
|
13
|
+
/**
|
|
14
|
+
* Get provider-specific prompt template
|
|
15
|
+
*/
|
|
16
|
+
function forModel(modelId: string): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Get environment context information
|
|
19
|
+
*/
|
|
20
|
+
function environment(): Promise<string[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Load custom rules from PORTER.md files
|
|
23
|
+
*/
|
|
24
|
+
function customRules(): Promise<string[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Assemble complete system prompt for a model
|
|
27
|
+
*/
|
|
28
|
+
function assemble(modelId: string, mode?: OperationMode): Promise<string[]>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Template System
|
|
3
|
+
*
|
|
4
|
+
* Replaces brand placeholders in prompt templates with actual brand values
|
|
5
|
+
*/
|
|
6
|
+
export declare namespace PromptTemplate {
|
|
7
|
+
/**
|
|
8
|
+
* Render a prompt template by replacing brand placeholders
|
|
9
|
+
*
|
|
10
|
+
* Supported placeholders:
|
|
11
|
+
* - {PRODUCT_NAME} - Product name (e.g., "Porter")
|
|
12
|
+
* - {PRODUCT_COMMAND} - Command name (e.g., "porter")
|
|
13
|
+
* - {CONFIG_DIR} - Config directory (e.g., ".porter")
|
|
14
|
+
* - {CONFIG_FILE} - Config file (e.g., "porter.jsonc")
|
|
15
|
+
* - {RULES_FILE} - Rules file (e.g., "PORTER.md")
|
|
16
|
+
* - {ENV_PREFIX} - Environment variable prefix (e.g., "PORTER_")
|
|
17
|
+
*/
|
|
18
|
+
function render(template: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Render a prompt template synchronously
|
|
21
|
+
* @deprecated Use render() instead - it's now synchronous
|
|
22
|
+
*/
|
|
23
|
+
function renderSync(template: string): string;
|
|
24
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ModelInfo, ProviderInfo } from "./types";
|
|
2
|
+
export declare const PROVIDERS: Record<string, ProviderInfo>;
|
|
3
|
+
/**
|
|
4
|
+
* Get all models from a provider
|
|
5
|
+
*/
|
|
6
|
+
export declare function getProviderModels(providerId: string): Record<string, ModelInfo>;
|
|
7
|
+
/**
|
|
8
|
+
* Get a specific model
|
|
9
|
+
*/
|
|
10
|
+
export declare function getModel(providerId: string, modelId: string): ModelInfo | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Get all available models across all providers
|
|
13
|
+
*/
|
|
14
|
+
export declare function getAllModels(): ModelInfo[];
|