@hizliemre/horse-code 0.3.0 → 0.4.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.
Files changed (32) hide show
  1. package/dist/{app-5FXHE7GX.js → app-KR7TAHUD.js} +82 -40
  2. package/dist/{chunk-LNW557IO.js → chunk-372X5HHU.js} +2 -2
  3. package/dist/{chunk-XEGQT5EN.js → chunk-4M6LXNG2.js} +1 -1
  4. package/dist/{chunk-6OSEQOYY.js → chunk-6S4WWQMN.js} +2 -2
  5. package/dist/chunk-ACTVFJRW.js +989 -0
  6. package/dist/{chunk-LLL7QWXB.js → chunk-BFIZMM4G.js} +6 -6
  7. package/dist/chunk-CYLPQWIF.js +214 -0
  8. package/dist/{chunk-AE36LLL2.js → chunk-JLWQCA7B.js} +2 -209
  9. package/dist/{chunk-XYZVZPAY.js → chunk-KXBYRU4W.js} +66 -31
  10. package/dist/chunk-MZM24M5M.js +251 -0
  11. package/dist/chunk-NBTH2VVI.js +1945 -0
  12. package/dist/chunk-PIG54WFU.js +2873 -0
  13. package/dist/{run-P6ZYL5JL.js → chunk-QJYVZPLG.js} +133 -389
  14. package/dist/{chunk-YPZP7LYL.js → chunk-UANNVVIU.js} +1 -1
  15. package/dist/{chunk-UGESK765.js → chunk-UTHLEW5V.js} +1 -1
  16. package/dist/{chunk-KAGKX2YT.js → chunk-ZPJP2VH5.js} +10 -1
  17. package/dist/cli.js +262 -69
  18. package/dist/{fix-ONLA45HD.js → fix-SSDUVV4T.js} +11 -8
  19. package/dist/{ongoing-WHYXPW24.js → ongoing-6NUSPSCV.js} +3 -2
  20. package/dist/{project-graph-5HNPRFQG.js → project-graph-OGIM2B33.js} +1 -1
  21. package/dist/research-MHBNZ6SA.js +111 -0
  22. package/dist/run-V5ZLZ3LS.js +274 -0
  23. package/dist/{save-skills-ZW5GY6KV.js → save-skills-NPKTYNAF.js} +2 -2
  24. package/dist/{trace-X6TU3AG6.js → trace-UVMZZRA5.js} +1 -1
  25. package/dist/{trace-adopt-URECQWJV.js → trace-adopt-7HWELJFE.js} +1 -1
  26. package/dist/{trace-run-7U4WJZ3V.js → trace-run-OBOD552Q.js} +9 -4
  27. package/dist/{triage-FCYHD2AQ.js → triage-IFCVL5MA.js} +7 -6
  28. package/dist/{verify-LC57A6H2.js → verify-2DTBG6RG.js} +26 -20
  29. package/package.json +1 -1
  30. package/dist/chunk-MRZVA5JB.js +0 -163
  31. package/dist/chunk-UEWVVN5L.js +0 -5691
  32. package/dist/{chunk-EAF22QIG.js → chunk-JR2JLRE3.js} +3 -3
