oh-my-opencode-cohub 1.17.0 → 1.18.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/README.md +2 -3
- package/dist/cli/config-io.d.ts +2 -2
- package/dist/cli/config-io.d.ts.map +1 -1
- package/dist/cli/index.js +209 -67
- package/dist/config/loader.d.ts +4 -0
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/context/diag-log.d.ts +62 -0
- package/dist/context/diag-log.d.ts.map +1 -0
- package/dist/context/engine.d.ts +33 -0
- package/dist/context/engine.d.ts.map +1 -1
- package/dist/context/extractor.d.ts +1 -20
- package/dist/context/extractor.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +605 -663
- package/dist/instructions/chinese.d.ts +1 -1
- package/dist/instructions/chinese.d.ts.map +1 -1
- package/dist/prompts/council.d.ts +1 -1
- package/dist/prompts/council.d.ts.map +1 -1
- package/dist/prompts/oracle.d.ts +1 -1
- package/dist/prompts/oracle.d.ts.map +1 -1
- package/dist/prompts/orchestrator.d.ts +1 -1
- package/dist/prompts/orchestrator.d.ts.map +1 -1
- package/dist/prompts/rule-app.d.ts +1 -1
- package/dist/prompts/rule-app.d.ts.map +1 -1
- package/dist/prompts/rule-project.d.ts +1 -1
- package/dist/prompts/rule-project.d.ts.map +1 -1
- package/dist/prompts/rule-user.d.ts +1 -1
- package/dist/prompts/rule-user.d.ts.map +1 -1
- package/dist/shared/chinese.d.ts +2 -0
- package/dist/shared/chinese.d.ts.map +1 -0
- package/dist/shared/consensus.d.ts +132 -0
- package/dist/shared/consensus.d.ts.map +1 -0
- package/dist/shared/constants.d.ts +26 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/fs-atomic.d.ts +11 -0
- package/dist/shared/fs-atomic.d.ts.map +1 -0
- package/dist/shared/log.d.ts +38 -0
- package/dist/shared/log.d.ts.map +1 -0
- package/dist/shared/model.d.ts +7 -0
- package/dist/shared/model.d.ts.map +1 -0
- package/dist/shared/token-estimator.d.ts +25 -0
- package/dist/shared/token-estimator.d.ts.map +1 -0
- package/dist/task-manager/tracker.d.ts +17 -5
- package/dist/task-manager/tracker.d.ts.map +1 -1
- package/dist/task-manager/types.d.ts +2 -1
- package/dist/task-manager/types.d.ts.map +1 -1
- package/dist/tools/council.d.ts +2 -66
- package/dist/tools/council.d.ts.map +1 -1
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +96 -48
- package/dist/utils/log.d.ts +8 -12
- package/dist/utils/log.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/tools/ocr-review.d.ts +0 -38
- package/dist/tools/ocr-review.d.ts.map +0 -1
- package/dist/tools/ocr-review.test.d.ts +0 -2
- package/dist/tools/ocr-review.test.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../src/task-manager/tracker.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../src/task-manager/tracker.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE/D,OAAO,EAAE,KAAK,eAAe,EAA0B,MAAM,kBAAkB,CAAC;AAIhF,wBAAwB;AACxB,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,mCAAmC;AACnC,eAAO,MAAM,UAAU,QAQtB,CAAC;AAEF,uEAAuE;AACvE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAEjE;AAED,gCAAgC;AAChC,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,CAAC,EAAE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jC;;;;;;OAMG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IAc7C;;;;;;OAMG;IACH,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAc9C;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAKlC,2BAA2B;IAC3B,gBAAgB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,EAAE;IAUnD,uBAAuB;IACvB,eAAe,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM;IAUhD,oCAAoC;IACpC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAS3D;;;OAGG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,GAAG,IAAI;IAWlF;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,QAAQ;IAahB,6BAA6B;IAC7B,OAAO,CAAC,mBAAmB;IAa3B,sDAAsD;IACtD,QAAQ,CAAC,MAAM,GAAE,MAA6B,GAAG,WAAW,EAAE;IAI9D,wDAAwD;IACxD,YAAY,CAAC,MAAM,GAAE,MAA6B,GAAG,IAAI;IAQzD,yDAAyD;IACzD,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAenC;;;;;;;;;OASG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,SAAS,CAAA;KAAE,GAAG,SAAS;CAqB7E"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ContextStrategy } from '../context/types';
|
|
2
|
+
import type { FailureCategory } from './quality';
|
|
2
3
|
export type TaskStatus = 'running' | 'completed' | 'errored' | 'cancelled';
|
|
3
4
|
export interface JobRecord {
|
|
4
5
|
alias: string;
|
|
@@ -18,7 +19,7 @@ export interface JobRecord {
|
|
|
18
19
|
quality?: {
|
|
19
20
|
/** 0-1 质量评分;undefined 表示未执行 assessQuality(与 score:0 的"质量最差"语义区分) */
|
|
20
21
|
score?: number;
|
|
21
|
-
failureCategory?:
|
|
22
|
+
failureCategory?: FailureCategory;
|
|
22
23
|
latencyMs?: number;
|
|
23
24
|
tokens?: {
|
|
24
25
|
input: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/task-manager/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/task-manager/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,CAAC;AAE3E,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB;IACjB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,kBAAkB;IAClB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,8CAA8C;IAC9C,OAAO,CAAC,EAAE;QACR,oEAAoE;QACpE,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,eAAe,CAAC,EAAE,eAAe,CAAC;QAClC,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;KAC5C,CAAC;CACH;AAED,MAAM,WAAW,QAAQ;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB"}
|
package/dist/tools/council.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { tool } from '@opencode-ai/plugin';
|
|
2
2
|
import type { PluginInput } from '@opencode-ai/plugin';
|
|
3
3
|
import type { createOpencodeClient } from '@opencode-ai/sdk';
|
|
4
|
-
import type
|
|
4
|
+
import { type CouncillorSummary, type ConsensusInput, type ConsensusResult, type RetryAction, RETRY_LIMITS, tokenize, jaccard, downgradeVariant, pairwiseAgreement, computeConsensus, decideRetryAction, appendRetryContext, classifyFailure, extractCouncillorSummary, RetryBudget } from '../shared/consensus.js';
|
|
5
|
+
export { type CouncillorSummary, type ConsensusInput, type ConsensusResult, type RetryAction, RETRY_LIMITS, tokenize, jaccard, pairwiseAgreement, computeConsensus, decideRetryAction, downgradeVariant, appendRetryContext, extractCouncillorSummary, classifyFailure, RetryBudget, };
|
|
5
6
|
export interface CouncillorConfig {
|
|
6
7
|
/** "provider/model" */
|
|
7
8
|
model: string;
|
|
@@ -43,70 +44,6 @@ interface CouncillorResult {
|
|
|
43
44
|
/** Optional structured summary used for consensus detection */
|
|
44
45
|
summary?: CouncillorSummary;
|
|
45
46
|
}
|
|
46
|
-
/** Structured summary extracted from a councillor response (T3) */
|
|
47
|
-
export interface CouncillorSummary {
|
|
48
|
-
conclusions: string[];
|
|
49
|
-
entities: string[];
|
|
50
|
-
}
|
|
51
|
-
/** Consensus detection input */
|
|
52
|
-
export interface ConsensusInput {
|
|
53
|
-
name: string;
|
|
54
|
-
summary: CouncillorSummary;
|
|
55
|
-
}
|
|
56
|
-
/** Consensus detection result */
|
|
57
|
-
export interface ConsensusResult {
|
|
58
|
-
consensus: boolean;
|
|
59
|
-
agreementScores: Record<string, number>;
|
|
60
|
-
averageAgreement: number;
|
|
61
|
-
}
|
|
62
|
-
/** Retry decision outcome (T2 decision table) */
|
|
63
|
-
export type RetryAction = 'retry' | 'needs-human' | 'give-up' | 'budget-exhausted';
|
|
64
|
-
/** Per-category retry limits (empty keeps the legacy councillor_retries default) */
|
|
65
|
-
export declare const RETRY_LIMITS: Record<FailureCategory, number>;
|
|
66
|
-
/** Map an error message to a failure category. */
|
|
67
|
-
export declare function classifyFailure(message: string): FailureCategory;
|
|
68
|
-
/**
|
|
69
|
-
* Heuristically extract a structured summary (conclusion sentences + key
|
|
70
|
-
* entity/decision sentences) from a councillor response text.
|
|
71
|
-
*/
|
|
72
|
-
export declare function extractCouncillorSummary(text: string): CouncillorSummary;
|
|
73
|
-
/**
|
|
74
|
-
* Pairwise agreement between two summaries: 0.5 * conclusion overlap
|
|
75
|
-
* + 0.5 * entity overlap (Jaccard on tokens).
|
|
76
|
-
*/
|
|
77
|
-
export declare function pairwiseAgreement(a: CouncillorSummary, b: CouncillorSummary): number;
|
|
78
|
-
/**
|
|
79
|
-
* Compute consensus across councillor summaries.
|
|
80
|
-
* Converged when >= ceil(2n/3) councillors have an average pairwise
|
|
81
|
-
* agreement at or above the threshold.
|
|
82
|
-
*/
|
|
83
|
-
export declare function computeConsensus(inputs: ConsensusInput[], threshold: number): ConsensusResult;
|
|
84
|
-
/**
|
|
85
|
-
* T2 retry decision table.
|
|
86
|
-
* - consecutiveStreak >= 2 of the same category -> needs-human
|
|
87
|
-
* - per-category retry limit reached -> give-up
|
|
88
|
-
* - shared budget exhausted -> budget-exhausted
|
|
89
|
-
* - otherwise -> retry
|
|
90
|
-
*/
|
|
91
|
-
export declare function decideRetryAction(category: FailureCategory, consecutiveStreak: number, categoryRetriesUsed: number, budgetAvailable: boolean, categoryLimit?: number): RetryAction;
|
|
92
|
-
/** Downgrade a variant one step ("max" -> "high" -> "medium" -> "low" -> undefined). */
|
|
93
|
-
export declare function downgradeVariant(variant?: string): string | undefined;
|
|
94
|
-
/** Append retry guidance to the prompt based on the failure category. */
|
|
95
|
-
export declare function appendRetryContext(prompt: string, category: FailureCategory): string;
|
|
96
|
-
/**
|
|
97
|
-
* Shared retry budget (T4): a total retry counter plus an elapsed-time cap.
|
|
98
|
-
* Both runCouncillorWithRetry retries and serial extra rounds draw from it.
|
|
99
|
-
*/
|
|
100
|
-
export declare class RetryBudget {
|
|
101
|
-
retriesLeft: number;
|
|
102
|
-
readonly maxElapsedMs: number;
|
|
103
|
-
readonly startedAt: number;
|
|
104
|
-
constructor(maxTotalRetries: number, maxElapsedMs: number, startedAt?: number);
|
|
105
|
-
elapsedMs(): number;
|
|
106
|
-
expired(): boolean;
|
|
107
|
-
/** Consume one retry slot; returns false when exhausted or expired. */
|
|
108
|
-
consumeRetry(): boolean;
|
|
109
|
-
}
|
|
110
47
|
export declare class CouncilManager {
|
|
111
48
|
private client;
|
|
112
49
|
private directory;
|
|
@@ -138,5 +75,4 @@ export declare class CouncilManager {
|
|
|
138
75
|
* Only the `co-council` agent is allowed to invoke this tool.
|
|
139
76
|
*/
|
|
140
77
|
export declare function createCouncilTool(ctx: PluginInput, councilManager: CouncilManager): Record<string, ReturnType<typeof tool>>;
|
|
141
|
-
export {};
|
|
142
78
|
//# sourceMappingURL=council.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"council.d.ts","sourceRoot":"","sources":["../../src/tools/council.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"council.d.ts","sourceRoot":"","sources":["../../src/tools/council.ts"],"names":[],"mappings":"AAMA,OAA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AAC,OAAO,IAAI,CAAC,CAAC,CAoEzC"}
|
package/dist/tui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../src/tui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AA+E/D,QAAA,MAAM,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../src/tui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AA+E/D,QAAA,MAAM,MAAM,EAAE,eAwIb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/tui.js
CHANGED
|
@@ -1,56 +1,68 @@
|
|
|
1
1
|
// src/tui.ts
|
|
2
2
|
import { jsx } from "@opentui/solid/jsx-runtime";
|
|
3
3
|
import * as fs2 from "node:fs";
|
|
4
|
-
import * as
|
|
4
|
+
import * as path3 from "node:path";
|
|
5
5
|
import * as os2 from "node:os";
|
|
6
6
|
|
|
7
7
|
// src/utils/log.ts
|
|
8
|
-
import * as fs from "fs/promises";
|
|
9
|
-
import * as path from "path";
|
|
10
8
|
import * as os from "os";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
import * as path2 from "path";
|
|
10
|
+
|
|
11
|
+
// src/shared/log.ts
|
|
12
|
+
import * as fs from "node:fs";
|
|
13
|
+
import * as fsp from "node:fs/promises";
|
|
14
|
+
import * as path from "node:path";
|
|
15
|
+
function createLogger(cfg) {
|
|
16
|
+
const logDir = cfg.logDir;
|
|
17
|
+
const prefix = cfg.prefix;
|
|
18
|
+
const linePrefix = cfg.linePrefix ?? cfg.prefix;
|
|
19
|
+
const dailyRotate = cfg.dailyRotate ?? true;
|
|
20
|
+
const keepDays = cfg.keepDays ?? 7;
|
|
21
|
+
const useAsync = cfg.async ?? true;
|
|
22
|
+
let today = "";
|
|
23
|
+
let logPath = "";
|
|
24
|
+
let cleanedToday = false;
|
|
25
|
+
function getLogPath() {
|
|
26
|
+
if (!dailyRotate) {
|
|
27
|
+
return path.join(logDir, `${prefix}.log`);
|
|
28
|
+
}
|
|
29
|
+
const d = new Date().toISOString().slice(0, 10).replace(/-/g, "");
|
|
30
|
+
if (d !== today) {
|
|
31
|
+
today = d;
|
|
32
|
+
logPath = path.join(logDir, `${prefix}.${d}.log`);
|
|
33
|
+
cleanedToday = false;
|
|
34
|
+
}
|
|
35
|
+
return logPath;
|
|
23
36
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
function cleanOldLogsOnce() {
|
|
38
|
+
if (!dailyRotate)
|
|
39
|
+
return;
|
|
40
|
+
getLogPath();
|
|
41
|
+
if (cleanedToday)
|
|
42
|
+
return;
|
|
43
|
+
cleanedToday = true;
|
|
44
|
+
try {
|
|
45
|
+
const cutoff = new Date;
|
|
46
|
+
cutoff.setUTCDate(cutoff.getUTCDate() - keepDays);
|
|
47
|
+
const cutoffStr = cutoff.toISOString().slice(0, 10).replace(/-/g, "");
|
|
48
|
+
const files = fs.readdirSync(logDir);
|
|
49
|
+
const escaped = prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
50
|
+
const re = new RegExp(`^${escaped}\\.(\\d{8})\\.log$`);
|
|
51
|
+
for (const file of files) {
|
|
52
|
+
const match = file.match(re);
|
|
53
|
+
if (!match)
|
|
54
|
+
continue;
|
|
55
|
+
if (match[1] < cutoffStr) {
|
|
56
|
+
try {
|
|
57
|
+
fs.unlinkSync(path.join(logDir, file));
|
|
58
|
+
} catch {}
|
|
59
|
+
}
|
|
44
60
|
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async function appendLog(tag, message, err) {
|
|
49
|
-
try {
|
|
50
|
-
const logPath = getLogPath();
|
|
51
|
-
await fs.mkdir(LOG_DIR, { recursive: true });
|
|
61
|
+
} catch {}
|
|
62
|
+
}
|
|
63
|
+
function formatLine(tag, message, err) {
|
|
52
64
|
const now = new Date().toISOString();
|
|
53
|
-
let line = `[${now}] [
|
|
65
|
+
let line = `[${now}] [${linePrefix}] [${tag}] ${message}`;
|
|
54
66
|
if (err instanceof Error) {
|
|
55
67
|
line += `
|
|
56
68
|
stack: ${err.stack ?? err.message}`;
|
|
@@ -60,13 +72,47 @@ async function appendLog(tag, message, err) {
|
|
|
60
72
|
}
|
|
61
73
|
line += `
|
|
62
74
|
`;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
75
|
+
return line;
|
|
76
|
+
}
|
|
77
|
+
if (useAsync) {
|
|
78
|
+
async function appendLogAsync(tag, message, err) {
|
|
79
|
+
try {
|
|
80
|
+
const lp = getLogPath();
|
|
81
|
+
await fsp.mkdir(logDir, { recursive: true });
|
|
82
|
+
const line = formatLine(tag, message, err);
|
|
83
|
+
await fsp.appendFile(lp, line, "utf-8");
|
|
84
|
+
if (dailyRotate)
|
|
85
|
+
cleanOldLogsOnce();
|
|
86
|
+
} catch {}
|
|
87
|
+
}
|
|
88
|
+
return appendLogAsync;
|
|
89
|
+
}
|
|
90
|
+
function appendLogSync(tag, message, err) {
|
|
91
|
+
try {
|
|
92
|
+
const lp = getLogPath();
|
|
93
|
+
fs.mkdirSync(logDir, { recursive: true });
|
|
94
|
+
const line = formatLine(tag, message, err);
|
|
95
|
+
fs.appendFileSync(lp, line, "utf-8");
|
|
96
|
+
if (dailyRotate)
|
|
97
|
+
cleanOldLogsOnce();
|
|
98
|
+
} catch {}
|
|
99
|
+
}
|
|
100
|
+
return appendLogSync;
|
|
66
101
|
}
|
|
67
102
|
|
|
103
|
+
// src/utils/log.ts
|
|
104
|
+
var LOG_DIR = path2.join(os.homedir(), ".local", "share", "opencode", "log");
|
|
105
|
+
var appendLog = createLogger({
|
|
106
|
+
logDir: LOG_DIR,
|
|
107
|
+
prefix: "oh-my-opencode-cohub",
|
|
108
|
+
linePrefix: "oh-my-opencode-cohub",
|
|
109
|
+
dailyRotate: true,
|
|
110
|
+
keepDays: 7,
|
|
111
|
+
async: true
|
|
112
|
+
});
|
|
113
|
+
|
|
68
114
|
// src/tui.ts
|
|
69
|
-
var AGENT_CONFIG_FILE =
|
|
115
|
+
var AGENT_CONFIG_FILE = path3.join(os2.homedir(), ".config", "opencode", "oh-my-opencode-cohub.json");
|
|
70
116
|
function loadAgentConfig() {
|
|
71
117
|
try {
|
|
72
118
|
if (!fs2.existsSync(AGENT_CONFIG_FILE))
|
|
@@ -119,7 +165,7 @@ function DEFAULT_AGENTS() {
|
|
|
119
165
|
};
|
|
120
166
|
});
|
|
121
167
|
}
|
|
122
|
-
var STATE_FILE =
|
|
168
|
+
var STATE_FILE = path3.join(os2.homedir(), ".local", "share", "opencode", "storage", "oh-my-opencode-cohub", "tracker-state.json");
|
|
123
169
|
var SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
124
170
|
function readState() {
|
|
125
171
|
try {
|
|
@@ -162,6 +208,8 @@ var plugin = {
|
|
|
162
208
|
if (state && state.runningCount > 0)
|
|
163
209
|
api.renderer.requestRender();
|
|
164
210
|
}, 100);
|
|
211
|
+
if (typeof spinnerTimer.unref === "function")
|
|
212
|
+
spinnerTimer.unref();
|
|
165
213
|
api.slots.register({
|
|
166
214
|
order: 800,
|
|
167
215
|
slots: {
|
package/dist/utils/log.d.ts
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* oh-my-opencode-cohub
|
|
2
|
+
* oh-my-opencode-cohub 诊断日志工具(共享层适配壳)。
|
|
3
|
+
*
|
|
4
|
+
* 实现已上移到 cohub-shared/src/log.ts(sync 到 src/shared/log.ts),
|
|
5
|
+
* 此处仅做工厂实例化,以维持既有 import 路径与调用签名不变。
|
|
3
6
|
*
|
|
4
7
|
* 日志路径:~/.local/share/opencode/log/oh-my-opencode-cohub.YYYYMMDD.log
|
|
5
|
-
* 保留天数:7
|
|
8
|
+
* 保留天数:7 天
|
|
6
9
|
* 格式:[ISO时间] [oh-my-opencode-cohub] [tag] message
|
|
7
|
-
*
|
|
8
|
-
* 内部 try-catch 自保护——日志写入失败不影响主业务。
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* 追加一条诊断日志
|
|
12
|
-
*
|
|
13
|
-
* @param tag 标签(如 hook 名称、函数名)
|
|
14
|
-
* @param message 描述信息
|
|
15
|
-
* @param err 可选,错误对象,存在时会自动追加 err.stack
|
|
16
10
|
*/
|
|
17
|
-
|
|
11
|
+
import { type LogFn } from '../shared/log';
|
|
12
|
+
/** 追加一条诊断日志(异步,失败静默)。 */
|
|
13
|
+
export declare const appendLog: LogFn;
|
|
18
14
|
//# sourceMappingURL=log.d.ts.map
|
package/dist/utils/log.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAgB,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AAIzD,yBAAyB;AACzB,eAAO,MAAM,SAAS,EAAE,KAOtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oh-my-opencode-cohub",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
|
-
"url": "git+https://github.com/Mr-cjf/
|
|
6
|
+
"url": "git+https://github.com/Mr-cjf/cohub.git",
|
|
7
|
+
"directory": "packages/oh-my-opencode-cohub"
|
|
7
8
|
},
|
|
8
9
|
"description": "OpenCode 中文智能体编排插件 CoHub - 纯调度模式 / 全中文提示词 / 规范分析代理 / 方案制定代理 / 独立运行",
|
|
9
10
|
"type": "module",
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { tool } from '@opencode-ai/plugin';
|
|
2
|
-
import type { PluginInput } from '@opencode-ai/plugin';
|
|
3
|
-
/**
|
|
4
|
-
* Detect whether the `ocr` CLI is available on the system.
|
|
5
|
-
* Result is cached in a module-level variable after the first call.
|
|
6
|
-
* Pass `force = true` to re-detect.
|
|
7
|
-
*/
|
|
8
|
-
export declare function detectOcrCli(force?: boolean): Promise<boolean>;
|
|
9
|
-
interface OcrArgsInput {
|
|
10
|
-
from: string;
|
|
11
|
-
to?: string;
|
|
12
|
-
background?: string;
|
|
13
|
-
preview?: boolean;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Build the CLI argument array for the `ocr` command.
|
|
17
|
-
*/
|
|
18
|
-
export declare function buildOcrArgs(input: OcrArgsInput, projectDir: string): string[];
|
|
19
|
-
/**
|
|
20
|
-
* Format OCR output with truncation to prevent context flooding.
|
|
21
|
-
* If the output is not valid JSON (e.g. preview mode plain text),
|
|
22
|
-
* returns the raw text directly.
|
|
23
|
-
*/
|
|
24
|
-
export declare function formatOcrOutput(raw: string): string;
|
|
25
|
-
/**
|
|
26
|
-
* Create the `co_ocr_review` tool definition.
|
|
27
|
-
*
|
|
28
|
-
* Provides optional integration with the local @alibaba-group/open-code-review CLI.
|
|
29
|
-
* Soft dependency: if OCR is not installed, returns a guidance string.
|
|
30
|
-
* Only the co-oracle agent is allowed to invoke this tool.
|
|
31
|
-
*
|
|
32
|
-
* @param ctx Plugin input
|
|
33
|
-
* @param projectDir Project root directory (used as --repo)
|
|
34
|
-
* @param ocrAvailable Whether the OCR CLI is installed (from detectOcrCli)
|
|
35
|
-
*/
|
|
36
|
-
export declare function createOcrReviewTool(ctx: PluginInput, projectDir: string, ocrAvailable: boolean): Record<string, ReturnType<typeof tool>>;
|
|
37
|
-
export {};
|
|
38
|
-
//# sourceMappingURL=ocr-review.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ocr-review.d.ts","sourceRoot":"","sources":["../../src/tools/ocr-review.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAYvD;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,KAAK,UAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CASlE;AAMD,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAkB9E;AAwID;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA+FnD;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,OAAO,GACpB,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,CA2FzC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ocr-review.test.d.ts","sourceRoot":"","sources":["../../src/tools/ocr-review.test.ts"],"names":[],"mappings":""}
|