@zhijiewang/openharness 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/CHANGELOG.md +18 -0
- package/CONTRIBUTING.md +55 -0
- package/LICENSE +21 -0
- package/README.md +154 -0
- package/data/models.json +74 -0
- package/data/prompts/system.md +25 -0
- package/data/skills/code-review.md +19 -0
- package/data/skills/commit.md +17 -0
- package/data/skills/debug.md +24 -0
- package/data/skills/tdd.md +22 -0
- package/dist/Tool.d.ts +45 -0
- package/dist/Tool.d.ts.map +1 -0
- package/dist/Tool.js +62 -0
- package/dist/Tool.js.map +1 -0
- package/dist/components/App.d.ts +16 -0
- package/dist/components/App.d.ts.map +1 -0
- package/dist/components/App.js +25 -0
- package/dist/components/App.js.map +1 -0
- package/dist/components/Messages.d.ts +9 -0
- package/dist/components/Messages.d.ts.map +1 -0
- package/dist/components/Messages.js +23 -0
- package/dist/components/Messages.js.map +1 -0
- package/dist/components/PermissionPrompt.d.ts +9 -0
- package/dist/components/PermissionPrompt.d.ts.map +1 -0
- package/dist/components/PermissionPrompt.js +18 -0
- package/dist/components/PermissionPrompt.js.map +1 -0
- package/dist/components/REPL.d.ts +15 -0
- package/dist/components/REPL.d.ts.map +1 -0
- package/dist/components/REPL.js +114 -0
- package/dist/components/REPL.js.map +1 -0
- package/dist/components/Spinner.d.ts +7 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner.js +7 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/TextInput.d.ts +7 -0
- package/dist/components/TextInput.d.ts.map +1 -0
- package/dist/components/TextInput.js +37 -0
- package/dist/components/TextInput.js.map +1 -0
- package/dist/components/ToolCallDisplay.d.ts +12 -0
- package/dist/components/ToolCallDisplay.d.ts.map +1 -0
- package/dist/components/ToolCallDisplay.js +16 -0
- package/dist/components/ToolCallDisplay.js.map +1 -0
- package/dist/harness/cost.d.ts +33 -0
- package/dist/harness/cost.d.ts.map +1 -0
- package/dist/harness/cost.js +68 -0
- package/dist/harness/cost.js.map +1 -0
- package/dist/harness/onboarding.d.ts +17 -0
- package/dist/harness/onboarding.d.ts.map +1 -0
- package/dist/harness/onboarding.js +99 -0
- package/dist/harness/onboarding.js.map +1 -0
- package/dist/harness/rules.d.ts +8 -0
- package/dist/harness/rules.d.ts.map +1 -0
- package/dist/harness/rules.js +66 -0
- package/dist/harness/rules.js.map +1 -0
- package/dist/harness/session.d.ts +24 -0
- package/dist/harness/session.d.ts.map +1 -0
- package/dist/harness/session.js +56 -0
- package/dist/harness/session.js.map +1 -0
- package/dist/main.d.ts +12 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +177 -0
- package/dist/main.js.map +1 -0
- package/dist/providers/anthropic.d.ts +27 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +291 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/base.d.ts +41 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +5 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/index.d.ts +12 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +57 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/ollama.d.ts +19 -0
- package/dist/providers/ollama.d.ts.map +1 -0
- package/dist/providers/ollama.js +233 -0
- package/dist/providers/ollama.js.map +1 -0
- package/dist/providers/openai.d.ts +21 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +242 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/openrouter.d.ts +25 -0
- package/dist/providers/openrouter.d.ts.map +1 -0
- package/dist/providers/openrouter.js +278 -0
- package/dist/providers/openrouter.js.map +1 -0
- package/dist/query.d.ts +35 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +185 -0
- package/dist/query.js.map +1 -0
- package/dist/tools/BashTool/index.d.ts +15 -0
- package/dist/tools/BashTool/index.d.ts.map +1 -0
- package/dist/tools/BashTool/index.js +78 -0
- package/dist/tools/BashTool/index.js.map +1 -0
- package/dist/tools/FileEditTool/index.d.ts +21 -0
- package/dist/tools/FileEditTool/index.d.ts.map +1 -0
- package/dist/tools/FileEditTool/index.js +70 -0
- package/dist/tools/FileEditTool/index.js.map +1 -0
- package/dist/tools/FileReadTool/index.d.ts +18 -0
- package/dist/tools/FileReadTool/index.d.ts.map +1 -0
- package/dist/tools/FileReadTool/index.js +63 -0
- package/dist/tools/FileReadTool/index.js.map +1 -0
- package/dist/tools/FileWriteTool/index.d.ts +15 -0
- package/dist/tools/FileWriteTool/index.d.ts.map +1 -0
- package/dist/tools/FileWriteTool/index.js +42 -0
- package/dist/tools/FileWriteTool/index.js.map +1 -0
- package/dist/tools/GlobTool/index.d.ts +15 -0
- package/dist/tools/GlobTool/index.d.ts.map +1 -0
- package/dist/tools/GlobTool/index.js +126 -0
- package/dist/tools/GlobTool/index.js.map +1 -0
- package/dist/tools/GrepTool/index.d.ts +21 -0
- package/dist/tools/GrepTool/index.d.ts.map +1 -0
- package/dist/tools/GrepTool/index.js +125 -0
- package/dist/tools/GrepTool/index.js.map +1 -0
- package/dist/tools/WebFetchTool/index.d.ts +12 -0
- package/dist/tools/WebFetchTool/index.d.ts.map +1 -0
- package/dist/tools/WebFetchTool/index.js +98 -0
- package/dist/tools/WebFetchTool/index.js.map +1 -0
- package/dist/tools.d.ts +9 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +25 -0
- package/dist/tools.js.map +1 -0
- package/dist/types/events.d.ts +49 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +5 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/message.d.ts +27 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/message.js +22 -0
- package/dist/types/message.js.map +1 -0
- package/dist/types/permissions.d.ts +22 -0
- package/dist/types/permissions.d.ts.map +1 -0
- package/dist/types/permissions.js +27 -0
- package/dist/types/permissions.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PermissionPrompt.d.ts","sourceRoot":"","sources":["../../src/components/PermissionPrompt.tsx"],"names":[],"mappings":"AAGA,KAAK,qBAAqB,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC,CAAC;AAQF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,QAAQ,EACR,WAAW,EACX,SAAS,EACT,SAAS,GACV,EAAE,qBAAqB,2CAwBvB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text, useInput } from "ink";
|
|
3
|
+
const riskColor = {
|
|
4
|
+
low: "green",
|
|
5
|
+
medium: "yellow",
|
|
6
|
+
high: "red",
|
|
7
|
+
};
|
|
8
|
+
export default function PermissionPrompt({ toolName, description, riskLevel, onResolve, }) {
|
|
9
|
+
useInput((input) => {
|
|
10
|
+
if (input.toLowerCase() === "y")
|
|
11
|
+
onResolve(true);
|
|
12
|
+
if (input.toLowerCase() === "n")
|
|
13
|
+
onResolve(false);
|
|
14
|
+
});
|
|
15
|
+
const color = riskColor[riskLevel] ?? "white";
|
|
16
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: color, paddingX: 1, children: [_jsxs(Text, { bold: true, color: color, children: ["Permission Request [", riskLevel.toUpperCase(), "]"] }), _jsxs(Text, { children: ["Tool: ", _jsx(Text, { bold: true, children: toolName })] }), _jsx(Text, { dimColor: true, children: description }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: ["Allow? [", _jsx(Text, { color: "green", bold: true, children: "Y" }), "/", _jsx(Text, { color: "red", bold: true, children: "N" }), "]"] }) })] }));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=PermissionPrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PermissionPrompt.js","sourceRoot":"","sources":["../../src/components/PermissionPrompt.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAS1C,MAAM,SAAS,GAA2B;IACxC,GAAG,EAAE,OAAO;IACZ,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,KAAK;CACZ,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,QAAQ,EACR,WAAW,EACX,SAAS,EACT,SAAS,GACa;IACtB,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE;QACjB,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,GAAG;YAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,GAAG;YAAE,SAAS,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC;IAE9C,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,WAAW,EAAC,OAAO,EAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,aAC7E,MAAC,IAAI,IAAC,IAAI,QAAC,KAAK,EAAE,KAAK,qCACA,SAAS,CAAC,WAAW,EAAE,SACvC,EACP,MAAC,IAAI,yBACG,KAAC,IAAI,IAAC,IAAI,kBAAE,QAAQ,GAAQ,IAC7B,EACP,KAAC,IAAI,IAAC,QAAQ,kBAAE,WAAW,GAAQ,EACnC,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,YACf,MAAC,IAAI,2BACK,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,wBAAS,OAAC,KAAC,IAAI,IAAC,KAAK,EAAC,KAAK,EAAC,IAAI,wBAAS,SACpE,GACH,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Message } from "../types/message.js";
|
|
2
|
+
import type { Provider } from "../providers/base.js";
|
|
3
|
+
import type { Tools } from "../Tool.js";
|
|
4
|
+
import type { PermissionMode } from "../types/permissions.js";
|
|
5
|
+
type REPLProps = {
|
|
6
|
+
provider: Provider;
|
|
7
|
+
tools: Tools;
|
|
8
|
+
permissionMode: PermissionMode;
|
|
9
|
+
systemPrompt: string;
|
|
10
|
+
model?: string;
|
|
11
|
+
initialMessages?: Message[];
|
|
12
|
+
};
|
|
13
|
+
export default function REPL({ provider, tools, permissionMode, systemPrompt, model, initialMessages, }: REPLProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=REPL.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"REPL.d.ts","sourceRoot":"","sources":["../../src/components/REPL.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAS9D,KAAK,SAAS,GAAG;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC;CAC7B,CAAC;AAkBF,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAC3B,QAAQ,EACR,KAAK,EACL,cAAc,EACd,YAAY,EACZ,KAAK,EACL,eAAe,GAChB,EAAE,SAAS,2CAiKX"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useCallback } from "react";
|
|
3
|
+
import { Box, Text, useApp } from "ink";
|
|
4
|
+
import { createAssistantMessage, createUserMessage } from "../types/message.js";
|
|
5
|
+
import { query } from "../query.js";
|
|
6
|
+
import Messages from "./Messages.js";
|
|
7
|
+
import Spinner from "./Spinner.js";
|
|
8
|
+
import TextInput from "./TextInput.js";
|
|
9
|
+
import PermissionPrompt from "./PermissionPrompt.js";
|
|
10
|
+
const BANNER = ` ___
|
|
11
|
+
/ \\
|
|
12
|
+
( ) ___ ___ ___ _ _ _ _ _ ___ _ _ ___ ___ ___
|
|
13
|
+
\`~w~\` / _ \\| _ \\| __| \\| | || | /_\\ | _ \\ \\| | __/ __/ __|
|
|
14
|
+
(( )) | (_) | _/| _|| .\` | __ |/ _ \\| / .\` | _|\\__ \\__ \\
|
|
15
|
+
))(( \\___/|_| |___|_|\\_|_||_/_/ \\_\\_|_\\_|\\_|___|___/___/
|
|
16
|
+
(( ))
|
|
17
|
+
\`--\``;
|
|
18
|
+
export default function REPL({ provider, tools, permissionMode, systemPrompt, model, initialMessages, }) {
|
|
19
|
+
const { exit } = useApp();
|
|
20
|
+
const [messages, setMessages] = useState(initialMessages ?? []);
|
|
21
|
+
const [loading, setLoading] = useState(false);
|
|
22
|
+
const [streamingText, setStreamingText] = useState("");
|
|
23
|
+
const [toolCalls, setToolCalls] = useState(new Map());
|
|
24
|
+
const [pendingPermission, setPendingPermission] = useState(null);
|
|
25
|
+
const [error, setError] = useState(null);
|
|
26
|
+
const [currentModel, setCurrentModel] = useState(model ?? "");
|
|
27
|
+
const handleSubmit = useCallback(async (input) => {
|
|
28
|
+
const trimmed = input.trim();
|
|
29
|
+
if (trimmed === "exit" || trimmed === "quit" || trimmed === "/exit" || trimmed === "/quit") {
|
|
30
|
+
exit();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
setLoading(true);
|
|
34
|
+
setStreamingText("");
|
|
35
|
+
setError(null);
|
|
36
|
+
setToolCalls(new Map());
|
|
37
|
+
const userMsg = createUserMessage(input);
|
|
38
|
+
setMessages((prev) => [...prev, userMsg]);
|
|
39
|
+
const askUser = (toolName, description) => {
|
|
40
|
+
return new Promise((resolve) => {
|
|
41
|
+
setPendingPermission({
|
|
42
|
+
toolName,
|
|
43
|
+
description,
|
|
44
|
+
riskLevel: "medium",
|
|
45
|
+
resolve: (allowed) => {
|
|
46
|
+
setPendingPermission(null);
|
|
47
|
+
resolve(allowed);
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const config = {
|
|
53
|
+
provider,
|
|
54
|
+
tools,
|
|
55
|
+
systemPrompt,
|
|
56
|
+
permissionMode,
|
|
57
|
+
askUser,
|
|
58
|
+
};
|
|
59
|
+
let accumulatedText = "";
|
|
60
|
+
try {
|
|
61
|
+
for await (const event of query(input, config, messages)) {
|
|
62
|
+
switch (event.type) {
|
|
63
|
+
case "text_delta":
|
|
64
|
+
accumulatedText += event.content;
|
|
65
|
+
setStreamingText(accumulatedText);
|
|
66
|
+
break;
|
|
67
|
+
case "tool_call_start":
|
|
68
|
+
setToolCalls((prev) => {
|
|
69
|
+
const next = new Map(prev);
|
|
70
|
+
next.set(event.callId, {
|
|
71
|
+
callId: event.callId,
|
|
72
|
+
toolName: event.toolName,
|
|
73
|
+
status: "running",
|
|
74
|
+
});
|
|
75
|
+
return next;
|
|
76
|
+
});
|
|
77
|
+
break;
|
|
78
|
+
case "tool_call_end":
|
|
79
|
+
setToolCalls((prev) => {
|
|
80
|
+
const next = new Map(prev);
|
|
81
|
+
next.set(event.callId, {
|
|
82
|
+
callId: event.callId,
|
|
83
|
+
toolName: next.get(event.callId)?.toolName ?? "unknown",
|
|
84
|
+
status: event.isError ? "error" : "done",
|
|
85
|
+
output: event.output,
|
|
86
|
+
});
|
|
87
|
+
return next;
|
|
88
|
+
});
|
|
89
|
+
break;
|
|
90
|
+
case "cost_update":
|
|
91
|
+
setCurrentModel(event.model);
|
|
92
|
+
break;
|
|
93
|
+
case "error":
|
|
94
|
+
setError(event.message);
|
|
95
|
+
break;
|
|
96
|
+
case "turn_complete":
|
|
97
|
+
if (accumulatedText) {
|
|
98
|
+
setMessages((prev) => [...prev, createAssistantMessage(accumulatedText)]);
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
setLoading(false);
|
|
109
|
+
setStreamingText("");
|
|
110
|
+
}
|
|
111
|
+
}, [provider, tools, systemPrompt, permissionMode, messages, exit]);
|
|
112
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { color: "magenta", children: BANNER }), _jsxs(Box, { children: [_jsx(Text, { bold: true, color: "magenta", children: "OpenHarness" }), _jsx(Text, { dimColor: true, children: " v0.1.0" }), _jsx(Text, { color: "cyan", children: currentModel ? ` ${currentModel}` : "" }), _jsx(Text, { dimColor: true, children: ` (${permissionMode})` })] }), _jsx(Text, { dimColor: true, children: "─".repeat(60) })] }), _jsx(Messages, { messages: messages, toolCalls: toolCalls }), loading && streamingText && (_jsxs(Box, { marginY: 0, flexDirection: "column", children: [_jsx(Text, { color: "magenta", bold: true, children: "◆ " }), _jsx(Text, { children: streamingText })] })), loading && !streamingText && _jsx(Spinner, { model: currentModel }), error && (_jsx(Box, { marginY: 1, borderStyle: "round", borderColor: "red", paddingX: 1, children: _jsxs(Text, { color: "red", children: ["\u2717 ", error] }) })), pendingPermission && (_jsx(PermissionPrompt, { toolName: pendingPermission.toolName, description: pendingPermission.description, riskLevel: pendingPermission.riskLevel, onResolve: pendingPermission.resolve })), _jsx(Box, { marginTop: 1, children: _jsx(TextInput, { onSubmit: handleSubmit, disabled: loading }) })] }));
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=REPL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"REPL.js","sourceRoot":"","sources":["../../src/components/REPL.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAMxC,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,KAAK,EAAoB,MAAM,aAAa,CAAC;AACtD,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AAmBrD,MAAM,MAAM,GAAG;;;;;;;eAOA,CAAC;AAEhB,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAC3B,QAAQ,EACR,KAAK,EACL,cAAc,EACd,YAAY,EACZ,KAAK,EACL,eAAe,GACL;IACV,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;IAC1B,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAY,eAAe,IAAI,EAAE,CAAC,CAAC;IAC3E,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAA6B,IAAI,GAAG,EAAE,CAAC,CAAC;IAClF,MAAM,CAAC,iBAAiB,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IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,YAAY,2CAc7D"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from "ink";
|
|
3
|
+
import InkSpinner from "ink-spinner";
|
|
4
|
+
export default function Spinner({ label, model }) {
|
|
5
|
+
return (_jsxs(Box, { children: [_jsx(Text, { color: "magenta", children: _jsx(InkSpinner, { type: "dots" }) }), _jsxs(Text, { dimColor: true, children: [" ", label ?? "Thinking", model ? ` (${model})` : "", "..."] })] }));
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=Spinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spinner.js","sourceRoot":"","sources":["../../src/components/Spinner.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,UAAU,MAAM,aAAa,CAAC;AAOrC,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAgB;IAC5D,OAAO,CACL,MAAC,GAAG,eACF,KAAC,IAAI,IAAC,KAAK,EAAC,SAAS,YACnB,KAAC,UAAU,IAAC,IAAI,EAAC,MAAM,GAAG,GACrB,EACP,MAAC,IAAI,IAAC,QAAQ,mBACX,GAAG,EACH,KAAK,IAAI,UAAU,EACnB,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,WAEtB,IACH,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../src/components/TextInput.tsx"],"names":[],"mappings":"AAIA,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,cAAc,2CA+CvE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useCallback } from "react";
|
|
3
|
+
import { Box, Text, useInput } from "ink";
|
|
4
|
+
import InkTextInput from "ink-text-input";
|
|
5
|
+
export default function TextInput({ onSubmit, disabled }) {
|
|
6
|
+
const [value, setValue] = useState("");
|
|
7
|
+
const [history, setHistory] = useState([]);
|
|
8
|
+
const [historyIndex, setHistoryIndex] = useState(-1);
|
|
9
|
+
useInput((_input, key) => {
|
|
10
|
+
if (key.upArrow && history.length > 0) {
|
|
11
|
+
const next = Math.min(historyIndex + 1, history.length - 1);
|
|
12
|
+
setHistoryIndex(next);
|
|
13
|
+
setValue(history[next]);
|
|
14
|
+
}
|
|
15
|
+
if (key.downArrow) {
|
|
16
|
+
if (historyIndex <= 0) {
|
|
17
|
+
setHistoryIndex(-1);
|
|
18
|
+
setValue("");
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const next = historyIndex - 1;
|
|
22
|
+
setHistoryIndex(next);
|
|
23
|
+
setValue(history[next]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}, { isActive: !disabled });
|
|
27
|
+
const handleSubmit = useCallback((submitted) => {
|
|
28
|
+
if (!submitted.trim() || disabled)
|
|
29
|
+
return;
|
|
30
|
+
setHistory((prev) => [submitted, ...prev]);
|
|
31
|
+
setHistoryIndex(-1);
|
|
32
|
+
setValue("");
|
|
33
|
+
onSubmit(submitted);
|
|
34
|
+
}, [onSubmit, disabled]);
|
|
35
|
+
return (_jsxs(Box, { children: [_jsx(Text, { color: "cyan", bold: true, children: "❯ " }), _jsx(InkTextInput, { value: value, onChange: setValue, onSubmit: handleSubmit, placeholder: disabled ? "Waiting..." : "Type a message..." })] }));
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=TextInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../src/components/TextInput.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAO1C,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAkB;IACtE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAW,EAAE,CAAC,CAAC;IACrD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAErD,QAAQ,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;QACvB,IAAI,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAC5D,eAAe,CAAC,IAAI,CAAC,CAAC;YACtB,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAE,CAAC,CAAC;QAC3B,CAAC;QACD,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;YAClB,IAAI,YAAY,IAAI,CAAC,EAAE,CAAC;gBACtB,eAAe,CAAC,CAA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olCallState;
|
|
9
|
+
};
|
|
10
|
+
export default function ToolCallDisplay({ toolCall }: ToolCallDisplayProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export type { ToolCallState };
|
|
12
|
+
//# sourceMappingURL=ToolCallDisplay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolCallDisplay.d.ts","sourceRoot":"","sources":["../../src/components/ToolCallDisplay.tsx"],"names":[],"mappings":"AAIA,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,oBAAoB,GAAG;IAC1B,QAAQ,EAAE,aAAa,CAAC;CACzB,CAAC;AAIF,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,QAAQ,EAAE,EAAE,oBAAoB,2CA2BzE;AAQD,YAAY,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from "ink";
|
|
3
|
+
import InkSpinner from "ink-spinner";
|
|
4
|
+
const MAX_OUTPUT_LINES = 8;
|
|
5
|
+
export default function ToolCallDisplay({ toolCall }) {
|
|
6
|
+
const { toolName, status, output } = toolCall;
|
|
7
|
+
const icon = status === "running" ? (_jsxs(Text, { color: "yellow", children: [_jsx(InkSpinner, { type: "dots" }), " "] })) : status === "error" ? (_jsx(Text, { color: "red", children: "✗ " })) : (_jsx(Text, { color: "green", children: "✓ " }));
|
|
8
|
+
return (_jsxs(Box, { flexDirection: "column", marginLeft: 2, marginY: 0, children: [_jsxs(Box, { children: [icon, _jsx(Text, { color: "yellow", bold: true, children: toolName }), status === "running" && _jsx(Text, { dimColor: true, children: " ..." })] }), output != null && status !== "running" && (_jsx(Box, { marginLeft: 4, children: _jsx(Text, { color: status === "error" ? "red" : "gray", dimColor: true, children: truncateOutput(output, MAX_OUTPUT_LINES) }) }))] }));
|
|
9
|
+
}
|
|
10
|
+
function truncateOutput(text, maxLines) {
|
|
11
|
+
const lines = text.split("\n");
|
|
12
|
+
if (lines.length <= maxLines)
|
|
13
|
+
return text;
|
|
14
|
+
return lines.slice(0, maxLines).join("\n") + `\n... (${lines.length} lines)`;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=ToolCallDisplay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolCallDisplay.js","sourceRoot":"","sources":["../../src/components/ToolCallDisplay.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,UAAU,MAAM,aAAa,CAAC;AAarC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,QAAQ,EAAwB;IACxE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC;IAE9C,MAAM,IAAI,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,CAClC,MAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,aAAC,KAAC,UAAU,IAAC,IAAI,EAAC,MAAM,GAAG,EAAC,GAAG,IAAQ,CAC5D,CAAC,CAAC,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CACvB,KAAC,IAAI,IAAC,KAAK,EAAC,KAAK,YAAE,IAAI,GAAQ,CAChC,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,YAAE,IAAI,GAAQ,CAClC,CAAC;IAEF,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,aACnD,MAAC,GAAG,eACD,IAAI,EACL,KAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,EAAC,IAAI,kBAAE,QAAQ,GAAQ,EAC1C,MAAM,KAAK,SAAS,IAAI,KAAC,IAAI,IAAC,QAAQ,kBAAE,MAAM,GAAQ,IACnD,EACL,MAAM,IAAI,IAAI,IAAI,MAAM,KAAK,SAAS,IAAI,CACzC,KAAC,GAAG,IAAC,UAAU,EAAE,CAAC,YAChB,KAAC,IAAI,IAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,QAAQ,kBACvD,cAAc,CAAC,MAAM,EAAE,gBAAgB,CAAC,GACpC,GACH,CACP,IACG,CACP,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,IAAY,EAAE,QAAgB;IACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,KAAK,CAAC,MAAM,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC1C,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,UAAU,KAAK,CAAC,MAAM,SAAS,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cost tracking — per-model token and cost tracking with budget enforcement.
|
|
3
|
+
*/
|
|
4
|
+
export type ModelUsage = {
|
|
5
|
+
inputTokens: number;
|
|
6
|
+
outputTokens: number;
|
|
7
|
+
costUsd: number;
|
|
8
|
+
requests: number;
|
|
9
|
+
};
|
|
10
|
+
export type CostEvent = {
|
|
11
|
+
timestamp: number;
|
|
12
|
+
provider: string;
|
|
13
|
+
model: string;
|
|
14
|
+
inputTokens: number;
|
|
15
|
+
outputTokens: number;
|
|
16
|
+
cost: number;
|
|
17
|
+
};
|
|
18
|
+
export declare class CostTracker {
|
|
19
|
+
events: CostEvent[];
|
|
20
|
+
modelUsage: Map<string, ModelUsage>;
|
|
21
|
+
budget: number;
|
|
22
|
+
constructor(budget?: number);
|
|
23
|
+
record(provider: string, model: string, inputTokens: number, outputTokens: number, cost: number): void;
|
|
24
|
+
get totalCost(): number;
|
|
25
|
+
get totalInputTokens(): number;
|
|
26
|
+
get totalOutputTokens(): number;
|
|
27
|
+
isOverBudget(): boolean;
|
|
28
|
+
formatSummary(): string;
|
|
29
|
+
}
|
|
30
|
+
/** Model pricing: [input_cost_per_mtok, output_cost_per_mtok] */
|
|
31
|
+
export declare const MODEL_PRICING: Record<string, [number, number]>;
|
|
32
|
+
export declare function estimateCost(model: string, inputTokens: number, outputTokens: number): number;
|
|
33
|
+
//# sourceMappingURL=cost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost.d.ts","sourceRoot":"","sources":["../../src/harness/cost.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,qBAAa,WAAW;IACtB,MAAM,EAAE,SAAS,EAAE,CAAM;IACzB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAa;IAChD,MAAM,EAAE,MAAM,CAAC;gBAEH,MAAM,SAAI;IAItB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAWtG,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAED,IAAI,iBAAiB,IAAI,MAAM,CAE9B;IAED,YAAY,IAAI,OAAO;IAIvB,aAAa,IAAI,MAAM;CAkBxB;AAED,iEAAiE;AACjE,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAW1D,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAI7F"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cost tracking — per-model token and cost tracking with budget enforcement.
|
|
3
|
+
*/
|
|
4
|
+
export class CostTracker {
|
|
5
|
+
events = [];
|
|
6
|
+
modelUsage = new Map();
|
|
7
|
+
budget;
|
|
8
|
+
constructor(budget = 0) {
|
|
9
|
+
this.budget = budget;
|
|
10
|
+
}
|
|
11
|
+
record(provider, model, inputTokens, outputTokens, cost) {
|
|
12
|
+
this.events.push({ timestamp: Date.now(), provider, model, inputTokens, outputTokens, cost });
|
|
13
|
+
const existing = this.modelUsage.get(model) ?? { inputTokens: 0, outputTokens: 0, costUsd: 0, requests: 0 };
|
|
14
|
+
existing.inputTokens += inputTokens;
|
|
15
|
+
existing.outputTokens += outputTokens;
|
|
16
|
+
existing.costUsd += cost;
|
|
17
|
+
existing.requests += 1;
|
|
18
|
+
this.modelUsage.set(model, existing);
|
|
19
|
+
}
|
|
20
|
+
get totalCost() {
|
|
21
|
+
return this.events.reduce((sum, e) => sum + e.cost, 0);
|
|
22
|
+
}
|
|
23
|
+
get totalInputTokens() {
|
|
24
|
+
return this.events.reduce((sum, e) => sum + e.inputTokens, 0);
|
|
25
|
+
}
|
|
26
|
+
get totalOutputTokens() {
|
|
27
|
+
return this.events.reduce((sum, e) => sum + e.outputTokens, 0);
|
|
28
|
+
}
|
|
29
|
+
isOverBudget() {
|
|
30
|
+
return this.budget > 0 && this.totalCost >= this.budget;
|
|
31
|
+
}
|
|
32
|
+
formatSummary() {
|
|
33
|
+
const lines = [
|
|
34
|
+
`Total cost: $${this.totalCost.toFixed(4)}`,
|
|
35
|
+
`Total tokens: ${this.totalInputTokens.toLocaleString()} input, ${this.totalOutputTokens.toLocaleString()} output`,
|
|
36
|
+
];
|
|
37
|
+
if (this.budget > 0) {
|
|
38
|
+
lines.push(`Budget: $${Math.max(0, this.budget - this.totalCost).toFixed(4)} remaining`);
|
|
39
|
+
}
|
|
40
|
+
if (this.modelUsage.size > 0) {
|
|
41
|
+
lines.push("\nBy model:");
|
|
42
|
+
for (const [model, usage] of this.modelUsage) {
|
|
43
|
+
lines.push(` ${model.padEnd(30)} ${usage.inputTokens.toLocaleString().padStart(8)} in, ${usage.outputTokens.toLocaleString().padStart(8)} out ($${usage.costUsd.toFixed(4)})`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return lines.join("\n");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Model pricing: [input_cost_per_mtok, output_cost_per_mtok] */
|
|
50
|
+
export const MODEL_PRICING = {
|
|
51
|
+
"gpt-4o": [2.5, 10.0],
|
|
52
|
+
"gpt-4o-mini": [0.15, 0.6],
|
|
53
|
+
"o3-mini": [1.1, 4.4],
|
|
54
|
+
"o3": [10.0, 40.0],
|
|
55
|
+
"claude-sonnet-4-6": [3.0, 15.0],
|
|
56
|
+
"claude-haiku-4-5": [0.8, 4.0],
|
|
57
|
+
"claude-opus-4-6": [15.0, 75.0],
|
|
58
|
+
"deepseek-chat": [0.14, 0.28],
|
|
59
|
+
"deepseek-coder": [0.14, 0.28],
|
|
60
|
+
"qwen-turbo": [0.2, 0.6],
|
|
61
|
+
};
|
|
62
|
+
export function estimateCost(model, inputTokens, outputTokens) {
|
|
63
|
+
const pricing = MODEL_PRICING[model];
|
|
64
|
+
if (!pricing)
|
|
65
|
+
return 0;
|
|
66
|
+
return (inputTokens / 1_000_000) * pricing[0] + (outputTokens / 1_000_000) * pricing[1];
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=cost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost.js","sourceRoot":"","sources":["../../src/harness/cost.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkBH,MAAM,OAAO,WAAW;IACtB,MAAM,GAAgB,EAAE,CAAC;IACzB,UAAU,GAA4B,IAAI,GAAG,EAAE,CAAC;IAChD,MAAM,CAAS;IAEf,YAAY,MAAM,GAAG,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,QAAgB,EAAE,KAAa,EAAE,WAAmB,EAAE,YAAoB,EAAE,IAAY;QAC7F,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;QAE9F,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;QAC5G,QAAQ,CAAC,WAAW,IAAI,WAAW,CAAC;QACpC,QAAQ,CAAC,YAAY,IAAI,YAAY,CAAC;QACtC,QAAQ,CAAC,OAAO,IAAI,IAAI,CAAC;QACzB,QAAQ,CAAC,QAAQ,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,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AG,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project auto-detection — detect language, framework, test runner, git state.
|
|
3
|
+
*/
|
|
4
|
+
export type ProjectContext = {
|
|
5
|
+
root: string;
|
|
6
|
+
language: string;
|
|
7
|
+
framework: string;
|
|
8
|
+
packageManager: string;
|
|
9
|
+
testRunner: string;
|
|
10
|
+
hasGit: boolean;
|
|
11
|
+
gitBranch: string;
|
|
12
|
+
hasReadme: boolean;
|
|
13
|
+
description: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function detectProject(root?: string): ProjectContext;
|
|
16
|
+
export declare function projectContextToPrompt(ctx: ProjectContext): string;
|
|
17
|
+
//# sourceMappingURL=onboarding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboarding.d.ts","sourceRoot":"","sources":["../../src/harness/onboarding.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAgCF,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc,CAqD3D;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM,CAUlE"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project auto-detection — detect language, framework, test runner, git state.
|
|
3
|
+
*/
|
|
4
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
const DETECTORS = [
|
|
7
|
+
// [indicator, language, framework, packageManager, testRunner]
|
|
8
|
+
["pyproject.toml", "python", "", "pip", "pytest"],
|
|
9
|
+
["requirements.txt", "python", "", "pip", "pytest"],
|
|
10
|
+
["package.json", "javascript", "", "npm", "jest"],
|
|
11
|
+
["bun.lockb", "typescript", "", "bun", "bun test"],
|
|
12
|
+
["deno.json", "typescript", "", "deno", "deno test"],
|
|
13
|
+
["Cargo.toml", "rust", "", "cargo", "cargo test"],
|
|
14
|
+
["go.mod", "go", "", "go", "go test"],
|
|
15
|
+
["pom.xml", "java", "", "maven", "mvn test"],
|
|
16
|
+
["build.gradle", "java", "", "gradle", "gradle test"],
|
|
17
|
+
["Gemfile", "ruby", "", "bundler", "rspec"],
|
|
18
|
+
["composer.json", "php", "", "composer", "phpunit"],
|
|
19
|
+
["Package.swift", "swift", "", "swift", "swift test"],
|
|
20
|
+
];
|
|
21
|
+
const FRAMEWORKS = {
|
|
22
|
+
"next.config.js": "Next.js",
|
|
23
|
+
"next.config.ts": "Next.js",
|
|
24
|
+
"nuxt.config.js": "Nuxt",
|
|
25
|
+
"nuxt.config.ts": "Nuxt",
|
|
26
|
+
"vite.config.ts": "Vite",
|
|
27
|
+
"angular.json": "Angular",
|
|
28
|
+
"svelte.config.js": "Svelte",
|
|
29
|
+
"manage.py": "Django",
|
|
30
|
+
"tailwind.config.js": "Tailwind CSS",
|
|
31
|
+
"Dockerfile": "Docker",
|
|
32
|
+
"docker-compose.yml": "Docker Compose",
|
|
33
|
+
};
|
|
34
|
+
export function detectProject(root) {
|
|
35
|
+
const projectRoot = root ?? process.cwd();
|
|
36
|
+
let language = "unknown";
|
|
37
|
+
let framework = "";
|
|
38
|
+
let packageManager = "";
|
|
39
|
+
let testRunner = "";
|
|
40
|
+
for (const [indicator, lang, fw, pm, tr] of DETECTORS) {
|
|
41
|
+
if (existsSync(join(projectRoot, indicator))) {
|
|
42
|
+
language = lang;
|
|
43
|
+
framework = fw || framework;
|
|
44
|
+
packageManager = pm;
|
|
45
|
+
testRunner = tr;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
for (const [file, fw] of Object.entries(FRAMEWORKS)) {
|
|
50
|
+
if (existsSync(join(projectRoot, file))) {
|
|
51
|
+
framework = fw;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const hasGit = existsSync(join(projectRoot, ".git"));
|
|
56
|
+
let gitBranch = "";
|
|
57
|
+
if (hasGit) {
|
|
58
|
+
try {
|
|
59
|
+
const head = readFileSync(join(projectRoot, ".git", "HEAD"), "utf-8").trim();
|
|
60
|
+
if (head.startsWith("ref: refs/heads/")) {
|
|
61
|
+
gitBranch = head.slice("ref: refs/heads/".length);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch { /* ignore */ }
|
|
65
|
+
}
|
|
66
|
+
const hasReadme = ["README.md", "README.rst", "README.txt", "README"].some((f) => existsSync(join(projectRoot, f)));
|
|
67
|
+
let description = "";
|
|
68
|
+
for (const name of ["README.md", "README.rst", "README.txt"]) {
|
|
69
|
+
const path = join(projectRoot, name);
|
|
70
|
+
if (existsSync(path)) {
|
|
71
|
+
const lines = readFileSync(path, "utf-8").split("\n");
|
|
72
|
+
for (const line of lines) {
|
|
73
|
+
const trimmed = line.replace(/^#+\s*/, "").trim();
|
|
74
|
+
if (trimmed) {
|
|
75
|
+
description = trimmed.slice(0, 200);
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return { root: projectRoot, language, framework, packageManager, testRunner, hasGit, gitBranch, hasReadme, description };
|
|
83
|
+
}
|
|
84
|
+
export function projectContextToPrompt(ctx) {
|
|
85
|
+
const parts = [`Working directory: ${ctx.root}`];
|
|
86
|
+
if (ctx.language !== "unknown") {
|
|
87
|
+
parts.push(`Language: ${ctx.language}${ctx.framework ? ` (${ctx.framework})` : ""}`);
|
|
88
|
+
}
|
|
89
|
+
if (ctx.packageManager)
|
|
90
|
+
parts.push(`Package manager: ${ctx.packageManager}`);
|
|
91
|
+
if (ctx.testRunner)
|
|
92
|
+
parts.push(`Test command: ${ctx.testRunner}`);
|
|
93
|
+
if (ctx.hasGit)
|
|
94
|
+
parts.push(`Git: yes${ctx.gitBranch ? ` (branch: ${ctx.gitBranch})` : ""}`);
|
|
95
|
+
if (ctx.description)
|
|
96
|
+
parts.push(`Project: ${ctx.description}`);
|
|
97
|
+
return "# Environment\n" + parts.map((p) => `- ${p}`).join("\n");
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=onboarding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboarding.js","sourceRoot":"","sources":["../../src/harness/onboarding.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAe,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAY,MAAM,WAAW,CAAC;AAc3C,MAAM,SAAS,GAAoD;IACjE,+DAA+D;IAC/D,CAAC,gBAAgB,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC;IACjD,CAAC,kBAAkB,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC;IACnD,CAAC,cAAc,EAAE,YAAY,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC;IACjD,CAAC,WAAW,EAAE,YAAY,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,CAAC;IAClD,CAAC,WAAW,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC;IACpD,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,YAAY,CAAC;IACjD,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC;IACr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AAG,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC5F,IAAI,GAAG,CAAC,WAAW;QAAE,KAAK,CAAC,IAAI,CAAC,YAAY,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;IAC/D,OAAO,iBAAiB,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rules system — load project and global rules into agent context.
|
|
3
|
+
* Discovery order: ~/.oh/global-rules/*.md → .oh/RULES.md → .oh/rules/*.md
|
|
4
|
+
*/
|
|
5
|
+
export declare function loadRules(projectPath?: string): string[];
|
|
6
|
+
export declare function loadRulesAsPrompt(projectPath?: string): string;
|
|
7
|
+
export declare function createRulesFile(projectPath?: string): string;
|
|
8
|
+
//# sourceMappingURL=rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/harness/rules.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,wBAAgB,SAAS,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CA8BxD;AAED,wBAAgB,iBAAiB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAI9D;AAED,wBAAgB,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAgB5D"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rules system — load project and global rules into agent context.
|
|
3
|
+
* Discovery order: ~/.oh/global-rules/*.md → .oh/RULES.md → .oh/rules/*.md
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync, readdirSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { homedir } from "node:os";
|
|
8
|
+
const OH_HOME = join(homedir(), ".oh");
|
|
9
|
+
export function loadRules(projectPath) {
|
|
10
|
+
const rules = [];
|
|
11
|
+
const root = projectPath ?? process.cwd();
|
|
12
|
+
// 1. Global rules
|
|
13
|
+
const globalDir = join(OH_HOME, "global-rules");
|
|
14
|
+
if (existsSync(globalDir)) {
|
|
15
|
+
for (const file of readdirSync(globalDir).filter((f) => f.endsWith(".md")).sort()) {
|
|
16
|
+
const content = readSafe(join(globalDir, file));
|
|
17
|
+
if (content)
|
|
18
|
+
rules.push(content);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// 2. Project RULES.md
|
|
22
|
+
const projectRules = join(root, ".oh", "RULES.md");
|
|
23
|
+
if (existsSync(projectRules)) {
|
|
24
|
+
const content = readSafe(projectRules);
|
|
25
|
+
if (content)
|
|
26
|
+
rules.push(content);
|
|
27
|
+
}
|
|
28
|
+
// 3. Project rules/*.md
|
|
29
|
+
const rulesDir = join(root, ".oh", "rules");
|
|
30
|
+
if (existsSync(rulesDir)) {
|
|
31
|
+
for (const file of readdirSync(rulesDir).filter((f) => f.endsWith(".md")).sort()) {
|
|
32
|
+
const content = readSafe(join(rulesDir, file));
|
|
33
|
+
if (content)
|
|
34
|
+
rules.push(content);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return rules;
|
|
38
|
+
}
|
|
39
|
+
export function loadRulesAsPrompt(projectPath) {
|
|
40
|
+
const rules = loadRules(projectPath);
|
|
41
|
+
if (rules.length === 0)
|
|
42
|
+
return "";
|
|
43
|
+
return "# Project Rules\n\nFollow these rules carefully.\n\n" + rules.join("\n\n---\n\n");
|
|
44
|
+
}
|
|
45
|
+
export function createRulesFile(projectPath) {
|
|
46
|
+
const root = projectPath ?? process.cwd();
|
|
47
|
+
const ohDir = join(root, ".oh");
|
|
48
|
+
mkdirSync(ohDir, { recursive: true });
|
|
49
|
+
const rulesFile = join(ohDir, "RULES.md");
|
|
50
|
+
if (!existsSync(rulesFile)) {
|
|
51
|
+
writeFileSync(rulesFile, "# Project Rules\n\n" +
|
|
52
|
+
"- Always run tests after making changes\n" +
|
|
53
|
+
"- Use type hints / strict types\n" +
|
|
54
|
+
"- Prefer small, reviewable patches\n");
|
|
55
|
+
}
|
|
56
|
+
return rulesFile;
|
|
57
|
+
}
|
|
58
|
+
function readSafe(path) {
|
|
59
|
+
try {
|
|
60
|
+
return readFileSync(path, "utf-8").trim();
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return "";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=rules.js.map
|