briefed 0.1.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/LICENSE +21 -0
- package/README.md +118 -0
- package/dist/bench/metrics.d.ts +31 -0
- package/dist/bench/metrics.js +122 -0
- package/dist/bench/metrics.js.map +1 -0
- package/dist/bench/runner.d.ts +27 -0
- package/dist/bench/runner.js +184 -0
- package/dist/bench/runner.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +42 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/bench.d.ts +11 -0
- package/dist/commands/bench.js +23 -0
- package/dist/commands/bench.js.map +1 -0
- package/dist/commands/doctor.d.ts +5 -0
- package/dist/commands/doctor.js +246 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.js +319 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/stats.d.ts +5 -0
- package/dist/commands/stats.js +87 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/deliver/ci.d.ts +4 -0
- package/dist/deliver/ci.js +62 -0
- package/dist/deliver/ci.js.map +1 -0
- package/dist/deliver/claudemd.d.ts +9 -0
- package/dist/deliver/claudemd.js +51 -0
- package/dist/deliver/claudemd.js.map +1 -0
- package/dist/deliver/cross-tool.d.ts +10 -0
- package/dist/deliver/cross-tool.js +49 -0
- package/dist/deliver/cross-tool.js.map +1 -0
- package/dist/deliver/git-hook.d.ts +10 -0
- package/dist/deliver/git-hook.js +104 -0
- package/dist/deliver/git-hook.js.map +1 -0
- package/dist/deliver/hooks.d.ts +9 -0
- package/dist/deliver/hooks.js +315 -0
- package/dist/deliver/hooks.js.map +1 -0
- package/dist/extract/complexity.d.ts +16 -0
- package/dist/extract/complexity.js +46 -0
- package/dist/extract/complexity.js.map +1 -0
- package/dist/extract/conventions.d.ts +18 -0
- package/dist/extract/conventions.js +143 -0
- package/dist/extract/conventions.js.map +1 -0
- package/dist/extract/depgraph.d.ts +12 -0
- package/dist/extract/depgraph.js +70 -0
- package/dist/extract/depgraph.js.map +1 -0
- package/dist/extract/env.d.ts +17 -0
- package/dist/extract/env.js +142 -0
- package/dist/extract/env.js.map +1 -0
- package/dist/extract/error-patterns.d.ts +15 -0
- package/dist/extract/error-patterns.js +107 -0
- package/dist/extract/error-patterns.js.map +1 -0
- package/dist/extract/frontend.d.ts +30 -0
- package/dist/extract/frontend.js +244 -0
- package/dist/extract/frontend.js.map +1 -0
- package/dist/extract/gotchas.d.ts +12 -0
- package/dist/extract/gotchas.js +145 -0
- package/dist/extract/gotchas.js.map +1 -0
- package/dist/extract/history.d.ts +29 -0
- package/dist/extract/history.js +91 -0
- package/dist/extract/history.js.map +1 -0
- package/dist/extract/infra.d.ts +27 -0
- package/dist/extract/infra.js +226 -0
- package/dist/extract/infra.js.map +1 -0
- package/dist/extract/monorepo.d.ts +16 -0
- package/dist/extract/monorepo.js +135 -0
- package/dist/extract/monorepo.js.map +1 -0
- package/dist/extract/routes.d.ts +16 -0
- package/dist/extract/routes.js +156 -0
- package/dist/extract/routes.js.map +1 -0
- package/dist/extract/scanner.d.ts +18 -0
- package/dist/extract/scanner.js +109 -0
- package/dist/extract/scanner.js.map +1 -0
- package/dist/extract/schema.d.ts +28 -0
- package/dist/extract/schema.js +192 -0
- package/dist/extract/schema.js.map +1 -0
- package/dist/extract/scripts.d.ts +18 -0
- package/dist/extract/scripts.js +104 -0
- package/dist/extract/scripts.js.map +1 -0
- package/dist/extract/security.d.ts +20 -0
- package/dist/extract/security.js +95 -0
- package/dist/extract/security.js.map +1 -0
- package/dist/extract/signatures.d.ts +33 -0
- package/dist/extract/signatures.js +608 -0
- package/dist/extract/signatures.js.map +1 -0
- package/dist/extract/staleness.d.ts +16 -0
- package/dist/extract/staleness.js +108 -0
- package/dist/extract/staleness.js.map +1 -0
- package/dist/extract/tests.d.ts +16 -0
- package/dist/extract/tests.js +175 -0
- package/dist/extract/tests.js.map +1 -0
- package/dist/extract/usage-examples.d.ts +17 -0
- package/dist/extract/usage-examples.js +115 -0
- package/dist/extract/usage-examples.js.map +1 -0
- package/dist/generate/index-file.d.ts +29 -0
- package/dist/generate/index-file.js +168 -0
- package/dist/generate/index-file.js.map +1 -0
- package/dist/generate/rules.d.ts +6 -0
- package/dist/generate/rules.js +94 -0
- package/dist/generate/rules.js.map +1 -0
- package/dist/generate/skeleton.d.ts +14 -0
- package/dist/generate/skeleton.js +145 -0
- package/dist/generate/skeleton.js.map +1 -0
- package/dist/learn/tracker.d.ts +54 -0
- package/dist/learn/tracker.js +129 -0
- package/dist/learn/tracker.js.map +1 -0
- package/dist/utils/detect.d.ts +16 -0
- package/dist/utils/detect.js +188 -0
- package/dist/utils/detect.js.map +1 -0
- package/dist/utils/pagerank.d.ts +19 -0
- package/dist/utils/pagerank.js +52 -0
- package/dist/utils/pagerank.js.map +1 -0
- package/dist/utils/tokens.d.ts +11 -0
- package/dist/utils/tokens.js +27 -0
- package/dist/utils/tokens.js.map +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Wesley
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# briefed
|
|
2
|
+
|
|
3
|
+
**Your AI already knows your codebase before you ask.**
|
|
4
|
+
|
|
5
|
+
briefed scans your repository once and compiles a focused, token-efficient context snapshot that Claude Code, Cursor, and Copilot load automatically at the start of every session — eliminating the orientation phase where AI tools spend 8–12 seconds reading files they should already know.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx briefed init
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
That's it. briefed installs itself and auto-updates on every commit.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## The problem
|
|
16
|
+
|
|
17
|
+
Every AI coding session starts the same way: the model reads 5–10 files, builds a mental model of your codebase, then starts working. This costs ~5,000–10,000 tokens and 8–12 seconds *before a single line of code is written* — on every task.
|
|
18
|
+
|
|
19
|
+
briefed pre-computes that mental model so the AI starts already oriented.
|
|
20
|
+
|
|
21
|
+
## What it produces
|
|
22
|
+
|
|
23
|
+
Three layers, delivered through the right channels:
|
|
24
|
+
|
|
25
|
+
| Layer | What | Where | When loaded |
|
|
26
|
+
|-------|------|--------|-------------|
|
|
27
|
+
| Skeleton | File tree, exports, function signatures, dependency graph | `CLAUDE.md` | Every session |
|
|
28
|
+
| Gotchas | Constraints, guard clauses, ordering deps, implicit contracts | `.claude/rules/` | When touching matching files |
|
|
29
|
+
| Contracts | Per-module behavioral contracts, state machines, side effects | `.briefed/contracts/` | Per-prompt via hook |
|
|
30
|
+
|
|
31
|
+
**Estimated savings: ~5,000–8,000 tokens per prompt, ~7–11 seconds per task.**
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Run once in any repo
|
|
37
|
+
npx briefed init
|
|
38
|
+
|
|
39
|
+
# Check your setup
|
|
40
|
+
npx briefed doctor
|
|
41
|
+
|
|
42
|
+
# See token usage stats
|
|
43
|
+
npx briefed stats
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## What gets generated
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
your-repo/
|
|
50
|
+
├── CLAUDE.md # skeleton — always loaded by Claude Code
|
|
51
|
+
├── AGENTS.md # cross-tool context (Copilot, OpenAI agents)
|
|
52
|
+
├── .cursorrules # Cursor IDE context
|
|
53
|
+
├── .claude/
|
|
54
|
+
│ ├── settings.json # hooks registered here
|
|
55
|
+
│ └── rules/
|
|
56
|
+
│ └── briefed-*.md # path-scoped gotchas
|
|
57
|
+
└── .briefed/
|
|
58
|
+
├── contracts/ # module behavioral contracts
|
|
59
|
+
├── index.json # module map for hook matching
|
|
60
|
+
├── test-map.json # source → test file mappings
|
|
61
|
+
└── history.json # git churn data
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## How it stays fresh
|
|
65
|
+
|
|
66
|
+
briefed installs a git `post-commit` hook that re-indexes your codebase after every commit in the background (~5 seconds, async). No CI required.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Manual refresh
|
|
70
|
+
npx briefed init
|
|
71
|
+
|
|
72
|
+
# Check staleness
|
|
73
|
+
npx briefed doctor
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## What gets mapped
|
|
77
|
+
|
|
78
|
+
briefed extracts context across every domain relevant to your project:
|
|
79
|
+
|
|
80
|
+
- **Code structure** — function signatures, exports, dependency graph, PageRank-ranked by importance
|
|
81
|
+
- **Schemas** — Prisma, Drizzle, Django, TypeORM models and relations
|
|
82
|
+
- **API routes** — Express, Fastify, Next.js, FastAPI, Django, Hono endpoints
|
|
83
|
+
- **Frontend** — pages, components, state stores (Zustand, Redux, Context)
|
|
84
|
+
- **Infrastructure** — Docker Compose, Terraform, Kubernetes, deployment platform
|
|
85
|
+
- **Environment** — required env vars with descriptions
|
|
86
|
+
- **Tests** — source → test file mappings
|
|
87
|
+
- **Git history** — churn data, recent changes per file
|
|
88
|
+
- **Conventions** — naming patterns, error handling style, code patterns
|
|
89
|
+
- **Gotchas** — important comments, guard clauses, state machine transitions
|
|
90
|
+
|
|
91
|
+
Only domains relevant to your project are included — a pure API project won't get frontend context.
|
|
92
|
+
|
|
93
|
+
## Commands
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
briefed init # scan and compile context
|
|
97
|
+
briefed init --skip-hooks # init without installing hooks
|
|
98
|
+
briefed init --skip-rules # init without writing .claude/rules/
|
|
99
|
+
briefed stats # show token usage breakdown
|
|
100
|
+
briefed doctor # validate setup, check staleness
|
|
101
|
+
briefed bench # benchmark with vs without briefed
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Works with
|
|
105
|
+
|
|
106
|
+
- **Claude Code** — hooks inject context automatically
|
|
107
|
+
- **Cursor** — `.cursorrules` loaded on every file
|
|
108
|
+
- **GitHub Copilot** — `AGENTS.md` provides baseline context
|
|
109
|
+
- **Any tool** that reads `CLAUDE.md` or `AGENTS.md`
|
|
110
|
+
|
|
111
|
+
## Requirements
|
|
112
|
+
|
|
113
|
+
- Node.js >= 20
|
|
114
|
+
- Git (for auto-update hook)
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
MIT
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metrics extracted from a `claude -p --output-format json` result.
|
|
3
|
+
*/
|
|
4
|
+
export interface TaskMetrics {
|
|
5
|
+
durationMs: number;
|
|
6
|
+
numTurns: number;
|
|
7
|
+
inputTokens: number;
|
|
8
|
+
outputTokens: number;
|
|
9
|
+
cacheCreationTokens: number;
|
|
10
|
+
cacheReadTokens: number;
|
|
11
|
+
totalCostUsd: number;
|
|
12
|
+
resultLength: number;
|
|
13
|
+
sessionId: string;
|
|
14
|
+
success: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Parse a claude -p JSON output file into metrics.
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseResult(filePath: string): TaskMetrics;
|
|
20
|
+
/**
|
|
21
|
+
* Compare two task results and produce a formatted row.
|
|
22
|
+
*/
|
|
23
|
+
export declare function compareMetrics(without: TaskMetrics, withCctx: TaskMetrics, taskName: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Generate a summary report from multiple task comparisons.
|
|
26
|
+
*/
|
|
27
|
+
export declare function generateSummary(results: Array<{
|
|
28
|
+
task: string;
|
|
29
|
+
without: TaskMetrics | null;
|
|
30
|
+
withCctx: TaskMetrics | null;
|
|
31
|
+
}>): string;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
/**
|
|
3
|
+
* Parse a claude -p JSON output file into metrics.
|
|
4
|
+
*/
|
|
5
|
+
export function parseResult(filePath) {
|
|
6
|
+
const content = readFileSync(filePath, "utf-8").trim();
|
|
7
|
+
// Handle JSONL (multiple lines) — take the last valid JSON
|
|
8
|
+
const lines = content.split("\n").filter(Boolean);
|
|
9
|
+
let data = null;
|
|
10
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
11
|
+
try {
|
|
12
|
+
const parsed = JSON.parse(lines[i]);
|
|
13
|
+
if (parsed.type === "result" || parsed.duration_ms) {
|
|
14
|
+
data = parsed;
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (!data) {
|
|
23
|
+
// Try parsing the whole content as one JSON
|
|
24
|
+
data = JSON.parse(content);
|
|
25
|
+
}
|
|
26
|
+
if (!data)
|
|
27
|
+
throw new Error("No valid JSON found in transcript");
|
|
28
|
+
const usage = (data.usage || {});
|
|
29
|
+
return {
|
|
30
|
+
durationMs: data.duration_ms || 0,
|
|
31
|
+
numTurns: data.num_turns || 0,
|
|
32
|
+
inputTokens: usage.input_tokens || 0,
|
|
33
|
+
outputTokens: usage.output_tokens || 0,
|
|
34
|
+
cacheCreationTokens: usage.cache_creation_input_tokens || 0,
|
|
35
|
+
cacheReadTokens: usage.cache_read_input_tokens || 0,
|
|
36
|
+
totalCostUsd: data.total_cost_usd || 0,
|
|
37
|
+
resultLength: (data.result || "").length,
|
|
38
|
+
sessionId: data.session_id || "",
|
|
39
|
+
success: data.subtype === "success" && !data.is_error,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Compare two task results and produce a formatted row.
|
|
44
|
+
*/
|
|
45
|
+
export function compareMetrics(without, withCctx, taskName) {
|
|
46
|
+
const lines = [];
|
|
47
|
+
lines.push(` Task: "${taskName}"`);
|
|
48
|
+
lines.push(" " + "─".repeat(62));
|
|
49
|
+
lines.push(padRow("", "Without briefed", "With briefed", "Delta"));
|
|
50
|
+
lines.push(" " + "─".repeat(62));
|
|
51
|
+
lines.push(padRow("Duration", `${(without.durationMs / 1000).toFixed(1)}s`, `${(withCctx.durationMs / 1000).toFixed(1)}s`, formatDelta(without.durationMs, withCctx.durationMs)));
|
|
52
|
+
lines.push(padRow("Turns", without.numTurns.toString(), withCctx.numTurns.toString(), formatDelta(without.numTurns, withCctx.numTurns)));
|
|
53
|
+
lines.push(padRow("Input tokens", formatNumber(without.inputTokens), formatNumber(withCctx.inputTokens), formatDelta(without.inputTokens, withCctx.inputTokens)));
|
|
54
|
+
lines.push(padRow("Output tokens", formatNumber(without.outputTokens), formatNumber(withCctx.outputTokens), formatDelta(without.outputTokens, withCctx.outputTokens, true)));
|
|
55
|
+
lines.push(padRow("Cache created", formatNumber(without.cacheCreationTokens), formatNumber(withCctx.cacheCreationTokens), formatDelta(without.cacheCreationTokens, withCctx.cacheCreationTokens)));
|
|
56
|
+
lines.push(padRow("Cache read", formatNumber(without.cacheReadTokens), formatNumber(withCctx.cacheReadTokens), formatDelta(without.cacheReadTokens, withCctx.cacheReadTokens, true)));
|
|
57
|
+
lines.push(padRow("Cost", `$${without.totalCostUsd.toFixed(4)}`, `$${withCctx.totalCostUsd.toFixed(4)}`, formatDelta(without.totalCostUsd, withCctx.totalCostUsd)));
|
|
58
|
+
lines.push(" " + "─".repeat(62));
|
|
59
|
+
return lines.join("\n");
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Generate a summary report from multiple task comparisons.
|
|
63
|
+
*/
|
|
64
|
+
export function generateSummary(results) {
|
|
65
|
+
const lines = [];
|
|
66
|
+
let compared = 0;
|
|
67
|
+
let totalDurationWithout = 0;
|
|
68
|
+
let totalDurationWith = 0;
|
|
69
|
+
let totalInputWithout = 0;
|
|
70
|
+
let totalInputWith = 0;
|
|
71
|
+
let totalTurnsWithout = 0;
|
|
72
|
+
let totalTurnsWith = 0;
|
|
73
|
+
let totalCostWithout = 0;
|
|
74
|
+
let totalCostWith = 0;
|
|
75
|
+
for (const r of results) {
|
|
76
|
+
if (r.without && r.withCctx) {
|
|
77
|
+
compared++;
|
|
78
|
+
totalDurationWithout += r.without.durationMs;
|
|
79
|
+
totalDurationWith += r.withCctx.durationMs;
|
|
80
|
+
totalInputWithout += r.without.inputTokens;
|
|
81
|
+
totalInputWith += r.withCctx.inputTokens;
|
|
82
|
+
totalTurnsWithout += r.without.numTurns;
|
|
83
|
+
totalTurnsWith += r.withCctx.numTurns;
|
|
84
|
+
totalCostWithout += r.without.totalCostUsd;
|
|
85
|
+
totalCostWith += r.withCctx.totalCostUsd;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (compared === 0) {
|
|
89
|
+
lines.push(" No tasks with both runs to compare.");
|
|
90
|
+
return lines.join("\n");
|
|
91
|
+
}
|
|
92
|
+
lines.push(" " + "═".repeat(62));
|
|
93
|
+
lines.push(" SUMMARY");
|
|
94
|
+
lines.push(" " + "═".repeat(62));
|
|
95
|
+
lines.push(` Tasks compared: ${compared}`);
|
|
96
|
+
lines.push(` Avg duration: ${(totalDurationWithout / compared / 1000).toFixed(1)}s → ${(totalDurationWith / compared / 1000).toFixed(1)}s (${formatDelta(totalDurationWithout, totalDurationWith)})`);
|
|
97
|
+
lines.push(` Avg input tokens: ${formatNumber(Math.round(totalInputWithout / compared))} → ${formatNumber(Math.round(totalInputWith / compared))} (${formatDelta(totalInputWithout, totalInputWith)})`);
|
|
98
|
+
lines.push(` Avg turns: ${(totalTurnsWithout / compared).toFixed(1)} → ${(totalTurnsWith / compared).toFixed(1)} (${formatDelta(totalTurnsWithout, totalTurnsWith)})`);
|
|
99
|
+
lines.push(` Total cost: $${totalCostWithout.toFixed(4)} → $${totalCostWith.toFixed(4)} (${formatDelta(totalCostWithout, totalCostWith)})`);
|
|
100
|
+
lines.push(" " + "═".repeat(62));
|
|
101
|
+
return lines.join("\n");
|
|
102
|
+
}
|
|
103
|
+
function padRow(label, col1, col2, col3) {
|
|
104
|
+
return ` ${label.padEnd(18)} ${col1.padStart(14)} ${col2.padStart(14)} ${col3.padStart(10)}`;
|
|
105
|
+
}
|
|
106
|
+
function formatDelta(before, after, higherIsBetter = false) {
|
|
107
|
+
if (before === 0 && after === 0)
|
|
108
|
+
return "—";
|
|
109
|
+
if (before === 0)
|
|
110
|
+
return `+${after}`;
|
|
111
|
+
const pct = Math.round(((after - before) / before) * 100);
|
|
112
|
+
const sign = pct >= 0 ? "+" : "";
|
|
113
|
+
return `${sign}${pct}%`;
|
|
114
|
+
}
|
|
115
|
+
function formatNumber(n) {
|
|
116
|
+
if (n >= 1_000_000)
|
|
117
|
+
return `${(n / 1_000_000).toFixed(1)}M`;
|
|
118
|
+
if (n >= 1_000)
|
|
119
|
+
return `${(n / 1_000).toFixed(1)}K`;
|
|
120
|
+
return n.toString();
|
|
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GAAG,CAAC;AAC1B,CAAC;AAED,SAAS,YAAY,CAAC,CAAS;IAC7B,IAAI,CAAC,IAAI,SAAS;QAAE,OAAO,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAC5D,IAAI,CAAC,IAAI,KAAK;QAAE,OAAO,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACpD,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type TaskMetrics } from "./metrics.js";
|
|
2
|
+
export interface BenchTask {
|
|
3
|
+
name: string;
|
|
4
|
+
prompt: string;
|
|
5
|
+
}
|
|
6
|
+
export interface BenchResult {
|
|
7
|
+
task: BenchTask;
|
|
8
|
+
without: TaskMetrics | null;
|
|
9
|
+
withCctx: TaskMetrics | null;
|
|
10
|
+
error: string | null;
|
|
11
|
+
}
|
|
12
|
+
export interface RunOptions {
|
|
13
|
+
repo: string;
|
|
14
|
+
tasks?: BenchTask[];
|
|
15
|
+
outputDir?: string;
|
|
16
|
+
skipWithout?: boolean;
|
|
17
|
+
skipWith?: boolean;
|
|
18
|
+
maxTasks?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Run the benchmark: execute tasks with and without briefed, compare results.
|
|
22
|
+
*/
|
|
23
|
+
export declare function runBenchmark(opts: RunOptions): Promise<BenchResult[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Generate the full report string.
|
|
26
|
+
*/
|
|
27
|
+
export declare function generateReport(results: BenchResult[]): string;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { execSync, spawnSync } from "child_process";
|
|
2
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, rmSync } from "fs";
|
|
3
|
+
import { join, resolve } from "path";
|
|
4
|
+
import { parseResult, compareMetrics, generateSummary } from "./metrics.js";
|
|
5
|
+
const DEFAULT_TASKS = [
|
|
6
|
+
{
|
|
7
|
+
name: "understand-architecture",
|
|
8
|
+
prompt: "Read the source files in this project and explain the overall architecture. What are the main modules, how do they connect, and what is the entry point? List every source file you read.",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: "add-verbose-flag",
|
|
12
|
+
prompt: "Read the main CLI entry point and add a --verbose flag that enables debug logging throughout the application. Read the relevant source files first, then make the code changes.",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: "find-and-fix-bugs",
|
|
16
|
+
prompt: "Read through the source code and identify any potential bugs, missing error handling, or edge cases. Fix at least 2 issues you find. Read every source file before making changes.",
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* Run the benchmark: execute tasks with and without briefed, compare results.
|
|
21
|
+
*/
|
|
22
|
+
export async function runBenchmark(opts) {
|
|
23
|
+
const root = resolve(opts.repo);
|
|
24
|
+
const tasks = (opts.tasks || DEFAULT_TASKS).slice(0, opts.maxTasks || 3);
|
|
25
|
+
const outputDir = resolve(opts.outputDir || join(root, ".briefed", "bench"));
|
|
26
|
+
mkdirSync(join(outputDir, "without"), { recursive: true });
|
|
27
|
+
mkdirSync(join(outputDir, "with"), { recursive: true });
|
|
28
|
+
const claudePath = findClaude();
|
|
29
|
+
if (!claudePath) {
|
|
30
|
+
console.error(" Error: 'claude' CLI not found.");
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
console.log(` Using: ${claudePath}`);
|
|
34
|
+
// Phase 1: Run tasks WITHOUT briefed
|
|
35
|
+
if (!opts.skipWithout) {
|
|
36
|
+
console.log("\n Phase 1: Running tasks WITHOUT briefed...\n");
|
|
37
|
+
const hadCctx = backupCctxArtifacts(root);
|
|
38
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
39
|
+
const task = tasks[i];
|
|
40
|
+
console.log(` [${i + 1}/${tasks.length}] ${task.name}`);
|
|
41
|
+
try {
|
|
42
|
+
runClaudeTask(claudePath, root, task.prompt, join(outputDir, "without", `${task.name}.json`));
|
|
43
|
+
const m = parseResult(join(outputDir, "without", `${task.name}.json`));
|
|
44
|
+
console.log(` ${(m.durationMs / 1000).toFixed(1)}s, ${m.numTurns} turns, ${m.inputTokens + m.outputTokens} tokens`);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
console.error(` Error: ${e.message.slice(0, 100)}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
restoreCctxArtifacts(root, hadCctx);
|
|
51
|
+
}
|
|
52
|
+
// Phase 2: Run tasks WITH briefed
|
|
53
|
+
if (!opts.skipWith) {
|
|
54
|
+
console.log("\n Phase 2: Running tasks WITH briefed...\n");
|
|
55
|
+
if (!existsSync(join(root, ".briefed", "skeleton.md"))) {
|
|
56
|
+
console.log(" Initializing briefed...");
|
|
57
|
+
const briefedCli = join(import.meta.dirname, "..", "cli.js");
|
|
58
|
+
execSync(`node "${briefedCli}" init --repo "${root}" --skip-hooks`, { stdio: "inherit" });
|
|
59
|
+
}
|
|
60
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
61
|
+
const task = tasks[i];
|
|
62
|
+
console.log(` [${i + 1}/${tasks.length}] ${task.name}`);
|
|
63
|
+
try {
|
|
64
|
+
runClaudeTask(claudePath, root, task.prompt, join(outputDir, "with", `${task.name}.json`));
|
|
65
|
+
const m = parseResult(join(outputDir, "with", `${task.name}.json`));
|
|
66
|
+
console.log(` ${(m.durationMs / 1000).toFixed(1)}s, ${m.numTurns} turns, ${m.inputTokens + m.outputTokens} tokens`);
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
console.error(` Error: ${e.message.slice(0, 100)}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Phase 3: Compare
|
|
74
|
+
console.log("\n Phase 3: Results\n");
|
|
75
|
+
const results = [];
|
|
76
|
+
for (const task of tasks) {
|
|
77
|
+
const result = { task, without: null, withCctx: null, error: null };
|
|
78
|
+
try {
|
|
79
|
+
const wp = join(outputDir, "without", `${task.name}.json`);
|
|
80
|
+
const cp = join(outputDir, "with", `${task.name}.json`);
|
|
81
|
+
if (existsSync(wp))
|
|
82
|
+
result.without = parseResult(wp);
|
|
83
|
+
if (existsSync(cp))
|
|
84
|
+
result.withCctx = parseResult(cp);
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
result.error = e.message;
|
|
88
|
+
}
|
|
89
|
+
results.push(result);
|
|
90
|
+
}
|
|
91
|
+
return results;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Generate the full report string.
|
|
95
|
+
*/
|
|
96
|
+
export function generateReport(results) {
|
|
97
|
+
const lines = [];
|
|
98
|
+
lines.push(" " + "═".repeat(62));
|
|
99
|
+
lines.push(" briefed Benchmark Report");
|
|
100
|
+
lines.push(" " + "═".repeat(62));
|
|
101
|
+
lines.push("");
|
|
102
|
+
const summaryData = [];
|
|
103
|
+
for (const r of results) {
|
|
104
|
+
if (r.without && r.withCctx) {
|
|
105
|
+
lines.push(compareMetrics(r.without, r.withCctx, r.task.name));
|
|
106
|
+
lines.push("");
|
|
107
|
+
}
|
|
108
|
+
else if (r.error) {
|
|
109
|
+
lines.push(` Task "${r.task.name}": Error — ${r.error}`);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
lines.push(` Task "${r.task.name}": Missing data (need both runs)`);
|
|
113
|
+
}
|
|
114
|
+
summaryData.push({ task: r.task.name, without: r.without, withCctx: r.withCctx });
|
|
115
|
+
}
|
|
116
|
+
lines.push(generateSummary(summaryData));
|
|
117
|
+
return lines.join("\n");
|
|
118
|
+
}
|
|
119
|
+
function findClaude() {
|
|
120
|
+
const candidates = [
|
|
121
|
+
"claude",
|
|
122
|
+
"claude.cmd",
|
|
123
|
+
join(process.env.APPDATA || "", "npm", "claude.cmd"),
|
|
124
|
+
join(process.env.APPDATA || "", "npm", "claude"),
|
|
125
|
+
];
|
|
126
|
+
for (const c of candidates) {
|
|
127
|
+
try {
|
|
128
|
+
const r = spawnSync(c, ["--version"], { stdio: "pipe", timeout: 5000, encoding: "utf-8", shell: true });
|
|
129
|
+
if (r.status === 0)
|
|
130
|
+
return c;
|
|
131
|
+
}
|
|
132
|
+
catch { /* next */ }
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
function runClaudeTask(claudePath, cwd, prompt, outputPath) {
|
|
137
|
+
const result = spawnSync(claudePath, ["-p", prompt, "--output-format", "json", "--max-turns", "20", "--permission-mode", "bypassPermissions"], { cwd, stdio: ["pipe", "pipe", "pipe"], timeout: 300_000, encoding: "utf-8", shell: true });
|
|
138
|
+
if (result.error)
|
|
139
|
+
throw new Error(`CLI failed: ${result.error.message}`);
|
|
140
|
+
if (result.stdout?.trim()) {
|
|
141
|
+
writeFileSync(outputPath, result.stdout);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
throw new Error(result.stderr?.slice(0, 200) || "No output");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function backupCctxArtifacts(root) {
|
|
148
|
+
const claudeMd = join(root, "CLAUDE.md");
|
|
149
|
+
const rulesDir = join(root, ".claude", "rules");
|
|
150
|
+
let had = false;
|
|
151
|
+
if (existsSync(claudeMd)) {
|
|
152
|
+
const content = readFileSync(claudeMd, "utf-8");
|
|
153
|
+
if (content.includes("<!-- briefed:start -->")) {
|
|
154
|
+
writeFileSync(claudeMd + ".bak", content);
|
|
155
|
+
writeFileSync(claudeMd, content.replace(/<!-- briefed:start -->[\s\S]*?<!-- briefed:end -->\n?/, "").trim() || "");
|
|
156
|
+
had = true;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (existsSync(rulesDir)) {
|
|
160
|
+
for (const f of readdirSync(rulesDir).filter((f) => f.startsWith("briefed-"))) {
|
|
161
|
+
writeFileSync(join(rulesDir, f + ".bak"), readFileSync(join(rulesDir, f)));
|
|
162
|
+
rmSync(join(rulesDir, f));
|
|
163
|
+
had = true;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return had;
|
|
167
|
+
}
|
|
168
|
+
function restoreCctxArtifacts(root, had) {
|
|
169
|
+
if (!had)
|
|
170
|
+
return;
|
|
171
|
+
const claudeMd = join(root, "CLAUDE.md");
|
|
172
|
+
const rulesDir = join(root, ".claude", "rules");
|
|
173
|
+
if (existsSync(claudeMd + ".bak")) {
|
|
174
|
+
writeFileSync(claudeMd, readFileSync(claudeMd + ".bak", "utf-8"));
|
|
175
|
+
rmSync(claudeMd + ".bak");
|
|
176
|
+
}
|
|
177
|
+
if (existsSync(rulesDir)) {
|
|
178
|
+
for (const f of readdirSync(rulesDir).filter((f) => f.endsWith(".bak"))) {
|
|
179
|
+
writeFileSync(join(rulesDir, f.replace(".bak", "")), readFileSync(join(rulesDir, f)));
|
|
180
|
+
rmSync(join(rulesDir, f));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/bench/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC7F,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAoB,MAAM,cAAc,CAAC;AAc9F,MAAM,aAAa,GAAgB;IACjC;QACE,IAAI,EAAE,yBAAyB;QAC/B,MAAM,EAAE,2LAA2L;KACpM;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,MAAM,EAAE,iLAAiL;KAC1L;IACD;QACE,IAA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,EAAE,YAAY,CAAC,QAAQ,GAAG,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAClE,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC;IAC5B,CAAC;IACD,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,KAAK,MAAM,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;YACxE,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YACtF,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { initCommand } from "./commands/init.js";
|
|
4
|
+
import { statsCommand } from "./commands/stats.js";
|
|
5
|
+
import { benchCommand } from "./commands/bench.js";
|
|
6
|
+
import { doctorCommand } from "./commands/doctor.js";
|
|
7
|
+
const program = new Command();
|
|
8
|
+
program
|
|
9
|
+
.name("briefed")
|
|
10
|
+
.description("Adaptive Context Engine — compile your codebase into focused, token-efficient context for AI coding tools")
|
|
11
|
+
.version("0.1.0");
|
|
12
|
+
program
|
|
13
|
+
.command("init")
|
|
14
|
+
.description("Scan codebase and compile context (skeleton + gotchas + hooks)")
|
|
15
|
+
.option("--repo <path>", "Repository root path", ".")
|
|
16
|
+
.option("--max-tokens <n>", "Token budget for skeleton", "1000")
|
|
17
|
+
.option("--skip-hooks", "Skip hook installation")
|
|
18
|
+
.option("--skip-rules", "Skip .claude/rules/ generation")
|
|
19
|
+
.action(initCommand);
|
|
20
|
+
program
|
|
21
|
+
.command("stats")
|
|
22
|
+
.description("Show token usage and context statistics")
|
|
23
|
+
.option("--repo <path>", "Repository root path", ".")
|
|
24
|
+
.action(statsCommand);
|
|
25
|
+
program
|
|
26
|
+
.command("doctor")
|
|
27
|
+
.description("Validate briefed setup and diagnose issues")
|
|
28
|
+
.option("--repo <path>", "Repository root path", ".")
|
|
29
|
+
.action(doctorCommand);
|
|
30
|
+
program
|
|
31
|
+
.command("bench")
|
|
32
|
+
.description("Benchmark briefed vs default Claude Code (uses your subscription)")
|
|
33
|
+
.option("--repo <path>", "Repository to benchmark", ".")
|
|
34
|
+
.option("--quick", "Run 3 tasks (fastest)")
|
|
35
|
+
.option("--full", "Run 10 tasks (most thorough)")
|
|
36
|
+
.option("--with-only", "Only run WITH briefed (skip without)")
|
|
37
|
+
.option("--without-only", "Only run WITHOUT briefed")
|
|
38
|
+
.option("--report-only", "Just generate report from existing transcripts")
|
|
39
|
+
.option("--output <dir>", "Output directory for transcripts")
|
|
40
|
+
.action(benchCommand);
|
|
41
|
+
program.parse();
|
|
42
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,SAAS,CAAC;KACf,WAAW,CACV,2GA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ions {
|
|
2
|
+
repo: string;
|
|
3
|
+
quick?: boolean;
|
|
4
|
+
full?: boolean;
|
|
5
|
+
withOnly?: boolean;
|
|
6
|
+
withoutOnly?: boolean;
|
|
7
|
+
reportOnly?: boolean;
|
|
8
|
+
output?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function benchCommand(opts: BenchOptions): Promise<void>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { resolve, join } from "path";
|
|
2
|
+
import { writeFileSync, existsSync } from "fs";
|
|
3
|
+
import { runBenchmark, generateReport } from "../bench/runner.js";
|
|
4
|
+
export async function benchCommand(opts) {
|
|
5
|
+
const root = resolve(opts.repo);
|
|
6
|
+
console.log(" briefed bench — measuring context efficiency");
|
|
7
|
+
console.log(` Repository: ${root}\n`);
|
|
8
|
+
const results = await runBenchmark({
|
|
9
|
+
repo: root,
|
|
10
|
+
maxTasks: opts.quick ? 2 : opts.full ? 5 : 3,
|
|
11
|
+
skipWithout: opts.withOnly || opts.reportOnly,
|
|
12
|
+
skipWith: opts.withoutOnly || opts.reportOnly,
|
|
13
|
+
outputDir: opts.output,
|
|
14
|
+
});
|
|
15
|
+
const report = generateReport(results);
|
|
16
|
+
console.log("\n" + report);
|
|
17
|
+
const outDir = join(root, ".briefed", "bench");
|
|
18
|
+
if (existsSync(outDir)) {
|
|
19
|
+
writeFileSync(join(outDir, "report.txt"), report);
|
|
20
|
+
console.log(`\n Report saved to ${join(outDir, "report.txt")}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=bench.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bench.js","sourceRoot":"","sources":["../../src/commands/bench.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAa,UAAU,EAAE,MAAM,IAAI,CAAC;AAC1D,OAAO,EAAE,YAA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