@dommaker/harness 0.12.10 → 0.12.12
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/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +2 -0
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/validate.d.ts +4 -0
- package/dist/cli/commands/validate.d.ts.map +1 -1
- package/dist/cli/commands/validate.js +33 -0
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +1 -0
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/definitions.d.ts.map +1 -1
- package/dist/core/constraints/definitions.js +15 -0
- package/dist/core/constraints/definitions.js.map +1 -1
- package/dist/types/constraint.d.ts +2 -0
- package/dist/types/constraint.d.ts.map +1 -1
- package/dist/types/constraint.js.map +1 -1
- package/package.json +2 -2
- package/bin/harness-knowledge-capture.js +0 -99
- package/bin/harness-knowledge-check.js +0 -63
- package/bin/harness-knowledge-track.js +0 -92
- package/bin/harness-knowledge-track.sh +0 -34
- package/dist/cli/commands/diagnose.d.ts +0 -16
- package/dist/cli/commands/diagnose.d.ts.map +0 -1
- package/dist/cli/commands/diagnose.js +0 -195
- package/dist/cli/commands/diagnose.js.map +0 -1
- package/dist/cli/commands/propose.d.ts +0 -18
- package/dist/cli/commands/propose.d.ts.map +0 -1
- package/dist/cli/commands/propose.js +0 -331
- package/dist/cli/commands/propose.js.map +0 -1
- package/dist/cli/commands/traces.d.ts +0 -15
- package/dist/cli/commands/traces.d.ts.map +0 -1
- package/dist/cli/commands/traces.js +0 -167
- package/dist/cli/commands/traces.js.map +0 -1
- package/dist/constraints/definitions.d.ts +0 -39
- package/dist/constraints/definitions.d.ts.map +0 -1
- package/dist/constraints/definitions.js +0 -71
- package/dist/constraints/definitions.js.map +0 -1
- package/dist/constraints/quality.d.ts +0 -11
- package/dist/constraints/quality.d.ts.map +0 -1
- package/dist/constraints/quality.js +0 -257
- package/dist/constraints/quality.js.map +0 -1
- package/dist/constraints/safety.d.ts +0 -13
- package/dist/constraints/safety.d.ts.map +0 -1
- package/dist/constraints/safety.js +0 -103
- package/dist/constraints/safety.js.map +0 -1
- package/dist/extensions/long-running/constraints.d.ts +0 -38
- package/dist/extensions/long-running/constraints.d.ts.map +0 -1
- package/dist/extensions/long-running/constraints.js +0 -153
- package/dist/extensions/long-running/constraints.js.map +0 -1
- package/dist/extensions/long-running/index.d.ts +0 -30
- package/dist/extensions/long-running/index.d.ts.map +0 -1
- package/dist/extensions/long-running/index.js +0 -50
- package/dist/extensions/long-running/index.js.map +0 -1
- package/dist/extensions/long-running/types.d.ts +0 -154
- package/dist/extensions/long-running/types.d.ts.map +0 -1
- package/dist/extensions/long-running/types.js +0 -9
- package/dist/extensions/long-running/types.js.map +0 -1
- package/dist/presets/long-running.d.ts +0 -33
- package/dist/presets/long-running.d.ts.map +0 -1
- package/dist/presets/long-running.js +0 -52
- package/dist/presets/long-running.js.map +0 -1
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Stop hook — check if deep analysis happened without knowledge capture
|
|
4
|
-
*
|
|
5
|
-
* Reads state file written by harness-knowledge-track.js.
|
|
6
|
-
* If EnterPlanMode was called, or Agent(Explore) was spawned, or 10+ unique
|
|
7
|
-
* directories were Read — and no knowledge files were Written — warn.
|
|
8
|
-
*
|
|
9
|
-
* Output: JSON with systemMessage (shown to user)
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const fs = require('fs');
|
|
13
|
-
const STATE_FILE = '/tmp/claude-knowledge-capture-state.json';
|
|
14
|
-
const LOG_FILE = '/tmp/claude-knowledge-hooks.log';
|
|
15
|
-
const UNIQUE_DIR_THRESHOLD = 10;
|
|
16
|
-
|
|
17
|
-
function log(level, message, data) {
|
|
18
|
-
try {
|
|
19
|
-
const entry = JSON.stringify({ ts: new Date().toISOString(), level, message, ...data }) + '\n';
|
|
20
|
-
fs.appendFileSync(LOG_FILE, entry, 'utf-8');
|
|
21
|
-
} catch {}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
if (!fs.existsSync(STATE_FILE)) process.exit(0);
|
|
26
|
-
|
|
27
|
-
const state = JSON.parse(fs.readFileSync(STATE_FILE, 'utf-8'));
|
|
28
|
-
const deepAnalysis = state.planned || state.explored || state.readDirs.length >= UNIQUE_DIR_THRESHOLD;
|
|
29
|
-
const missingCapture = !state.captured;
|
|
30
|
-
|
|
31
|
-
log('info', 'stop-check', {
|
|
32
|
-
planned: state.planned, explored: state.explored,
|
|
33
|
-
readDirsCount: state.readDirs.length, captured: state.captured,
|
|
34
|
-
deepAnalysis, missingCapture,
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
if (deepAnalysis && missingCapture) {
|
|
38
|
-
const signals = [];
|
|
39
|
-
if (state.planned) signals.push('EnterPlanMode called');
|
|
40
|
-
if (state.explored) signals.push('Agent(Explore) spawned');
|
|
41
|
-
if (state.readDirs.length >= UNIQUE_DIR_THRESHOLD) signals.push(`${state.readDirs.length} unique directories Read`);
|
|
42
|
-
|
|
43
|
-
log('warn', 'missing-capture', { signals });
|
|
44
|
-
|
|
45
|
-
const message = [
|
|
46
|
-
'⚠️ Deep analysis detected but no knowledge captured.',
|
|
47
|
-
` Signals: ${signals.join(', ')}`,
|
|
48
|
-
'',
|
|
49
|
-
' To capture:',
|
|
50
|
-
' 1. Write .harness/knowledge-docs/<scope>.md',
|
|
51
|
-
' 2. npx harness knowledge upsert --scope <scope> --file <file> --source claude',
|
|
52
|
-
'',
|
|
53
|
-
' Or run `harness knowledge sync-status` to check staleness.',
|
|
54
|
-
].join('\n');
|
|
55
|
-
|
|
56
|
-
console.log(JSON.stringify({ systemMessage: message }));
|
|
57
|
-
}
|
|
58
|
-
} catch (e) {
|
|
59
|
-
// Silently ignore errors
|
|
60
|
-
} finally {
|
|
61
|
-
// Clean up state file for next session
|
|
62
|
-
try { fs.unlinkSync(STATE_FILE); } catch {}
|
|
63
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* PostToolUse hook — track deep analysis signals
|
|
4
|
-
*
|
|
5
|
-
* Updates state file with:
|
|
6
|
-
* - planned: EnterPlanMode was called
|
|
7
|
-
* - explored: Agent(Explore) was spawned
|
|
8
|
-
* - readDirs: Set of unique directories Read was called on
|
|
9
|
-
* - captured: Write to .harness/knowledge-docs/ or .harness/knowledge/
|
|
10
|
-
* - turnCount: session turn counter
|
|
11
|
-
*
|
|
12
|
-
* Usage: PostToolUse hook with matcher "EnterPlanMode|Agent|Read|Write|Write"
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const fs = require('fs');
|
|
16
|
-
const path = require('path');
|
|
17
|
-
|
|
18
|
-
const STATE_FILE = '/tmp/claude-knowledge-capture-state.json';
|
|
19
|
-
const LOG_FILE = '/tmp/claude-knowledge-hooks.log';
|
|
20
|
-
|
|
21
|
-
function log(level, message, data) {
|
|
22
|
-
try {
|
|
23
|
-
const entry = JSON.stringify({ ts: new Date().toISOString(), level, message, ...data }) + '\n';
|
|
24
|
-
fs.appendFileSync(LOG_FILE, entry, 'utf-8');
|
|
25
|
-
} catch {}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Read hook input from stdin
|
|
29
|
-
let input = '';
|
|
30
|
-
process.stdin.setEncoding('utf-8');
|
|
31
|
-
process.stdin.on('data', (chunk) => input += chunk);
|
|
32
|
-
|
|
33
|
-
process.stdin.on('end', () => {
|
|
34
|
-
try {
|
|
35
|
-
const event = JSON.parse(input);
|
|
36
|
-
const state = loadState();
|
|
37
|
-
updateState(state, event);
|
|
38
|
-
saveState(state);
|
|
39
|
-
} catch (e) {
|
|
40
|
-
// Silently ignore parse errors
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
function loadState() {
|
|
45
|
-
try {
|
|
46
|
-
if (fs.existsSync(STATE_FILE)) {
|
|
47
|
-
return JSON.parse(fs.readFileSync(STATE_FILE, 'utf-8'));
|
|
48
|
-
}
|
|
49
|
-
} catch {}
|
|
50
|
-
return { planned: false, explored: false, readDirs: [], captured: false };
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function updateState(state, event) {
|
|
54
|
-
const toolName = event.tool_name || '';
|
|
55
|
-
|
|
56
|
-
if (toolName === 'EnterPlanMode') {
|
|
57
|
-
state.planned = true;
|
|
58
|
-
log('info', 'planned', { tool: toolName });
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (toolName === 'Agent') {
|
|
62
|
-
const input = event.tool_input || {};
|
|
63
|
-
if (input.subagent_type === 'Explore') {
|
|
64
|
-
state.explored = true;
|
|
65
|
-
log('info', 'explored', { tool: toolName, subagent_type: input.subagent_type });
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (toolName === 'Read') {
|
|
70
|
-
const input = event.tool_input || {};
|
|
71
|
-
const filePath = input.file_path || '';
|
|
72
|
-
const dir = path.dirname(filePath);
|
|
73
|
-
if (dir && dir !== '.' && dir !== '/' && !state.readDirs.includes(dir)) {
|
|
74
|
-
state.readDirs.push(dir);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (toolName === 'Write') {
|
|
79
|
-
const input = event.tool_input || {};
|
|
80
|
-
const filePath = input.file_path || '';
|
|
81
|
-
if (filePath.includes('.harness/knowledge-docs/') || filePath.includes('.harness/knowledge/')) {
|
|
82
|
-
state.captured = true;
|
|
83
|
-
log('info', 'captured', { file: filePath });
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function saveState(state) {
|
|
89
|
-
try {
|
|
90
|
-
fs.writeFileSync(STATE_FILE, JSON.stringify(state), 'utf-8');
|
|
91
|
-
} catch {}
|
|
92
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# PostToolUse hook — track deep analysis signals
|
|
3
|
-
# Replaces Node.js version. Bash: <1ms vs Node: 33ms cold start.
|
|
4
|
-
# Matcher: Read|Write (most frequent tools, covers all signals needed)
|
|
5
|
-
|
|
6
|
-
STATE_FILE=/tmp/claude-knowledge-capture-state.json
|
|
7
|
-
INPUT=$(cat)
|
|
8
|
-
|
|
9
|
-
tool_name=$(echo "$INPUT" | jq -r '.tool_name // ""')
|
|
10
|
-
file_path=$(echo "$INPUT" | jq -r '.tool_input.file_path // ""')
|
|
11
|
-
|
|
12
|
-
# Init state file if missing
|
|
13
|
-
[ -f "$STATE_FILE" ] || echo '{"planned":false,"explored":false,"readDirs":[],"captured":false}' > "$STATE_FILE"
|
|
14
|
-
|
|
15
|
-
case "$tool_name" in
|
|
16
|
-
EnterPlanMode)
|
|
17
|
-
jq '.planned = true' "$STATE_FILE" > "${STATE_FILE}.tmp" && mv "${STATE_FILE}.tmp" "$STATE_FILE"
|
|
18
|
-
;;
|
|
19
|
-
Read)
|
|
20
|
-
if [ -n "$file_path" ]; then
|
|
21
|
-
dir=$(dirname "$file_path")
|
|
22
|
-
if [ "$dir" != "." ] && [ "$dir" != "/" ]; then
|
|
23
|
-
jq --arg d "$dir" '.readDirs += [$d] | .readDirs |= unique' "$STATE_FILE" > "${STATE_FILE}.tmp" && mv "${STATE_FILE}.tmp" "$STATE_FILE"
|
|
24
|
-
fi
|
|
25
|
-
fi
|
|
26
|
-
;;
|
|
27
|
-
Write)
|
|
28
|
-
case "$file_path" in
|
|
29
|
-
*.harness/knowledge-docs/*|*.harness/knowledge/*)
|
|
30
|
-
jq '.captured = true' "$STATE_FILE" > "${STATE_FILE}.tmp" && mv "${STATE_FILE}.tmp" "$STATE_FILE"
|
|
31
|
-
;;
|
|
32
|
-
esac
|
|
33
|
-
;;
|
|
34
|
-
esac
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Diagnose CLI 命令
|
|
3
|
-
*
|
|
4
|
-
* 运行诊断分析异常
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* diagnose 命令
|
|
8
|
-
*/
|
|
9
|
-
export declare function diagnoseCommand(subcommand: string, options: {
|
|
10
|
-
hours?: number;
|
|
11
|
-
constraintId?: string;
|
|
12
|
-
anomalyId?: string;
|
|
13
|
-
format?: 'json' | 'text';
|
|
14
|
-
save?: boolean;
|
|
15
|
-
}): Promise<void>;
|
|
16
|
-
//# sourceMappingURL=diagnose.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diagnose.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/diagnose.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH;;GAEG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;IACP,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,GACA,OAAO,CAAC,IAAI,CAAC,CA6Bf"}
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Diagnose CLI 命令
|
|
4
|
-
*
|
|
5
|
-
* 运行诊断分析异常
|
|
6
|
-
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.diagnoseCommand = diagnoseCommand;
|
|
42
|
-
const fs = __importStar(require("fs"));
|
|
43
|
-
const path = __importStar(require("path"));
|
|
44
|
-
const traces_1 = require("../../monitoring/traces");
|
|
45
|
-
const trace_analyzer_1 = require("../../monitoring/trace-analyzer");
|
|
46
|
-
const constraint_doctor_1 = require("../../monitoring/constraint-doctor");
|
|
47
|
-
/**
|
|
48
|
-
* diagnose 命令
|
|
49
|
-
*/
|
|
50
|
-
async function diagnoseCommand(subcommand, options) {
|
|
51
|
-
switch (subcommand) {
|
|
52
|
-
case 'run':
|
|
53
|
-
await runDiagnose(options);
|
|
54
|
-
break;
|
|
55
|
-
case 'show':
|
|
56
|
-
await showDiagnose(options);
|
|
57
|
-
break;
|
|
58
|
-
case 'list':
|
|
59
|
-
await listDiagnoses(options);
|
|
60
|
-
break;
|
|
61
|
-
default:
|
|
62
|
-
console.log('Usage: harness diagnose <subcommand>');
|
|
63
|
-
console.log('');
|
|
64
|
-
console.log('Subcommands:');
|
|
65
|
-
console.log(' run Run diagnosis on detected anomalies');
|
|
66
|
-
console.log(' show Show a specific diagnosis result');
|
|
67
|
-
console.log(' list List all diagnosis results');
|
|
68
|
-
console.log('');
|
|
69
|
-
console.log('Options:');
|
|
70
|
-
console.log(' --hours <n> Analyze last N hours (default: 24)');
|
|
71
|
-
console.log(' --constraint <id> Filter by constraint ID');
|
|
72
|
-
console.log(' --anomaly <id> Show specific anomaly diagnosis');
|
|
73
|
-
console.log(' --format <format> Output format: json or text (default: text)');
|
|
74
|
-
console.log(' --save Save diagnosis to file');
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* 运行诊断
|
|
79
|
-
*/
|
|
80
|
-
async function runDiagnose(options) {
|
|
81
|
-
const hours = options.hours || 24;
|
|
82
|
-
const analyzer = (0, trace_analyzer_1.createAnalyzer)();
|
|
83
|
-
const doctor = (0, constraint_doctor_1.createDoctor)();
|
|
84
|
-
// 1. 检测异常
|
|
85
|
-
const anomalies = analyzer.runDailyAnomalyCheck();
|
|
86
|
-
// 过滤特定约束
|
|
87
|
-
let filteredAnomalies = anomalies;
|
|
88
|
-
if (options.constraintId) {
|
|
89
|
-
filteredAnomalies = anomalies.filter(a => a.constraintId === options.constraintId);
|
|
90
|
-
}
|
|
91
|
-
if (filteredAnomalies.length === 0) {
|
|
92
|
-
console.log('✅ No anomalies detected. No diagnosis needed.');
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
console.log(`🔍 Detected ${filteredAnomalies.length} anomalies, running diagnosis...`);
|
|
96
|
-
console.log('');
|
|
97
|
-
// 2. 获取 traces
|
|
98
|
-
const collector = (0, traces_1.getTraceCollector)();
|
|
99
|
-
const traces = collector.readRecent(hours);
|
|
100
|
-
// 3. 运行诊断
|
|
101
|
-
const diagnoses = [];
|
|
102
|
-
for (const anomaly of filteredAnomalies) {
|
|
103
|
-
doctor.setData(traces.filter(t => t.constraintId === anomaly.constraintId));
|
|
104
|
-
const diagnosis = await doctor.diagnose(anomaly);
|
|
105
|
-
diagnoses.push(diagnosis);
|
|
106
|
-
// 保存诊断
|
|
107
|
-
if (options.save) {
|
|
108
|
-
const outputPath = `.harness/diagnoses/${diagnosis.anomalyId}.json`;
|
|
109
|
-
doctor.saveDiagnosis(diagnosis, outputPath);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
// 4. 输出结果
|
|
113
|
-
if (options.format === 'json') {
|
|
114
|
-
console.log(JSON.stringify(diagnoses, null, 2));
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
for (const diagnosis of diagnoses) {
|
|
118
|
-
console.log(doctor.generateReport(diagnosis));
|
|
119
|
-
console.log('---');
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
// 5. 统计
|
|
123
|
-
const needsChange = diagnoses.filter(d => d.needsChange).length;
|
|
124
|
-
console.log('');
|
|
125
|
-
console.log(`📊 Summary: ${needsChange} diagnoses need constraint changes`);
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* 显示特定诊断
|
|
129
|
-
*/
|
|
130
|
-
async function showDiagnose(options) {
|
|
131
|
-
if (!options.anomalyId) {
|
|
132
|
-
console.log('❌ Please specify --anomaly <id>');
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
const doctor = (0, constraint_doctor_1.createDoctor)();
|
|
136
|
-
const diagnosisPath = `.harness/diagnoses/${options.anomalyId}.json`;
|
|
137
|
-
if (!fs.existsSync(diagnosisPath)) {
|
|
138
|
-
console.log(`❌ Diagnosis not found: ${options.anomalyId}`);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
const diagnosis = doctor.loadDiagnosis(diagnosisPath);
|
|
142
|
-
if (options.format === 'json') {
|
|
143
|
-
console.log(JSON.stringify(diagnosis, null, 2));
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
console.log(doctor.generateReport(diagnosis));
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* 列出所有诊断
|
|
151
|
-
*/
|
|
152
|
-
async function listDiagnoses(options) {
|
|
153
|
-
const diagnosesDir = '.harness/diagnoses';
|
|
154
|
-
if (!fs.existsSync(diagnosesDir)) {
|
|
155
|
-
console.log('❌ No diagnoses found. Run `harness diagnose run` first.');
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
const files = fs.readdirSync(diagnosesDir)
|
|
159
|
-
.filter(f => f.endsWith('.json'));
|
|
160
|
-
if (files.length === 0) {
|
|
161
|
-
console.log('❌ No diagnoses found.');
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const doctor = (0, constraint_doctor_1.createDoctor)();
|
|
165
|
-
const diagnoses = files.map(f => {
|
|
166
|
-
const content = fs.readFileSync(path.join(diagnosesDir, f), 'utf-8');
|
|
167
|
-
return JSON.parse(content);
|
|
168
|
-
});
|
|
169
|
-
if (options.format === 'json') {
|
|
170
|
-
console.log(JSON.stringify(diagnoses.map(d => ({
|
|
171
|
-
anomalyId: d.anomalyId,
|
|
172
|
-
constraintId: d.constraintId,
|
|
173
|
-
needsChange: d.needsChange,
|
|
174
|
-
urgency: d.urgency,
|
|
175
|
-
})), null, 2));
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
console.log('📋 Diagnosis List');
|
|
179
|
-
console.log('');
|
|
180
|
-
for (const diagnosis of diagnoses) {
|
|
181
|
-
const urgencyEmoji = {
|
|
182
|
-
low: '🟢',
|
|
183
|
-
medium: '🟡',
|
|
184
|
-
high: '🔴',
|
|
185
|
-
}[diagnosis.urgency] || '⚪';
|
|
186
|
-
console.log(`${urgencyEmoji} ${diagnosis.anomalyId}`);
|
|
187
|
-
console.log(` Constraint: ${diagnosis.constraintId}`);
|
|
188
|
-
console.log(` Needs Change: ${diagnosis.needsChange ? 'Yes' : 'No'}`);
|
|
189
|
-
console.log(` Urgency: ${diagnosis.urgency}`);
|
|
190
|
-
console.log('');
|
|
191
|
-
}
|
|
192
|
-
console.log(`Total: ${diagnoses.length} diagnoses`);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
//# sourceMappingURL=diagnose.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diagnose.js","sourceRoot":"","sources":["../../../src/cli/commands/diagnose.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaH,0CAsCC;AAjDD,uCAAyB;AACzB,2CAA6B;AAC7B,oDAA4E;AAC5E,oEAAgF;AAChF,0EAAoF;AAIpF;;GAEG;AACI,KAAK,UAAU,eAAe,CACnC,UAAkB,EAClB,OAMC;IAED,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,KAAK;YACR,MAAM,WAAW,CAAC,OAAO,CAAC,CAAC;YAC3B,MAAM;QAER,KAAK,MAAM;YACT,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;YAC5B,MAAM;QAER,KAAK,MAAM;YACT,MAAM,aAAa,CAAC,OAAO,CAAC,CAAC;YAC7B,MAAM;QAER;YACE,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;YACpD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;YAC5D,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;YACzD,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;YACnD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,OAAO,CAAC,GAAG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,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YACxE,OAAO,CAAC,GAAG,CAAC,eAAe,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;YAChD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,UAAU,SAAS,CAAC,MAAM,YAAY,CAAC,CAAC;IACtD,CAAC;AACH,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Propose CLI 命令
|
|
3
|
-
*
|
|
4
|
-
* 根据诊断生成约束提案
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* propose 命令
|
|
8
|
-
*/
|
|
9
|
-
export declare function proposeCommand(subcommand: string, options: {
|
|
10
|
-
diagnosisId?: string;
|
|
11
|
-
format?: 'json' | 'text';
|
|
12
|
-
save?: boolean;
|
|
13
|
-
status?: 'proposed' | 'accepted' | 'rejected';
|
|
14
|
-
accept?: boolean;
|
|
15
|
-
reject?: boolean;
|
|
16
|
-
comment?: string;
|
|
17
|
-
}): Promise<void>;
|
|
18
|
-
//# sourceMappingURL=propose.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"propose.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/propose.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH;;GAEG;AACH,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;IACP,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;IAC9C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACA,OAAO,CAAC,IAAI,CAAC,CAyCf"}
|