@payconductor/houndsman 0.4.0 → 0.6.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 +35 -41
- package/assets/grammars/tree-sitter-javascript.wasm +0 -0
- package/assets/grammars/tree-sitter-tsx.wasm +0 -0
- package/assets/grammars/tree-sitter-typescript.wasm +0 -0
- package/assets/grammars/web-tree-sitter.wasm +0 -0
- package/package.json +11 -3
- package/src/cli/commands/command.ts +5 -0
- package/src/cli/commands/doctor-command.ts +116 -24
- package/src/cli/commands/hunt-command.ts +25 -0
- package/src/cli/commands/status-command.ts +46 -0
- package/src/cli/help.ts +18 -1
- package/src/cli/index.ts +13 -6
- package/src/core/ai/ai-client.ts +221 -0
- package/src/core/ai/ai-sdk-model-provider.ts +101 -0
- package/src/core/ai/errors.ts +36 -0
- package/src/core/ai/features/brief-enricher.ts +62 -0
- package/src/core/ai/features/classifier.ts +50 -0
- package/src/core/ai/features/context-summarizer.ts +31 -0
- package/src/core/ai/features/pre-analyzer.ts +51 -0
- package/src/core/ai/features/verifier.ts +45 -0
- package/src/core/ai/index.ts +56 -0
- package/src/core/ai/model-factory.ts +137 -0
- package/src/core/ai/prompts/base.ts +36 -0
- package/src/core/ai/prompts/brief.ts +87 -0
- package/src/core/ai/prompts/classification.ts +36 -0
- package/src/core/ai/prompts/context.ts +29 -0
- package/src/core/ai/prompts/pre-analysis.ts +49 -0
- package/src/core/ai/prompts/verify.ts +40 -0
- package/src/core/ai/schemas.ts +110 -0
- package/src/core/ai/types.ts +76 -0
- package/src/core/ai/usage-budget.ts +75 -0
- package/src/core/ai/usage-recorder.ts +79 -0
- package/src/core/assets.ts +16 -0
- package/src/core/ast/diff.ts +220 -0
- package/src/core/ast/impact.ts +127 -0
- package/src/core/ast/parser.ts +167 -0
- package/src/core/ast/service.ts +233 -0
- package/src/core/ast/symbols.ts +294 -0
- package/src/core/ast/types.ts +125 -0
- package/src/core/brief.ts +138 -0
- package/src/core/commands/findings.ts +120 -6
- package/src/core/commands/review.ts +2 -0
- package/src/core/commands/scaffold.ts +159 -10
- package/src/core/commands/status.ts +63 -0
- package/src/core/commands/update.ts +5 -3
- package/src/core/config.ts +85 -0
- package/src/core/defaults.ts +27 -0
- package/src/core/domain/watchdog.ts +43 -5
- package/src/core/engine/houndsman-engine.ts +16 -1
- package/src/core/engine/review-scope.ts +77 -13
- package/src/core/engine/review-session.ts +27 -2
- package/src/core/env.ts +101 -0
- package/src/core/file-classifier.ts +25 -4
- package/src/core/findings-state.ts +21 -4
- package/src/core/github-review.ts +620 -57
- package/src/core/jev/jev-client.ts +8 -7
- package/src/core/jev/jev-verify.ts +2 -1
- package/src/core/logging/index.ts +17 -0
- package/src/core/logging/logger.ts +187 -0
- package/src/core/orchestrator.ts +454 -16
- package/src/core/paths.ts +3 -0
- package/src/core/project-config.ts +123 -1
- package/src/core/registry-check.ts +148 -6
- package/src/core/renderers/manifest-writer.ts +33 -0
- package/src/core/renderers/resume-renderer.ts +151 -0
- package/src/core/report-builder.ts +7 -4
- package/src/core/rule-text.ts +97 -0
- package/src/core/run-status.ts +39 -5
- package/src/core/services/file-classifier.ts +10 -3
- package/src/core/services/verifier.ts +14 -3
- package/src/core/storage/file/file-storage.ts +2 -0
- package/src/core/storage/paths.ts +6 -5
- package/src/core/storage/sqlite/mappers.ts +2 -0
- package/src/core/storage/sqlite/schema.ts +9 -1
- package/src/core/storage/sqlite/sqlite-storage.ts +5 -1
- package/src/core/storage/types.ts +15 -0
- package/src/core/storage/work-area.ts +12 -0
- package/src/core/types.ts +37 -1
- package/src/core/verify.ts +17 -5
- package/src/harness/README.md +15 -0
- package/src/harness/agent/agent-context.ts +33 -0
- package/src/harness/agent/agent-errors.ts +30 -0
- package/src/harness/agent/agent-factory.ts +45 -0
- package/src/harness/agent/agent-reporter.ts +34 -0
- package/src/harness/agent/agent-result.ts +16 -0
- package/src/harness/agent/agent-runner.ts +32 -0
- package/src/harness/agent/agent-scheduler.ts +37 -0
- package/src/harness/agent/review-agent.ts +391 -0
- package/src/harness/config/harness-config.ts +84 -0
- package/src/harness/hunt/hunt-harness.ts +83 -0
- package/src/harness/hunt/hunt-options.ts +75 -0
- package/src/harness/hunt/hunt-result.ts +17 -0
- package/src/harness/hunt/hunt-session.ts +372 -0
- package/src/harness/hunt/review-planner.ts +98 -0
- package/src/harness/index.ts +36 -0
- package/src/harness/investigation/agent-state.ts +134 -0
- package/src/harness/investigation/evidence-verifier.ts +129 -0
- package/src/harness/investigation/evidence.ts +110 -0
- package/src/harness/investigation/finding-critic.ts +96 -0
- package/src/harness/investigation/investigation-planner.ts +118 -0
- package/src/harness/investigation/investigation-task.ts +10 -0
- package/src/harness/investigation/review-journal.ts +87 -0
- package/src/harness/investigation/rule-analyzer.ts +178 -0
- package/src/harness/investigation/rule-signals.ts +110 -0
- package/src/harness/prompts/agent-schemas.ts +57 -0
- package/src/harness/prompts/reviewer-prompt-builder.ts +101 -0
- package/src/harness/prompts/states/conclude-prompt.ts +16 -0
- package/src/harness/prompts/states/investigate-prompt.ts +37 -0
- package/src/harness/prompts/states/orient-prompt.ts +15 -0
- package/src/harness/prompts/states/verify-prompt.ts +22 -0
- package/src/harness/tools/agent-tool.ts +102 -0
- package/src/harness/tools/builtin/changed-symbols-tool.ts +48 -0
- package/src/harness/tools/builtin/doc-context-tool.ts +74 -0
- package/src/harness/tools/builtin/file-outline-tool.ts +66 -0
- package/src/harness/tools/builtin/find-references-tool.ts +66 -0
- package/src/harness/tools/builtin/find-symbol-tool.ts +91 -0
- package/src/harness/tools/builtin/helpers.ts +115 -0
- package/src/harness/tools/builtin/impact-tool.ts +48 -0
- package/src/harness/tools/builtin/imports-exports-tool.ts +53 -0
- package/src/harness/tools/builtin/index.ts +59 -0
- package/src/harness/tools/builtin/list-files-tool.ts +85 -0
- package/src/harness/tools/builtin/pr-context-tool.ts +41 -0
- package/src/harness/tools/builtin/read-file-range-tool.ts +73 -0
- package/src/harness/tools/builtin/rule-signals-tool.ts +36 -0
- package/src/harness/tools/builtin/search-code-tool.ts +65 -0
- package/src/harness/tools/builtin/symbol-context-tool.ts +106 -0
- package/src/harness/tools/builtin/tests-for-symbol-tool.ts +61 -0
- package/src/harness/tools/path-guard.ts +90 -0
- package/src/harness/tools/result-limiter.ts +49 -0
- package/src/harness/tools/secret-redactor.ts +54 -0
- package/src/harness/tools/tool-cache.ts +50 -0
- package/src/harness/tools/tool-call-budget.ts +60 -0
- package/src/harness/tools/tool-context.ts +5 -0
- package/src/harness/tools/tool-middleware.ts +105 -0
- package/src/harness/tools/tool-policy.ts +51 -0
- package/src/harness/tools/tool-registry.ts +112 -0
- package/src/harness/tools/tool-result.ts +15 -0
- package/src/harness/tools/toolbox.ts +36 -0
- package/src/harness/validation/finding-validator.ts +119 -0
- package/src/index.ts +46 -0
- package/src/server/client/App.tsx +26 -9
- package/src/server/client/ArtifactsPanel.tsx +12 -5
- package/src/server/client/AutoRefresh.tsx +1 -1
- package/src/server/client/Filters.tsx +7 -2
- package/src/server/client/FindingCard.tsx +14 -10
- package/src/server/client/FindingsList.tsx +2 -2
- package/src/server/client/MarkdownText.tsx +92 -12
- package/src/server/client/ResumePanel.tsx +368 -0
- package/src/server/client/RunList.tsx +3 -3
- package/src/server/client/SubmitModal.tsx +49 -6
- package/src/server/client/SummaryBar.tsx +1 -1
- package/src/server/client/icons.tsx +17 -0
- package/src/server/client/{constants.ts → utils/constants.ts} +61 -10
- package/src/server/client/utils/markdown.ts +319 -0
- package/src/server/client/{types.ts → utils/types.ts} +64 -0
- package/src/server/index.ts +66 -7
- package/src/server/run-repository.ts +9 -0
- package/src/skill/OUTPUT-FORMAT.md +12 -0
- package/src/skill/SETUP.md +6 -2
- package/src/skill/example-review.md +22 -14
- package/src/skill/hunt.md +45 -19
- package/src/skill/verify.md +3 -2
- package/src/tests/__snapshots__/baseline.test.ts.snap +126 -42
- package/src/tests/ai-core.test.ts +120 -0
- package/src/tests/ai-features.test.ts +183 -0
- package/src/tests/ast.test.ts +335 -0
- package/src/tests/baseline.test.ts +3 -0
- package/src/tests/code-highlight.test.ts +1 -1
- package/src/tests/env.test.ts +69 -0
- package/src/tests/fallback.test.ts +172 -0
- package/src/tests/findings-state.test.ts +50 -2
- package/src/tests/fixtures/fake-agent-tools.ts +69 -0
- package/src/tests/fixtures/fake-investigation.ts +64 -0
- package/src/tests/fixtures/fake-model-provider.ts +48 -0
- package/src/tests/github-review.test.ts +409 -60
- package/src/tests/harness-agent.test.ts +122 -0
- package/src/tests/harness-investigation.test.ts +206 -0
- package/src/tests/harness-tools.test.ts +148 -0
- package/src/tests/hunt-command.test.ts +212 -0
- package/src/tests/logger.test.ts +83 -0
- package/src/tests/markdown.test.ts +61 -1
- package/src/tests/review-resume.test.ts +101 -0
- package/src/tests/review-scope.test.ts +302 -0
- package/src/tests/review-scripts.test.ts +73 -0
- package/src/tests/rule-analyzer.test.ts +61 -0
- package/src/tests/run-status-view.test.ts +94 -0
- package/src/tests/run-status.test.ts +53 -0
- package/src/tests/server.test.ts +76 -21
- package/src/tests/storage.test.ts +63 -0
- package/src/tests/tool-contracts.test.ts +82 -0
- package/src/tests/verify.test.ts +1 -1
- package/src/server/client/markdown.ts +0 -153
- /package/src/server/client/{api.ts → utils/api.ts} +0 -0
- /package/src/server/client/{code-highlight.ts → utils/code-highlight.ts} +0 -0
- /package/src/server/client/{format.ts → utils/format.ts} +0 -0
- /package/src/server/client/{json-highlight.ts → utils/json-highlight.ts} +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tools fake para a suíte do harness.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import type {
|
|
7
|
+
AgentTool,
|
|
8
|
+
ToolContext,
|
|
9
|
+
ToolMetadata,
|
|
10
|
+
ToolResult,
|
|
11
|
+
} from "../../harness/tools/agent-tool";
|
|
12
|
+
|
|
13
|
+
/** Tool de eco (testa registry/middleware). */
|
|
14
|
+
export class EchoTool implements AgentTool<{ value: string }, { value: string }> {
|
|
15
|
+
readonly metadata: ToolMetadata = {
|
|
16
|
+
name: "echo",
|
|
17
|
+
description: "Devolve o valor recebido.",
|
|
18
|
+
category: "context",
|
|
19
|
+
capabilities: ["read"],
|
|
20
|
+
readOnly: true,
|
|
21
|
+
cost: 1,
|
|
22
|
+
cacheTtlMs: 60_000,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
readonly inputSchema = z.object({ value: z.string() });
|
|
26
|
+
|
|
27
|
+
async execute(
|
|
28
|
+
input: { value: string },
|
|
29
|
+
_context: ToolContext,
|
|
30
|
+
): Promise<ToolResult<{ value: string }>> {
|
|
31
|
+
return { ok: true, data: { value: input.value } };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Tool que produz evidência para o estado. */
|
|
36
|
+
export class EvidenceTool implements AgentTool<{ file: string }, unknown> {
|
|
37
|
+
readonly metadata: ToolMetadata = {
|
|
38
|
+
name: "evidence",
|
|
39
|
+
description: "Produz uma evidência fake.",
|
|
40
|
+
category: "evidence",
|
|
41
|
+
capabilities: ["read"],
|
|
42
|
+
readOnly: true,
|
|
43
|
+
cost: 1,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
readonly inputSchema = z.object({ file: z.string() });
|
|
47
|
+
|
|
48
|
+
async execute(
|
|
49
|
+
input: { file: string },
|
|
50
|
+
_context: ToolContext,
|
|
51
|
+
): Promise<ToolResult<unknown>> {
|
|
52
|
+
return {
|
|
53
|
+
ok: true,
|
|
54
|
+
data: { file: input.file },
|
|
55
|
+
evidence: [
|
|
56
|
+
{
|
|
57
|
+
id: "",
|
|
58
|
+
file: input.file,
|
|
59
|
+
startLine: 1,
|
|
60
|
+
endLine: 1,
|
|
61
|
+
snippet: "const x: any = 1;",
|
|
62
|
+
kind: "definition",
|
|
63
|
+
sourceTool: "evidence",
|
|
64
|
+
confidence: 0.9,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fixtures de investigação/agente (sem rede, sem git).
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { AstService } from "../../core/ast/service";
|
|
6
|
+
import { Watchdog } from "../../core/domain/watchdog";
|
|
7
|
+
import type { AgentContext } from "../../harness/agent/agent-context";
|
|
8
|
+
import { SilentReporter } from "../../harness/agent/agent-reporter";
|
|
9
|
+
import type { ReviewAgentDeps } from "../../harness/agent/review-agent";
|
|
10
|
+
import { RuleAnalyzer } from "../../harness/investigation/rule-analyzer";
|
|
11
|
+
import { BuiltinToolsModule } from "../../harness/tools/builtin";
|
|
12
|
+
import { ToolRegistry } from "../../harness/tools/tool-registry";
|
|
13
|
+
import type { FakeModelProvider } from "./fake-model-provider";
|
|
14
|
+
import { fakeHoundsmanConfig } from "./fake-project";
|
|
15
|
+
|
|
16
|
+
/** Contexto de agente para o watchdog `alpha`. */
|
|
17
|
+
export function fakeAgentContext(overrides: Partial<AgentContext> = {}): AgentContext {
|
|
18
|
+
const watchdog = new Watchdog(fakeHoundsmanConfig.watchdogs.alpha);
|
|
19
|
+
const rules = new RuleAnalyzer().analyze(watchdog.rules);
|
|
20
|
+
return {
|
|
21
|
+
watchdog,
|
|
22
|
+
projectName: "Fake",
|
|
23
|
+
branch: "main",
|
|
24
|
+
files: ["src/alpha/a.ts"],
|
|
25
|
+
overflow: [],
|
|
26
|
+
deleted: [],
|
|
27
|
+
docs: [],
|
|
28
|
+
context: null,
|
|
29
|
+
ast: new Map(),
|
|
30
|
+
outputPath: "findings/alpha.json",
|
|
31
|
+
maxSteps: 4,
|
|
32
|
+
maxCalls: 8,
|
|
33
|
+
repoRoot: process.cwd(),
|
|
34
|
+
diff: { byFile: new Map(), churn: new Map() },
|
|
35
|
+
rules,
|
|
36
|
+
...overrides,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Registry com tools built-in. */
|
|
41
|
+
export function builtinRegistry(): ToolRegistry {
|
|
42
|
+
const registry = new ToolRegistry();
|
|
43
|
+
registry.registerModule(new BuiltinToolsModule());
|
|
44
|
+
return registry;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Deps completas de um `ReviewAgent` com provider fake. */
|
|
48
|
+
export function fakeAgentDeps(
|
|
49
|
+
provider: FakeModelProvider,
|
|
50
|
+
overrides: Partial<ReviewAgentDeps> = {},
|
|
51
|
+
): ReviewAgentDeps {
|
|
52
|
+
const context = overrides.context ?? fakeAgentContext();
|
|
53
|
+
return {
|
|
54
|
+
context,
|
|
55
|
+
provider,
|
|
56
|
+
registry: builtinRegistry(),
|
|
57
|
+
reporter: new SilentReporter(),
|
|
58
|
+
maxOutputTokens: 512,
|
|
59
|
+
temperature: 0,
|
|
60
|
+
timeoutMs: 5_000,
|
|
61
|
+
ast: new AstService(fakeHoundsmanConfig),
|
|
62
|
+
...overrides,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider de modelo fake — suíte sem rede.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { AiUsage, ModelProvider, ModelRequest, ModelResponse } from "../../core/ai";
|
|
6
|
+
|
|
7
|
+
/** Uso padrão de uma chamada fake. */
|
|
8
|
+
export function fakeUsage(calls = 1): AiUsage {
|
|
9
|
+
return {
|
|
10
|
+
inputTokens: 10 * calls,
|
|
11
|
+
outputTokens: 5 * calls,
|
|
12
|
+
totalTokens: 15 * calls,
|
|
13
|
+
calls,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Handler roteirizado: recebe o request e o índice da chamada. */
|
|
18
|
+
export type FakeHandler = (
|
|
19
|
+
request: ModelRequest<unknown>,
|
|
20
|
+
index: number,
|
|
21
|
+
) => unknown | Promise<unknown>;
|
|
22
|
+
|
|
23
|
+
/** Provider roteirizado. */
|
|
24
|
+
export class FakeModelProvider implements ModelProvider {
|
|
25
|
+
readonly name = "deepseek" as const;
|
|
26
|
+
readonly modelId: string;
|
|
27
|
+
readonly requests: ModelRequest<unknown>[] = [];
|
|
28
|
+
calls = 0;
|
|
29
|
+
|
|
30
|
+
constructor(
|
|
31
|
+
private readonly handler: FakeHandler,
|
|
32
|
+
modelId = "fake-model",
|
|
33
|
+
) {
|
|
34
|
+
this.modelId = modelId;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async generate<T>(request: ModelRequest<T>): Promise<ModelResponse<T>> {
|
|
38
|
+
this.requests.push(request as ModelRequest<unknown>);
|
|
39
|
+
const index = this.calls++;
|
|
40
|
+
const output = await this.handler(request as ModelRequest<unknown>, index);
|
|
41
|
+
return {
|
|
42
|
+
output: output as T,
|
|
43
|
+
usage: fakeUsage(),
|
|
44
|
+
steps: 1,
|
|
45
|
+
finishReason: "stop",
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|