150 lines
8.7 KiB
Python
150 lines
8.7 KiB
Python
"""Read a pinned, clean public source checkout; never import or run its code."""
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import subprocess
|
|
|
|
PIN = "2d0b22e0b3554686e1e4131f8bdc568ef768e060"
|
|
PRODUCT_PIN = "676fc554"
|
|
URL = "https://github.com/huiliyi37/Tianshu-harness"
|
|
|
|
# Identifiers are used by the research report. Empty needles anchor at line one.
|
|
SOURCES = [
|
|
("S01", "package.json", '"version"'),
|
|
("S02", "LICENSE", ""),
|
|
("S03", "README.md", "**提交、验证、审查分离的交付**"),
|
|
("S04", "src/agent/runtime-hooks.ts", "export type RuntimeHookPhase"),
|
|
("S05", "src/agent/create-runtime-hooks.ts", "export function createDefaultRuntimeHooks"),
|
|
("S06", "src/agent/loop-factory.ts", "const hooks = createDefaultRuntimeHooks"),
|
|
("S07", "src/agent/turn-perception.ts", ""),
|
|
("S08", "src/agent/tool-execution.ts", "export class ToolExecutionController"),
|
|
("S09", "src/agent/turn-orchestrator.ts", ""),
|
|
("S10", "src/context/task-contract.ts", "export interface TaskContract"),
|
|
("S11", "src/agent/evidence-obligation.ts", "export type ObligationState"),
|
|
("S12", "src/agent/obligation-tracker.ts", "export class ObligationTracker"),
|
|
("S13", "src/agent/loop.ts", "captureAcceptance(items:"),
|
|
("S14", "src/agent/advisory-bus.ts", "export class AdvisoryBus"),
|
|
("S15", "src/agent/runtime-advice-facts.ts", ""),
|
|
("S16", "src/agent/convergence-detector.ts", "const effectiveScore ="),
|
|
("S17", "src/agent/convergence-message.ts", ""),
|
|
("S18", "src/agent/score-history.ts", ""),
|
|
("S19", "src/tools/write-tool-helpers.ts", ""),
|
|
("S20", "src/agent/exploration-stall.ts", ""),
|
|
("S21", "src/agent/__tests__/convergence-detector.test.ts", ""),
|
|
("S22", "src/agent/delivery-gate-v2.ts", ""),
|
|
("S23", "src/agent/deliver-task.ts", ""),
|
|
("S24", "src/agent/evidence.ts", ""),
|
|
("S25", "src/agent/verification-snapshot.ts", ""),
|
|
("S26", "src/agent/verification-scope-current.ts", ""),
|
|
("S27", "src/agent/tool-pipeline.ts", "export function executeToolUse("),
|
|
("S28", "src/agent/approval-input-boundary.ts", ""),
|
|
("S29", "src/prompt/engine.ts", "export class PromptEngine"),
|
|
("S30", "src/agent/request-context-controller.ts", "export class RequestContextController"),
|
|
("S31", "src/agent/context-budget-preparation.ts", "export async function prepareContextRequest"),
|
|
("S32", "src/agent/compact-boundary-coordinator.ts", ""),
|
|
("S33", "src/context/request-budget.ts", ""),
|
|
("S34", "src/tools/tool-preset.ts", "minimal 36 / 26"),
|
|
("S35", "src/tools/default-registry.ts", ""),
|
|
("S36", "src/agent/tool-surface.ts", "export function describeToolSurface"),
|
|
("S37", "src/agent/work-order.ts", "const workerBudgetSchema"),
|
|
("S38", "src/agent/worker-runtime.ts", "export function createWorkerRuntimeFactory"),
|
|
("S39", "src/agent/worker-session.ts", "async function runWorkerSessionImpl"),
|
|
("S40", "src/agent/hands-session.ts", "const gateOn ="),
|
|
("S41", "src/agent/worker-write-gate.ts", "export async function evaluateWorkerWriteGate"),
|
|
("S42", "src/agent/worker-objective-gate.ts", "export function reconcileWithObjective"),
|
|
("S43", "src/agent/coordinator.ts", "result: reconcileWithObjective(order"),
|
|
("S44", "src/model/model-binding.ts", "export function resolveModelBinding"),
|
|
("S45", "src/config/provider-keys.ts", "export function findModelOwner"),
|
|
("S46", "src/api/fallback-client.ts", "getMainPrefixProof?.() ||"),
|
|
("S47", "src/memory/formation-policy.ts", ""),
|
|
("S48", "src/memory/essence-gate.ts", "export async function runEssenceGate"),
|
|
("S49", "src/memory/unified-memory.ts", "export function recallMemoryEntries"),
|
|
("S50", "src/agent/hooks/essence-gate-hook.ts", ""),
|
|
("S51", "src/agent/skill-distill.ts", "export function renderSkillDraftMarkdown"),
|
|
("S52", "src/agent/hooks/skill-distill-hook.ts", ""),
|
|
("S53", "src/skills/skill-loader.ts", "Two tiers:"),
|
|
("S54", "src/mcp/manager.ts", "export class McpManager"),
|
|
("S55", "src/plugins/plugin-loader.ts", "export async function initializePlugins"),
|
|
("S56", "src/tools/computer-use/bridge.ts", ""),
|
|
("S57", "src/tools/computer-use/stub.ts", ""),
|
|
("S58", "docs/architecture-overview.md", ""),
|
|
("S59", "docs/reference/observability-harness.md", ""),
|
|
("S60", "docs/CVM运行时对Agent模型的实证影响.md", "版权与许可"),
|
|
("S61", "docs/reference/cvm-cognitive-runtime.md", "版权与许可"),
|
|
("S62", "src/cli/entry.ts", ""),
|
|
("S63", "src/main.ts", ""),
|
|
]
|
|
PRODUCT = [
|
|
"src/server/runtime.mjs", "src/core/context/working-set.mjs",
|
|
"src/core/context/request-plan.mjs", "src/core/context/delivery-progress.mjs",
|
|
"src/core/tasks/task-plan-manager.mjs", "src/core/tasks/worker-manager.mjs",
|
|
"src/core/git-delivery.mjs", "src/core/models/model-hub.mjs",
|
|
"src/core/models/protocols.mjs", "src/core/memory/project-memory.mjs",
|
|
"src/core/evaluation/evaluation-manager.mjs", "src/core/browser/browser-manager.mjs",
|
|
"src/shared/contracts/task-plans.mjs", "docs/PLAN-1.25.md",
|
|
]
|
|
|
|
|
|
def git(root, *args):
|
|
return subprocess.check_output(["git", "-C", str(root), *args])
|
|
|
|
|
|
def digest(root, rel):
|
|
data = (root / rel).read_bytes()
|
|
return {"path": rel, "bytes": len(data), "sha256": hashlib.sha256(data).hexdigest(),
|
|
"lines": len(data.decode("utf-8").splitlines())}
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--source", required=True, type=Path)
|
|
parser.add_argument("--output", required=True, type=Path)
|
|
args = parser.parse_args()
|
|
source = args.source.resolve()
|
|
product = Path(__file__).resolve().parents[1]
|
|
assert git(source, "rev-parse", "HEAD").decode().strip() == PIN, "Unexpected source revision"
|
|
assert git(source, "status", "--porcelain") == b"", "Source checkout is not clean"
|
|
tracked = git(source, "ls-files", "-z").decode("utf-8").split("\0")[:-1]
|
|
ts = [p for p in tracked if p.startswith("src/") and p.endswith((".ts", ".tsx"))]
|
|
tests = [p for p in ts if "/__tests__/" in p or ".test." in p or ".spec." in p]
|
|
code = [p for p in ts if p not in set(tests)]
|
|
hooks = [p for p in code if p.startswith("src/agent/hooks/")]
|
|
entries = []
|
|
for identifier, rel, needle in SOURCES:
|
|
entry = {"id": identifier, **digest(source, rel)}
|
|
lines = (source / rel).read_text(encoding="utf-8").splitlines()
|
|
matches = [i + 1 for i, line in enumerate(lines) if needle in line] if needle else [1]
|
|
assert matches, f"Anchor not found: {identifier} {rel} {needle}"
|
|
entry.update(anchorLine=matches[0], anchorNeedle=needle,
|
|
url=f"{URL}/blob/{PIN}/{rel}#L{matches[0]}",
|
|
gitBlob=git(source, "rev-parse", f"HEAD:{rel}").decode().strip())
|
|
entries.append(entry)
|
|
result = {
|
|
"schemaVersion": 1, "repository": URL + ".git", "commit": PIN,
|
|
"commitInfo": git(source, "show", "-s", "--format=%cI%n%s", "HEAD").decode().splitlines(),
|
|
"packageVersion": json.loads((source / "package.json").read_text(encoding="utf-8"))["version"],
|
|
"codeLicense": "Apache-2.0",
|
|
"documentExceptions": ["docs/CVM运行时对Agent模型的实证影响.md", "docs/reference/cvm-cognitive-runtime.md"],
|
|
"documentExceptionLicense": "CC-BY-NC-ND-4.0; linked and license-recorded only; not reproduced or adapted",
|
|
"publicTree": {name: any(p.startswith(name + "/") for p in tracked) for name in ["desktop", "src/pro", "vscode-extension", "src/tools/computer-use"]},
|
|
"inventory": {"trackedFiles": len(tracked), "srcTsTsxFiles": len(ts), "testFilesByPathOrName": len(tests),
|
|
"sourceFilesByExclusion": len(code), "sourceLinesSplitlines": sum(digest(source, p)["lines"] for p in code),
|
|
"hookSourceFiles": len(hooks)},
|
|
"inventoryMethod": "git ls-files; src/ .ts/.tsx; tests are /__tests__/ or .test. or .spec.; UTF-8 splitlines counts; no tests executed",
|
|
"sourceFiles": entries,
|
|
"productBaselineCommit": git(product, "rev-parse", PRODUCT_PIN).decode().strip(),
|
|
"productFiles": [digest(product, p) for p in PRODUCT],
|
|
"executionScope": {"fullApplicationStarted": False, "thirdPartyDependenciesInstalled": False, "modelRequests": 0,
|
|
"pureProbeOnly": "Five reviewed modules; separate original output and driver are sealed alongside this index"},
|
|
}
|
|
args.output.parent.mkdir(parents=True, exist_ok=True)
|
|
with args.output.open("x", encoding="utf-8", newline="\n") as stream:
|
|
json.dump(result, stream, ensure_ascii=False, indent=2)
|
|
stream.write("\n")
|
|
print(json.dumps({"commit": PIN, "inventory": result["inventory"], "indexedSources": len(entries), "productFiles": len(PRODUCT)}, ensure_ascii=False))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|