headlesscode 1.0.2
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/ATTRIBUTION.md +53 -0
- package/CODE_OF_CONDUCT.md +130 -0
- package/CONTRIBUTING.md +107 -0
- package/LICENSE +202 -0
- package/README.md +486 -0
- package/SECURITY.md +211 -0
- package/bin/headlesscode.mjs +83 -0
- package/package.json +63 -0
- package/shared/prompts/review-mode-prompt-short.md +93 -0
- package/shared/prompts/review-mode-prompt.md +281 -0
- package/shared/rules-code/rules.md +22 -0
- package/shared/stacks/cpp/rules.md +30 -0
- package/shared/stacks/fastapi/rules.md +30 -0
- package/shared/stacks/javascript/rules.md +37 -0
- package/shared/stacks/postgresql/rules.md +31 -0
- package/shared/stacks/python/rules.md +35 -0
- package/shared/stacks/react/rules.md +11 -0
- package/shared/stacks/typescript/rules.md +10 -0
- package/src/budget/budget.ts +221 -0
- package/src/budget/concurrency.ts +126 -0
- package/src/budget/cost.ts +309 -0
- package/src/budget/index.ts +8 -0
- package/src/checkpoints/cli.ts +256 -0
- package/src/checkpoints/service.ts +227 -0
- package/src/cli.ts +1535 -0
- package/src/cloud/docker-provider.ts +334 -0
- package/src/cloud/provider.ts +300 -0
- package/src/codeintel/call-graph.ts +78 -0
- package/src/codeintel/find-references.ts +123 -0
- package/src/codeintel/go-to-definition.ts +193 -0
- package/src/codeintel/handlers.ts +190 -0
- package/src/codeintel/import-graph.ts +173 -0
- package/src/codeintel/outline.ts +180 -0
- package/src/codeintel/position.ts +77 -0
- package/src/codeintel/program.ts +350 -0
- package/src/codeintel/rename-symbol.ts +213 -0
- package/src/codeintel/tools.ts +280 -0
- package/src/codemap/build.ts +135 -0
- package/src/codemap/cli.ts +190 -0
- package/src/codemap/extract.ts +339 -0
- package/src/codemap/files.ts +236 -0
- package/src/codemap/fingerprint.ts +65 -0
- package/src/codemap/flows.ts +62 -0
- package/src/codemap/html.ts +451 -0
- package/src/codemap/lock.ts +80 -0
- package/src/codemap/types.ts +101 -0
- package/src/codesearch/airunner-embedder.ts +185 -0
- package/src/codesearch/chunk.ts +339 -0
- package/src/codesearch/cli.ts +223 -0
- package/src/codesearch/embedder.ts +332 -0
- package/src/codesearch/files.ts +280 -0
- package/src/codesearch/index.ts +469 -0
- package/src/codesearch/ollama-embedder.ts +205 -0
- package/src/codesearch/search.ts +141 -0
- package/src/codesearch/types.ts +100 -0
- package/src/config/mode-models.ts +218 -0
- package/src/dashboard/aggregate.ts +364 -0
- package/src/dashboard/chat-thread.ts +141 -0
- package/src/dashboard/checkpoints.ts +124 -0
- package/src/dashboard/cli.ts +193 -0
- package/src/dashboard/codemap.ts +44 -0
- package/src/dashboard/files.ts +121 -0
- package/src/dashboard/page.ts +2803 -0
- package/src/dashboard/self-improvement-metrics.ts +282 -0
- package/src/dashboard/server.ts +1103 -0
- package/src/dashboard/session-launch.ts +310 -0
- package/src/dashboard/timeline.ts +273 -0
- package/src/dashboard/tool-exec.ts +107 -0
- package/src/dashboard/trend-cli.ts +141 -0
- package/src/dashboard/trend.ts +413 -0
- package/src/decision-proxy/cli.ts +261 -0
- package/src/decision-proxy/proxy.ts +569 -0
- package/src/deploy/gate-cli.ts +147 -0
- package/src/deploy/gate.ts +254 -0
- package/src/engine/condense.ts +512 -0
- package/src/engine/events.ts +428 -0
- package/src/engine/handoff.ts +71 -0
- package/src/engine/lazy-tools.ts +160 -0
- package/src/engine/local-explore.ts +653 -0
- package/src/engine/logger.ts +96 -0
- package/src/engine/loop.ts +5517 -0
- package/src/engine/parser.ts +347 -0
- package/src/engine/prompt.ts +860 -0
- package/src/engine/reports.ts +47 -0
- package/src/engine/stacks.ts +448 -0
- package/src/engine/types.ts +291 -0
- package/src/engine/usage.ts +186 -0
- package/src/github/app-auth.ts +161 -0
- package/src/github/cli.ts +448 -0
- package/src/github/installations.ts +133 -0
- package/src/github/pr.ts +321 -0
- package/src/github/provision.ts +118 -0
- package/src/github/push.ts +122 -0
- package/src/index-util.ts +50 -0
- package/src/index.ts +81 -0
- package/src/init/cli.ts +248 -0
- package/src/init/gitignore.ts +74 -0
- package/src/llm/ollama.ts +308 -0
- package/src/llm/openrouter.ts +868 -0
- package/src/llm/preflight.ts +367 -0
- package/src/llm/transcript-capture.ts +84 -0
- package/src/memory/embed.ts +110 -0
- package/src/memory/index.ts +22 -0
- package/src/memory/local.ts +259 -0
- package/src/memory/summarizer.ts +283 -0
- package/src/memory/types.ts +153 -0
- package/src/memory/uwuchat.ts +157 -0
- package/src/migrate/cli.ts +115 -0
- package/src/orchestrator/analyze-cli.ts +104 -0
- package/src/orchestrator/auto-split.ts +206 -0
- package/src/orchestrator/cleanup.ts +1003 -0
- package/src/orchestrator/cli.ts +3571 -0
- package/src/orchestrator/cost-estimate.ts +564 -0
- package/src/orchestrator/cost-history-cli.ts +242 -0
- package/src/orchestrator/cost-history.ts +397 -0
- package/src/orchestrator/git-sync.ts +250 -0
- package/src/orchestrator/index.ts +153 -0
- package/src/orchestrator/log-analysis.ts +0 -0
- package/src/orchestrator/merge-check.ts +108 -0
- package/src/orchestrator/pipeline.ts +411 -0
- package/src/orchestrator/resume.ts +1940 -0
- package/src/orchestrator/reviewer.ts +503 -0
- package/src/orchestrator/split.ts +296 -0
- package/src/orchestrator/state.ts +542 -0
- package/src/orchestrator/status.ts +697 -0
- package/src/orchestrator/verification-gate.ts +134 -0
- package/src/orchestrator/watch.ts +898 -0
- package/src/permissions/commands.ts +1083 -0
- package/src/permissions/config.ts +241 -0
- package/src/permissions/index.ts +12 -0
- package/src/permissions/protected-files.ts +96 -0
- package/src/permissions/store-protection.ts +272 -0
- package/src/project-store.ts +648 -0
- package/src/projects/cli.ts +382 -0
- package/src/qa/qa.ts +487 -0
- package/src/tools/browser/handler.ts +346 -0
- package/src/tools/browser/service.ts +406 -0
- package/src/tools/browser/smoke.ts +78 -0
- package/src/tools/browser/tool.ts +99 -0
- package/src/tools/executor.ts +2575 -0
- package/src/tools/language-detect.ts +183 -0
- package/src/tools/output-summarizer.ts +369 -0
- package/src/tools/run-tests.ts +302 -0
- package/src/tools/set-indentation-tool.ts +49 -0
- package/src/tools/test-selection.ts +160 -0
- package/src/vendor/tests/smoke.ts +103 -0
- package/src/vendor/zoo-code/VENDOR-NOTES.md +213 -0
- package/src/vendor/zoo-code/shim/anthropic.ts +71 -0
- package/src/vendor/zoo-code/shim/openai.d.ts +60 -0
- package/src/vendor/zoo-code/shim/os-name.ts +18 -0
- package/src/vendor/zoo-code/shim/strip-bom.ts +14 -0
- package/src/vendor/zoo-code/shim/vscode.ts +76 -0
- package/src/vendor/zoo-code/src/core/config/CustomModesManager.ts +1015 -0
- package/src/vendor/zoo-code/src/core/diff/strategies/multi-search-replace.ts +670 -0
- package/src/vendor/zoo-code/src/core/prompts/sections/capabilities.ts +46 -0
- package/src/vendor/zoo-code/src/core/prompts/sections/custom-instructions.ts +559 -0
- package/src/vendor/zoo-code/src/core/prompts/sections/index.ts +10 -0
- package/src/vendor/zoo-code/src/core/prompts/sections/markdown-formatting.ts +7 -0
- package/src/vendor/zoo-code/src/core/prompts/sections/modes.ts +35 -0
- package/src/vendor/zoo-code/src/core/prompts/sections/objective.ts +13 -0
- package/src/vendor/zoo-code/src/core/prompts/sections/rules.ts +95 -0
- package/src/vendor/zoo-code/src/core/prompts/sections/skills.ts +105 -0
- package/src/vendor/zoo-code/src/core/prompts/sections/system-info.ts +30 -0
- package/src/vendor/zoo-code/src/core/prompts/sections/tool-use-guidelines.ts +9 -0
- package/src/vendor/zoo-code/src/core/prompts/sections/tool-use.ts +7 -0
- package/src/vendor/zoo-code/src/core/prompts/system.ts +176 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/access_mcp_resource.ts +41 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/apply_diff.ts +40 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/apply_patch.ts +61 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/ask_followup_question.ts +62 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/attempt_completion.ts +33 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/codebase_search.ts +43 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/converters.ts +109 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/edit.ts +48 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/edit_file.ts +72 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/execute_command.ts +54 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/generate_image.ts +51 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/index.ts +75 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/list_files.ts +41 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/mcp_server.ts +75 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/new_task.ts +39 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/read_command_output.ts +81 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/read_file.ts +169 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/run_slash_command.ts +31 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/search_files.ts +50 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/search_replace.ts +51 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/skill.ts +33 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/switch_mode.ts +31 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/update_todo_list.ts +54 -0
- package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/write_to_file.ts +40 -0
- package/src/vendor/zoo-code/src/core/prompts/types.ts +12 -0
- package/src/vendor/zoo-code/src/i18n/index.ts +19 -0
- package/src/vendor/zoo-code/src/integrations/misc/extract-text.ts +81 -0
- package/src/vendor/zoo-code/src/services/checkpoints/RepoPerTaskCheckpointService.ts +15 -0
- package/src/vendor/zoo-code/src/services/checkpoints/ShadowCheckpointService.ts +553 -0
- package/src/vendor/zoo-code/src/services/checkpoints/excludes.ts +212 -0
- package/src/vendor/zoo-code/src/services/checkpoints/index.ts +3 -0
- package/src/vendor/zoo-code/src/services/checkpoints/types.ts +35 -0
- package/src/vendor/zoo-code/src/services/code-index/manager.ts +19 -0
- package/src/vendor/zoo-code/src/services/mcp/McpHub.ts +36 -0
- package/src/vendor/zoo-code/src/services/roo-config/index.ts +441 -0
- package/src/vendor/zoo-code/src/services/search/file-search.ts +143 -0
- package/src/vendor/zoo-code/src/services/skills/SkillsManager.ts +20 -0
- package/src/vendor/zoo-code/src/shared/globalFileNames.ts +9 -0
- package/src/vendor/zoo-code/src/shared/language.ts +43 -0
- package/src/vendor/zoo-code/src/shared/modes.ts +257 -0
- package/src/vendor/zoo-code/src/shared/tools.ts +385 -0
- package/src/vendor/zoo-code/src/utils/fs.ts +39 -0
- package/src/vendor/zoo-code/src/utils/globalContext.ts +22 -0
- package/src/vendor/zoo-code/src/utils/json-schema.ts +16 -0
- package/src/vendor/zoo-code/src/utils/logging.ts +21 -0
- package/src/vendor/zoo-code/src/utils/mcp-name.ts +190 -0
- package/src/vendor/zoo-code/src/utils/object.ts +18 -0
- package/src/vendor/zoo-code/src/utils/path.ts +94 -0
- package/src/vendor/zoo-code/src/utils/shell.ts +376 -0
- package/src/vendor/zoo-code/src/utils/text-normalization.ts +99 -0
- package/src/vendor/zoo-code/types/global-settings.ts +19 -0
- package/src/vendor/zoo-code/types/index.ts +22 -0
- package/src/vendor/zoo-code/types/message.ts +375 -0
- package/src/vendor/zoo-code/types/mode.ts +241 -0
- package/src/vendor/zoo-code/types/todo.ts +19 -0
- package/src/vendor/zoo-code/types/tool-params.ts +116 -0
- package/src/vendor/zoo-code/types/tool.ts +67 -0
- package/src/vendor/zoo-code/types/vscode.ts +84 -0
- package/src/vision/describe.ts +242 -0
- package/src/vision/tool.ts +91 -0
- package/src/watcher/cli.ts +369 -0
- package/src/watcher/github.ts +304 -0
- package/src/watcher/index.ts +59 -0
- package/src/watcher/state.ts +254 -0
- package/src/watcher/watch.ts +562 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process"
|
|
2
|
+
import * as fs from "node:fs"
|
|
3
|
+
import * as path from "node:path"
|
|
4
|
+
|
|
5
|
+
import { eventsFilePath } from "../engine/events.js"
|
|
6
|
+
|
|
7
|
+
// Bookkeeping artifacts the harness itself writes into a worktree — never
|
|
8
|
+
// real work, must not count as "the group changed something".
|
|
9
|
+
export const HARNESS_ARTIFACT_RE =
|
|
10
|
+
/^(\.harness\.|harness\.log$|qa\.log$|review\.log$|\.env$|ORCHESTRATOR_TASK\.md$|\.headlesscode\/)/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Deterministic, un-hallucinate-able gate: does this worktree actually
|
|
14
|
+
* contain any real change at all? Run directly by the orchestrator's own
|
|
15
|
+
* git commands — never asked of an LLM — before either runReviewStep or
|
|
16
|
+
* runQaStep ever trusts a "clean"/"pass" verdict.
|
|
17
|
+
*
|
|
18
|
+
* Verified live 2026-08-28 (joeos issue #26): a review session fabricated
|
|
19
|
+
* an ENTIRE false completion — invented commit counts, invented diff
|
|
20
|
+
* stats ("8691 insertions... across 47 files"), invented passing test
|
|
21
|
+
* output, even a fabricated GitHub PR link — and declared VERDICT: CLEAN
|
|
22
|
+
* via the structured, supposedly-authoritative verdict line, for a
|
|
23
|
+
* worktree that in reality had ZERO commits and ZERO changes. No amount
|
|
24
|
+
* of parser hardening closes this: the fabrication was coherent,
|
|
25
|
+
* well-formatted prose: the model's own summary is not a source of
|
|
26
|
+
* truth about what really happened. This checks the actual filesystem/
|
|
27
|
+
* git state instead, which the model cannot talk its way around.
|
|
28
|
+
*
|
|
29
|
+
* Checks BOTH: (1) committed changes vs the tracked upstream (mirrors
|
|
30
|
+
* exactly what worker/review/QA sessions are themselves told to check
|
|
31
|
+
* via `git diff origin/master...HEAD`), and (2) uncommitted working-tree
|
|
32
|
+
* changes — a worker's write_to_file calls land in the real working tree
|
|
33
|
+
* with nothing forcing it to also commit them, so a committed-only check
|
|
34
|
+
* could false-negative on real, uncommitted work. Ignores the harness's
|
|
35
|
+
* own bookkeeping files (harness.log, .env, etc.) via HARNESS_ARTIFACT_RE
|
|
36
|
+
* — those exist in every worktree regardless of whether real work
|
|
37
|
+
* happened and must never count as "changed something".
|
|
38
|
+
*/
|
|
39
|
+
export function hasRealWorktreeChanges(wtPath: string): boolean {
|
|
40
|
+
let upstream = "origin/master"
|
|
41
|
+
try {
|
|
42
|
+
const tracked = execFileSync(
|
|
43
|
+
"git",
|
|
44
|
+
["-C", wtPath, "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"],
|
|
45
|
+
{ encoding: "utf-8", timeout: 5000 },
|
|
46
|
+
).trim()
|
|
47
|
+
if (tracked) {
|
|
48
|
+
upstream = tracked
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
// No tracked upstream configured — fall back to origin/master.
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
const diffStat = execFileSync("git", ["-C", wtPath, "diff", `${upstream}...HEAD`, "--stat"], {
|
|
55
|
+
encoding: "utf-8",
|
|
56
|
+
timeout: 10_000,
|
|
57
|
+
}).trim()
|
|
58
|
+
if (diffStat.length > 0) {
|
|
59
|
+
return true
|
|
60
|
+
}
|
|
61
|
+
} catch {
|
|
62
|
+
// A failed diff isn't proof of "no changes" — fall through to the
|
|
63
|
+
// working-tree check below rather than assume real work happened.
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
const status = execFileSync("git", ["-C", wtPath, "status", "--porcelain"], {
|
|
67
|
+
encoding: "utf-8",
|
|
68
|
+
timeout: 10_000,
|
|
69
|
+
})
|
|
70
|
+
for (const line of status.split("\n")) {
|
|
71
|
+
const filePath = line.slice(3).trim()
|
|
72
|
+
if (filePath && !HARNESS_ARTIFACT_RE.test(filePath)) {
|
|
73
|
+
return true
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
} catch {
|
|
77
|
+
// Can't determine either way — err toward NOT trusting an
|
|
78
|
+
// unverifiable "clean" (return false, same as "no changes found").
|
|
79
|
+
}
|
|
80
|
+
return false
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Tier 2 of the same 2026-08-28 incident's fix (see hasRealWorktreeChanges):
|
|
85
|
+
* even once real work exists to review, a "clean"/"pass" verdict is only as
|
|
86
|
+
* trustworthy as the verification the session actually did. Cross-checks
|
|
87
|
+
* the review/QA session's OWN event-log transcript (never re-derived from
|
|
88
|
+
* its summary prose, which is exactly what was fabricated) for at least one
|
|
89
|
+
* REAL, non-error `execute_command` result — the one tool that actually
|
|
90
|
+
* proves something was run and checked, as opposed to read_file/list_files
|
|
91
|
+
* (which only prove something was looked at). A session that declares
|
|
92
|
+
* "clean"/"pass" without ever running a single successful command has
|
|
93
|
+
* nothing behind that verdict but its own prose, the exact gap that let
|
|
94
|
+
* the fabricated 2026-08-28 review through even with a structured,
|
|
95
|
+
* required-format verdict line.
|
|
96
|
+
*
|
|
97
|
+
* Deliberately narrow like hasRealWorktreeChanges: this checks that SOME
|
|
98
|
+
* real verification activity happened at all, not that specific claimed
|
|
99
|
+
* numbers (e.g. "8691 insertions") match specific tool outputs — matching
|
|
100
|
+
* every claim in free-form prose against the transcript has no realistic
|
|
101
|
+
* false-positive ceiling (the exact trap parseReviewResult/parseQaResult's
|
|
102
|
+
* own docs already warn against for heuristic text matching). Absent or
|
|
103
|
+
* unreadable event log → false (same fail-closed posture as an empty
|
|
104
|
+
* diff): a verdict this codebase cannot verify at all is never trusted.
|
|
105
|
+
*/
|
|
106
|
+
export function hasRealVerificationActivity(workspaceRoot: string, reportPath: string | undefined): boolean {
|
|
107
|
+
if (!reportPath) {
|
|
108
|
+
return false
|
|
109
|
+
}
|
|
110
|
+
const sessionId = path.basename(reportPath, ".md")
|
|
111
|
+
const eventsPath = eventsFilePath(workspaceRoot, sessionId)
|
|
112
|
+
let raw: string
|
|
113
|
+
try {
|
|
114
|
+
raw = fs.readFileSync(eventsPath, "utf-8")
|
|
115
|
+
} catch {
|
|
116
|
+
return false
|
|
117
|
+
}
|
|
118
|
+
for (const line of raw.split("\n")) {
|
|
119
|
+
const trimmed = line.trim()
|
|
120
|
+
if (!trimmed) {
|
|
121
|
+
continue
|
|
122
|
+
}
|
|
123
|
+
let record: { type?: unknown; tool?: unknown; isError?: unknown }
|
|
124
|
+
try {
|
|
125
|
+
record = JSON.parse(trimmed)
|
|
126
|
+
} catch {
|
|
127
|
+
continue
|
|
128
|
+
}
|
|
129
|
+
if (record.type === "tool_result" && record.tool === "execute_command" && record.isError === false) {
|
|
130
|
+
return true
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return false
|
|
134
|
+
}
|