bashkit 0.1.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/AGENTS.md +442 -0
- package/LICENSE +21 -0
- package/README.md +713 -0
- package/dist/cli/init.d.ts +2 -0
- package/dist/cli/init.js +179 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +1805 -0
- package/dist/middleware/anthropic-cache.d.ts +17 -0
- package/dist/middleware/index.d.ts +1 -0
- package/dist/sandbox/e2b.d.ts +9 -0
- package/dist/sandbox/index.d.ts +4 -0
- package/dist/sandbox/interface.d.ts +21 -0
- package/dist/sandbox/local.d.ts +5 -0
- package/dist/sandbox/vercel.d.ts +13 -0
- package/dist/setup/index.d.ts +2 -0
- package/dist/setup/setup-environment.d.ts +36 -0
- package/dist/setup/types.d.ts +47 -0
- package/dist/skills/discovery.d.ts +9 -0
- package/dist/skills/fetch.d.ts +56 -0
- package/dist/skills/index.d.ts +6 -0
- package/dist/skills/loader.d.ts +11 -0
- package/dist/skills/types.d.ts +29 -0
- package/dist/skills/xml.d.ts +26 -0
- package/dist/tools/bash.d.ts +18 -0
- package/dist/tools/edit.d.ts +16 -0
- package/dist/tools/exit-plan-mode.d.ts +11 -0
- package/dist/tools/glob.d.ts +14 -0
- package/dist/tools/grep.d.ts +42 -0
- package/dist/tools/index.d.ts +45 -0
- package/dist/tools/read.d.ts +25 -0
- package/dist/tools/task.d.ts +50 -0
- package/dist/tools/todo-write.d.ts +28 -0
- package/dist/tools/web-fetch.d.ts +20 -0
- package/dist/tools/web-search.d.ts +24 -0
- package/dist/tools/write.d.ts +14 -0
- package/dist/types.d.ts +32 -0
- package/dist/utils/compact-conversation.d.ts +85 -0
- package/dist/utils/context-status.d.ts +71 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/prune-messages.d.ts +32 -0
- package/package.json +84 -0
package/dist/cli/init.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
4
|
+
|
|
5
|
+
// src/cli/init.ts
|
|
6
|
+
import { confirm, intro, outro, select, spinner } from "@clack/prompts";
|
|
7
|
+
import { execSync } from "child_process";
|
|
8
|
+
import { existsSync, writeFileSync } from "fs";
|
|
9
|
+
import { join } from "path";
|
|
10
|
+
function checkInstalled(pkg) {
|
|
11
|
+
try {
|
|
12
|
+
__require.resolve(pkg, { paths: [process.cwd()] });
|
|
13
|
+
return true;
|
|
14
|
+
} catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function detectPackageManager() {
|
|
19
|
+
const userAgent = process.env.npm_config_user_agent || "";
|
|
20
|
+
if (userAgent.includes("bun"))
|
|
21
|
+
return "bun";
|
|
22
|
+
if (userAgent.includes("yarn"))
|
|
23
|
+
return "yarn";
|
|
24
|
+
if (userAgent.includes("pnpm"))
|
|
25
|
+
return "pnpm";
|
|
26
|
+
return "npm";
|
|
27
|
+
}
|
|
28
|
+
function getInstallCommand(pm) {
|
|
29
|
+
switch (pm) {
|
|
30
|
+
case "bun":
|
|
31
|
+
return "bun add";
|
|
32
|
+
case "yarn":
|
|
33
|
+
return "yarn add";
|
|
34
|
+
case "pnpm":
|
|
35
|
+
return "pnpm add";
|
|
36
|
+
default:
|
|
37
|
+
return "npm install";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function createConfigFile(sandbox, webTools) {
|
|
41
|
+
const configContent = `import { create${sandbox}Sandbox, createAgentTools } from 'bashkit';
|
|
42
|
+
import type { AgentConfig } from 'bashkit';
|
|
43
|
+
|
|
44
|
+
// Create sandbox
|
|
45
|
+
export const sandbox = create${sandbox}Sandbox(${sandbox === "Local" ? `{
|
|
46
|
+
workingDirectory: process.cwd()
|
|
47
|
+
}` : ""});
|
|
48
|
+
|
|
49
|
+
// Configure tools
|
|
50
|
+
export const config: AgentConfig = {${webTools ? `
|
|
51
|
+
webSearch: {
|
|
52
|
+
apiKey: process.env.PARALLEL_API_KEY
|
|
53
|
+
}
|
|
54
|
+
` : ""}};
|
|
55
|
+
|
|
56
|
+
// Create tools
|
|
57
|
+
export const tools = createAgentTools(sandbox${webTools ? ", config" : ""});
|
|
58
|
+
`;
|
|
59
|
+
const configPath = join(process.cwd(), "bashkit.config.ts");
|
|
60
|
+
if (existsSync(configPath)) {
|
|
61
|
+
console.log(`
|
|
62
|
+
⚠️ bashkit.config.ts already exists, skipping creation`);
|
|
63
|
+
} else {
|
|
64
|
+
writeFileSync(configPath, configContent);
|
|
65
|
+
console.log(`
|
|
66
|
+
✅ Created bashkit.config.ts`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function init() {
|
|
70
|
+
intro("\uD83D\uDEE0️ BashKit Setup");
|
|
71
|
+
const hasAI = checkInstalled("ai");
|
|
72
|
+
const hasZod = checkInstalled("zod");
|
|
73
|
+
const hasVercel = checkInstalled("@vercel/sandbox");
|
|
74
|
+
const hasE2B = checkInstalled("@e2b/code-interpreter");
|
|
75
|
+
const hasWeb = checkInstalled("parallel-web");
|
|
76
|
+
console.log(`
|
|
77
|
+
\uD83D\uDCE6 Dependency check:`);
|
|
78
|
+
console.log(` ${hasAI ? "✅" : "❌"} ai`);
|
|
79
|
+
console.log(` ${hasZod ? "✅" : "❌"} zod`);
|
|
80
|
+
console.log(` ${hasVercel ? "✅" : "⚪"} @vercel/sandbox (optional)`);
|
|
81
|
+
console.log(` ${hasE2B ? "✅" : "⚪"} @e2b/code-interpreter (optional)`);
|
|
82
|
+
console.log(` ${hasWeb ? "✅" : "⚪"} parallel-web (optional)`);
|
|
83
|
+
const sandboxChoice = await select({
|
|
84
|
+
message: "Which sandbox environment would you like to use?",
|
|
85
|
+
options: [
|
|
86
|
+
{
|
|
87
|
+
value: "Local",
|
|
88
|
+
label: "LocalSandbox",
|
|
89
|
+
hint: "Bun-based, best for development (no additional deps)"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
value: "Vercel",
|
|
93
|
+
label: "VercelSandbox",
|
|
94
|
+
hint: hasVercel ? "Already installed ✓" : "Production-ready, requires @vercel/sandbox"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
value: "E2B",
|
|
98
|
+
label: "E2BSandbox",
|
|
99
|
+
hint: hasE2B ? "Already installed ✓" : "Hosted execution, requires @e2b/code-interpreter"
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
});
|
|
103
|
+
if (!sandboxChoice || typeof sandboxChoice !== "string") {
|
|
104
|
+
outro("Setup cancelled");
|
|
105
|
+
process.exit(0);
|
|
106
|
+
}
|
|
107
|
+
const webTools = await confirm({
|
|
108
|
+
message: "Enable WebSearch and WebFetch tools?",
|
|
109
|
+
initialValue: hasWeb
|
|
110
|
+
});
|
|
111
|
+
if (typeof webTools !== "boolean") {
|
|
112
|
+
outro("Setup cancelled");
|
|
113
|
+
process.exit(0);
|
|
114
|
+
}
|
|
115
|
+
const toInstall = [];
|
|
116
|
+
if (!hasAI)
|
|
117
|
+
toInstall.push("ai");
|
|
118
|
+
if (!hasZod)
|
|
119
|
+
toInstall.push("zod");
|
|
120
|
+
if (sandboxChoice === "Vercel" && !hasVercel)
|
|
121
|
+
toInstall.push("@vercel/sandbox");
|
|
122
|
+
if (sandboxChoice === "E2B" && !hasE2B)
|
|
123
|
+
toInstall.push("@e2b/code-interpreter");
|
|
124
|
+
if (webTools && !hasWeb)
|
|
125
|
+
toInstall.push("parallel-web");
|
|
126
|
+
if (toInstall.length === 0) {
|
|
127
|
+
console.log(`
|
|
128
|
+
✅ All required dependencies already installed!`);
|
|
129
|
+
} else {
|
|
130
|
+
const pm = detectPackageManager();
|
|
131
|
+
const installCmd = getInstallCommand(pm);
|
|
132
|
+
console.log(`
|
|
133
|
+
\uD83D\uDCE6 Installing missing dependencies: ${toInstall.join(", ")}`);
|
|
134
|
+
console.log(` Using: ${pm}
|
|
135
|
+
`);
|
|
136
|
+
const s = spinner();
|
|
137
|
+
s.start("Installing...");
|
|
138
|
+
try {
|
|
139
|
+
execSync(`${installCmd} ${toInstall.join(" ")}`, {
|
|
140
|
+
cwd: process.cwd(),
|
|
141
|
+
stdio: "inherit"
|
|
142
|
+
});
|
|
143
|
+
s.stop("Dependencies installed ✓");
|
|
144
|
+
} catch (error) {
|
|
145
|
+
s.stop("Installation failed ✗");
|
|
146
|
+
console.error(`
|
|
147
|
+
❌ Failed to install dependencies`);
|
|
148
|
+
console.error("Please try installing manually:", `${installCmd} ${toInstall.join(" ")}`);
|
|
149
|
+
process.exit(1);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
createConfigFile(sandboxChoice, webTools);
|
|
153
|
+
outro("✅ Setup complete!");
|
|
154
|
+
console.log(`
|
|
155
|
+
\uD83D\uDCDA Next steps:`);
|
|
156
|
+
console.log(" 1. Import your tools:");
|
|
157
|
+
console.log(` import { tools } from './bashkit.config';
|
|
158
|
+
`);
|
|
159
|
+
console.log(" 2. Use with Vercel AI SDK:");
|
|
160
|
+
console.log(" import { streamText } from 'ai';");
|
|
161
|
+
console.log(` import { anthropic } from '@ai-sdk/anthropic';
|
|
162
|
+
`);
|
|
163
|
+
console.log(" const result = streamText({");
|
|
164
|
+
console.log(" model: anthropic('claude-sonnet-4-5'),");
|
|
165
|
+
console.log(" tools,");
|
|
166
|
+
console.log(" messages: [{ role: 'user', content: 'List files' }]");
|
|
167
|
+
console.log(" });");
|
|
168
|
+
if (webTools) {
|
|
169
|
+
console.log(`
|
|
170
|
+
3. Set your API key for web tools:`);
|
|
171
|
+
console.log(" export PARALLEL_API_KEY=your_key");
|
|
172
|
+
}
|
|
173
|
+
console.log(`
|
|
174
|
+
\uD83D\uDCD6 Docs: https://github.com/jbreite/bashkit`);
|
|
175
|
+
}
|
|
176
|
+
init().catch((error) => {
|
|
177
|
+
console.error("❌ Setup failed:", error);
|
|
178
|
+
process.exit(1);
|
|
179
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { anthropicPromptCacheMiddleware } from "./middleware";
|
|
2
|
+
export type { E2BSandboxConfig, LocalSandboxConfig, VercelSandboxConfig, } from "./sandbox";
|
|
3
|
+
export { createE2BSandbox, createLocalSandbox, createVercelSandbox, } from "./sandbox";
|
|
4
|
+
export type { ExecOptions, ExecResult, Sandbox } from "./sandbox/interface";
|
|
5
|
+
export type { BashError, BashOutput, EditError, EditOutput, ExitPlanModeError, ExitPlanModeOutput, GlobError, GlobOutput, GrepContentOutput, GrepCountOutput, GrepError, GrepFilesOutput, GrepMatch, GrepOutput, ReadDirectoryOutput, ReadError, ReadOutput, ReadTextOutput, SubagentStepEvent, SubagentTypeConfig, TaskError, TaskOutput, TaskToolConfig, TodoItem, TodoState, TodoWriteError, TodoWriteOutput, WebFetchError, WebFetchOutput, WebFetchToolConfig, WebSearchError, WebSearchOutput, WebSearchResult, WebSearchToolConfig, WriteError, WriteOutput, } from "./tools";
|
|
6
|
+
export { createAgentTools, createBashTool, createEditTool, createExitPlanModeTool, createGlobTool, createGrepTool, createReadTool, createTaskTool, createTodoWriteTool, createWebFetchTool, createWebSearchTool, createWriteTool, } from "./tools";
|
|
7
|
+
export type { AgentConfig, ToolConfig, WebFetchConfig, WebSearchConfig, } from "./types";
|
|
8
|
+
export { DEFAULT_CONFIG } from "./types";
|
|
9
|
+
export type { CompactConversationConfig, CompactConversationResult, CompactConversationState, ContextMetrics, ContextStatus, ContextStatusConfig, ContextStatusLevel, ModelContextLimit, PruneMessagesConfig, } from "./utils";
|
|
10
|
+
export { compactConversation, contextNeedsAttention, contextNeedsCompaction, createCompactConfig, estimateMessagesTokens, estimateMessageTokens, estimateTokens, getContextStatus, MODEL_CONTEXT_LIMITS, pruneMessagesByTokens, } from "./utils";
|
|
11
|
+
export type { DiscoverSkillsOptions, SkillBundle, SkillMetadata, } from "./skills";
|
|
12
|
+
export { discoverSkills, fetchSkill, fetchSkills, parseSkillMetadata, skillsToXml, } from "./skills";
|
|
13
|
+
export type { AgentEnvironmentConfig, SetupResult, SkillContent, } from "./setup";
|
|
14
|
+
export { setupAgentEnvironment } from "./setup";
|