@@ -1,163 +0,0 @@
1
- import {
2
- defaultGitRunner
3
- } from "./chunk-LPQU436C.js";
4
- import {
5
- briefForPrompt,
6
- briefPrompt,
7
- briefStatus,
8
- gatherBriefInput,
9
- saveBrief
10
- } from "./chunk-6OSEQOYY.js";
11
- import {
12
- ensureGitignore,
13
- loadTraceIndex,
14
- planTraces,
15
- pruneTraces,
16
- saveTrace,
17
- saveTraceIndex,
18
- traceCoverage,
19
- tracePrompt,
20
- traceRootRel,
21
- traceable
22
- } from "./chunk-KAGKX2YT.js";
23
- import {
24
- loadGraph
25
- } from "./chunk-XEGQT5EN.js";
26
-
27
- // src/engine/trace-run.ts
28
- async function traceableFiles(cwd, opts) {
29
- const r = await defaultGitRunner(["ls-files", "--cached", "--others", "--exclude-standard"], cwd);
30
- return traceable(r.stdout.split("\n").filter(Boolean), opts);
31
- }
32
- async function coverageFor(cwd) {
33
- return traceCoverage(cwd, await traceableFiles(cwd), await loadTraceIndex(cwd));
34
- }
35
- var TRACE_CONCURRENCY = 6;
36
- var INDEX_CHECKPOINT = 25;
37
- function describePlan(plan, model) {
38
- if (!plan.jobs.length) {
39
- return plan.upToDate ? `All ${plan.upToDate} traces are current \u2014 nothing to write, nothing to spend.` : "No files to trace.";
40
- }
41
- const kIn = Math.round(plan.estimatedInputTokens / 1e3);
42
- const kOut = Math.round(plan.estimatedOutputTokens / 1e3);
43
- const skipped = plan.skipped.length ? `
44
-
45
- ${plan.skipped.length} file(s) skipped as too large to trace economically (e.g. ${plan.skipped.slice(0, 3).map((s) => `\`${s.file}\``).join(", ")}${plan.skipped.length > 3 ? ", \u2026" : ""}).` : "";
46
- const cached = plan.upToDate ? `
47
- ${plan.upToDate} file(s) already have a current trace and will be left alone.` : "";
48
- return `**Tracing ${plan.jobs.length} file(s)** with \`${model}\`.
49
-
50
- This is the part of understanding your project that costs tokens \u2014 the graph was free, this is not. Each file is read once and described in ~150 words.
51
-
52
- Rough cost: **~${kIn}k input + ~${kOut}k output tokens**.${cached}${skipped}`;
53
- }
54
- async function traceOne(provider, model, job, signal, brief) {
55
- const req = {
56
- model,
57
- messages: [
58
- { role: "system", content: "You write terse, factual reference notes about source files. You never speculate." },
59
- { role: "user", content: tracePrompt(job, brief) }
60
- ],
61
- tools: []
62
- };
63
- let out = "";
64
- for await (const ev of provider.chat(req, signal)) {
65
- if (ev.type === "text-delta") out += ev.text;
66
- else if (ev.type === "error") throw new Error(ev.message);
67
- }
68
- const body = out.replace(/<\/?think>/gi, "").trim();
69
- if (!body) throw new Error("empty response");
70
- return body;
71
- }
72
- async function runTraces(opts) {
73
- const { cwd, plan } = opts;
74
- const signal = opts.signal ?? new AbortController().signal;
75
- const index = await loadTraceIndex(cwd);
76
- const brief = briefForPrompt(cwd);
77
- const failed = [];
78
- let written = 0;
79
- let done = 0;
80
- const queue = [...plan.jobs];
81
- const worker = async () => {
82
- for (; ; ) {
83
- const job = queue.shift();
84
- if (!job || signal.aborted) return;
85
- let wroteTo;
86
- let words;
87
- let error;
88
- try {
89
- const body = await traceOne(opts.provider, opts.model, job, signal, brief);
90
- const rec = await saveTrace(cwd, job, body, opts.model);
91
- index.traces[job.file] = rec;
92
- wroteTo = `${traceRootRel()}/${job.file}.md`;
93
- words = body.split(/\s+/).filter(Boolean).length;
94
- written++;
95
- if (written % INDEX_CHECKPOINT === 0) await saveTraceIndex(cwd, index);
96
- } catch (e) {
97
- if (signal.aborted) return;
98
- error = e instanceof Error ? e.message : String(e);
99
- failed.push({ file: job.file, error });
100
- }
101
- opts.onProgress?.({
102
- done: ++done,
103
- total: plan.jobs.length,
104
- file: job.file,
105
- ...wroteTo !== void 0 && { wroteTo },
106
- ...words !== void 0 && { words },
107
- ...error !== void 0 && { error }
108
- });
109
- }
110
- };
111
- await Promise.all(Array.from({ length: Math.min(TRACE_CONCURRENCY, queue.length) }, worker));
112
- const pruned = opts.liveFiles ? await pruneTraces(cwd, opts.liveFiles, index) : [];
113
- await saveTraceIndex(cwd, index);
114
- const wroteGitignore = written > 0 && await ensureGitignore(cwd);
115
- return { written, failed, pruned, upToDate: plan.upToDate, cancelled: signal.aborted, wroteGitignore };
116
- }
117
- async function planFor(cwd, files) {
118
- return planTraces(cwd, files, await loadGraph(cwd), await loadTraceIndex(cwd));
119
- }
120
- async function buildBrief(opts) {
121
- if (!opts.force) {
122
- const st = await briefStatus(opts.cwd, opts.files);
123
- if (st.built && !st.stale) {
124
- return { ok: true, skipped: true, message: `Project brief is current (${st.sources.length} document(s)) \u2014 not rewritten.` };
125
- }
126
- }
127
- const input = await gatherBriefInput(opts.cwd, opts.files);
128
- if (!input) {
129
- return { ok: false, message: "No documentation found (README, docs/, specs/) \u2014 traces will describe the code without product context." };
130
- }
131
- const signal = opts.signal ?? new AbortController().signal;
132
- const req = {
133
- model: opts.model,
134
- messages: [
135
- { role: "system", content: "You write factual project briefings from documentation. You never invent facts the documents do not state." },
136
- { role: "user", content: briefPrompt(input) }
137
- ],
138
- tools: []
139
- };
140
- let out = "";
141
- try {
142
- for await (const ev of opts.provider.chat(req, signal)) {
143
- if (ev.type === "text-delta") out += ev.text;
144
- else if (ev.type === "error") throw new Error(ev.message);
145
- }
146
- } catch (e) {
147
- return { ok: false, message: `Project brief failed (${e instanceof Error ? e.message : String(e)}) \u2014 tracing can still run without it.` };
148
- }
149
- const body = out.replace(/<\/?think>/gi, "").trim();
150
- if (!body) return { ok: false, message: "The brief came back empty \u2014 tracing can still run without it." };
151
- await saveBrief(opts.cwd, body, { hash: input.hash, sources: input.sources.map((s) => s.file), writtenAt: Date.now(), model: opts.model });
152
- return { ok: true, message: `**Project brief** written from ${input.sources.length} document(s): ${input.sources.slice(0, 6).map((s) => `\`${s.file}\``).join(", ")}` };
153
- }
154
-
155
- export {
156
- traceableFiles,
157
- coverageFor,
158
- TRACE_CONCURRENCY,
159
- describePlan,
160
- runTraces,
161
- planFor,
162
- buildBrief
163
- };