oh-my-opencode-cohub 1.5.0 → 1.5.1
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.
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import type { RelevantFile } from './types';
|
|
2
|
+
/** SDK v2 Part 格式(简化) */
|
|
3
|
+
interface SdkPart {
|
|
4
|
+
type?: string;
|
|
5
|
+
text?: string;
|
|
6
|
+
tool?: string;
|
|
7
|
+
state?: {
|
|
8
|
+
status?: string;
|
|
9
|
+
input?: Record<string, unknown>;
|
|
10
|
+
output?: string;
|
|
11
|
+
error?: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
2
14
|
/** SDK v2 消息格式(简化) */
|
|
3
15
|
interface SdkMessage {
|
|
4
16
|
info?: {
|
|
5
17
|
role?: string;
|
|
6
18
|
};
|
|
7
|
-
parts?:
|
|
8
|
-
type?: string;
|
|
9
|
-
text?: string;
|
|
10
|
-
tool?: string;
|
|
11
|
-
args?: unknown;
|
|
12
|
-
tool_result?: unknown;
|
|
13
|
-
}>;
|
|
19
|
+
parts?: SdkPart[];
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
16
22
|
* 从消息列表中提取相关文件。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../src/context/extractor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAuB5C,
|
|
1
|
+
{"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../src/context/extractor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAuB5C,yBAAyB;AACzB,UAAU,OAAO;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE;QACN,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,sBAAsB;AACtB,UAAU,UAAU;IAClB,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,UAAU,EAAE,EACtB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,YAAY,EAAE,CAoFhB;AAUD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,UAAU,EAAE,EACtB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,MAAM,EAAE,CAqBV;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,UAAU,EAAE,EACtB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,MAAM,EAAE,CAwBV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractor.test.d.ts","sourceRoot":"","sources":["../../src/context/extractor.test.ts"],"names":[],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -770,13 +770,27 @@ function extractRelevantFiles(messages, maxFiles, windowSize) {
|
|
|
770
770
|
const fileMap = new Map;
|
|
771
771
|
for (const msg of recent) {
|
|
772
772
|
for (const part of msg.parts ?? []) {
|
|
773
|
-
if (part.type === "
|
|
774
|
-
const
|
|
775
|
-
const
|
|
776
|
-
|
|
777
|
-
|
|
773
|
+
if (part.type === "tool" && part.state) {
|
|
774
|
+
const state = part.state;
|
|
775
|
+
const input = state.input ?? {};
|
|
776
|
+
const path = extractPath(input);
|
|
777
|
+
if (path) {
|
|
778
|
+
if (!fileMap.has(path)) {
|
|
779
|
+
fileMap.set(path, { path, summary: "" });
|
|
780
|
+
}
|
|
781
|
+
const existing = fileMap.get(path);
|
|
782
|
+
if (typeof input.offset === "number") {
|
|
783
|
+
const limit = typeof input.limit === "number" ? input.limit : 50;
|
|
784
|
+
existing.lines = `${input.offset}-${input.offset + limit}`;
|
|
785
|
+
}
|
|
786
|
+
if (typeof input.oldString === "string") {
|
|
787
|
+
existing.summary = `编辑: ${input.oldString.slice(0, 80)}`;
|
|
788
|
+
}
|
|
789
|
+
if (state.status === "completed" && typeof state.output === "string" && !existing.summary) {
|
|
790
|
+
existing.summary = state.output.slice(0, 100).replace(/\n/g, " ");
|
|
791
|
+
}
|
|
778
792
|
}
|
|
779
|
-
for (const value of Object.values(
|
|
793
|
+
for (const value of Object.values(input)) {
|
|
780
794
|
if (typeof value !== "string")
|
|
781
795
|
continue;
|
|
782
796
|
let match;
|
|
@@ -792,25 +806,19 @@ function extractRelevantFiles(messages, maxFiles, windowSize) {
|
|
|
792
806
|
}
|
|
793
807
|
}
|
|
794
808
|
}
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
}
|
|
807
|
-
if (typeof args.oldString === "string") {
|
|
808
|
-
existing.summary = `编辑位置: ${args.oldString.slice(0, 80)}`;
|
|
809
|
+
if (state.status === "completed" && typeof state.output === "string") {
|
|
810
|
+
let match;
|
|
811
|
+
FILE_PATH_RE.lastIndex = 0;
|
|
812
|
+
while ((match = FILE_PATH_RE.exec(state.output)) !== null) {
|
|
813
|
+
const rawPath = match[1];
|
|
814
|
+
const ext = rawPath.split(".").pop()?.toLowerCase();
|
|
815
|
+
if (!ext || !KNOWN_EXTENSIONS.has(ext))
|
|
816
|
+
continue;
|
|
817
|
+
const cleanPath = rawPath.replace(/^`|`$/g, "");
|
|
818
|
+
if (!fileMap.has(cleanPath)) {
|
|
819
|
+
fileMap.set(cleanPath, { path: cleanPath, summary: "" });
|
|
809
820
|
}
|
|
810
821
|
}
|
|
811
|
-
if (!existing.summary && typeof tr.output === "string") {
|
|
812
|
-
existing.summary = tr.output.slice(0, 100).replace(/\n/g, " ");
|
|
813
|
-
}
|
|
814
822
|
}
|
|
815
823
|
}
|
|
816
824
|
if (typeof part.text === "string") {
|
|
@@ -871,10 +879,10 @@ function extractErrors(messages, maxErrors, windowSize) {
|
|
|
871
879
|
const errorPatterns = /(error|Error|TypeError|ReferenceError|SyntaxError|RangeError|FAIL|failed|cannot find|cannot resolve|not found|unexpected token)/;
|
|
872
880
|
for (const msg of recent) {
|
|
873
881
|
for (const part of msg.parts ?? []) {
|
|
874
|
-
if (part.type !== "
|
|
882
|
+
if (part.type !== "tool" || !part.state)
|
|
875
883
|
continue;
|
|
876
|
-
const
|
|
877
|
-
const output = typeof
|
|
884
|
+
const state = part.state;
|
|
885
|
+
const output = state.status === "error" ? typeof state.error === "string" ? state.error : "" : typeof state.output === "string" ? state.output : "";
|
|
878
886
|
if (!output)
|
|
879
887
|
continue;
|
|
880
888
|
const lines = output.split(`
|
|
@@ -1757,7 +1765,7 @@ var CoHubPlugin = async (input, options) => {
|
|
|
1757
1765
|
output.args[targetField] += details;
|
|
1758
1766
|
}
|
|
1759
1767
|
const finalPrompt = typeof output.args?.prompt === "string" ? output.args.prompt : "";
|
|
1760
|
-
fs2.appendFileSync("
|
|
1768
|
+
fs2.appendFileSync(path2.join(os2.tmpdir(), "opencode", "ctx-diag.log"), JSON.stringify({
|
|
1761
1769
|
time: new Date().toISOString(),
|
|
1762
1770
|
session: input2.sessionID?.slice(0, 20) ?? "?",
|
|
1763
1771
|
subagent: subagentType,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oh-my-opencode-cohub",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/Mr-cjf/oh-my-opencode-cohub.git"
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "bun run scripts/generate-prompts.ts && bun build src/index.ts src/tui.ts --outdir dist --target node --format esm --external @opencode-ai/plugin --external @opencode-ai/plugin/* --external @opencode-ai/sdk --external @opencode-ai/sdk/* --external @opentui/core --external @opentui/solid --external zod && bun build src/cli/index.ts --outdir dist/cli --target node --format esm && tsc --emitDeclarationOnly",
|
|
30
|
+
"test": "bun test",
|
|
30
31
|
"prepublishOnly": "npm run build"
|
|
31
32
|
},
|
|
32
33
|
"keywords": [
|