@afaik-lab/weigh 0.0.0 → 0.6.1
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/.env.example +49 -0
- package/LICENSE +373 -0
- package/README.md +103 -1
- package/dist/agent.d.ts +83 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +204 -0
- package/dist/agent.js.map +1 -0
- package/dist/ceilings.d.ts +32 -0
- package/dist/ceilings.d.ts.map +1 -0
- package/dist/ceilings.js +61 -0
- package/dist/ceilings.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +530 -0
- package/dist/cli.js.map +1 -0
- package/dist/config-cli.d.ts +15 -0
- package/dist/config-cli.d.ts.map +1 -0
- package/dist/config-cli.js +141 -0
- package/dist/config-cli.js.map +1 -0
- package/dist/config.d.ts +198 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +373 -0
- package/dist/config.js.map +1 -0
- package/dist/context-cli.d.ts +35 -0
- package/dist/context-cli.d.ts.map +1 -0
- package/dist/context-cli.js +251 -0
- package/dist/context-cli.js.map +1 -0
- package/dist/context.d.ts +118 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +159 -0
- package/dist/context.js.map +1 -0
- package/dist/corrections/correction-set.d.ts +67 -0
- package/dist/corrections/correction-set.d.ts.map +1 -0
- package/dist/corrections/correction-set.js +104 -0
- package/dist/corrections/correction-set.js.map +1 -0
- package/dist/corrections/correction.d.ts +74 -0
- package/dist/corrections/correction.d.ts.map +1 -0
- package/dist/corrections/correction.js +154 -0
- package/dist/corrections/correction.js.map +1 -0
- package/dist/corrections/follow-up.d.ts +69 -0
- package/dist/corrections/follow-up.d.ts.map +1 -0
- package/dist/corrections/follow-up.js +217 -0
- package/dist/corrections/follow-up.js.map +1 -0
- package/dist/corrections/index.d.ts +31 -0
- package/dist/corrections/index.d.ts.map +1 -0
- package/dist/corrections/index.js +31 -0
- package/dist/corrections/index.js.map +1 -0
- package/dist/corrections/ledger.d.ts +78 -0
- package/dist/corrections/ledger.d.ts.map +1 -0
- package/dist/corrections/ledger.js +117 -0
- package/dist/corrections/ledger.js.map +1 -0
- package/dist/corrections/promotion.d.ts +119 -0
- package/dist/corrections/promotion.d.ts.map +1 -0
- package/dist/corrections/promotion.js +221 -0
- package/dist/corrections/promotion.js.map +1 -0
- package/dist/corrections/schema.d.ts +125 -0
- package/dist/corrections/schema.d.ts.map +1 -0
- package/dist/corrections/schema.js +100 -0
- package/dist/corrections/schema.js.map +1 -0
- package/dist/corrections-cli.d.ts +28 -0
- package/dist/corrections-cli.d.ts.map +1 -0
- package/dist/corrections-cli.js +157 -0
- package/dist/corrections-cli.js.map +1 -0
- package/dist/diff.d.ts +105 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +202 -0
- package/dist/diff.js.map +1 -0
- package/dist/doctor.d.ts +38 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +197 -0
- package/dist/doctor.js.map +1 -0
- package/dist/events.d.ts +21 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +5 -0
- package/dist/events.js.map +1 -0
- package/dist/findings.d.ts +510 -0
- package/dist/findings.d.ts.map +1 -0
- package/dist/findings.js +645 -0
- package/dist/findings.js.map +1 -0
- package/dist/follow-up-cli.d.ts +88 -0
- package/dist/follow-up-cli.d.ts.map +1 -0
- package/dist/follow-up-cli.js +208 -0
- package/dist/follow-up-cli.js.map +1 -0
- package/dist/harness.d.ts +64 -0
- package/dist/harness.d.ts.map +1 -0
- package/dist/harness.js +71 -0
- package/dist/harness.js.map +1 -0
- package/dist/help/command-help.d.ts +9 -0
- package/dist/help/command-help.d.ts.map +1 -0
- package/dist/help/command-help.js +21 -0
- package/dist/help/command-help.js.map +1 -0
- package/dist/help/commands/answer.d.ts +3 -0
- package/dist/help/commands/answer.d.ts.map +1 -0
- package/dist/help/commands/answer.js +39 -0
- package/dist/help/commands/answer.js.map +1 -0
- package/dist/help/commands/config.d.ts +3 -0
- package/dist/help/commands/config.d.ts.map +1 -0
- package/dist/help/commands/config.js +25 -0
- package/dist/help/commands/config.js.map +1 -0
- package/dist/help/commands/context.d.ts +3 -0
- package/dist/help/commands/context.d.ts.map +1 -0
- package/dist/help/commands/context.js +44 -0
- package/dist/help/commands/context.js.map +1 -0
- package/dist/help/commands/corrections.d.ts +3 -0
- package/dist/help/commands/corrections.d.ts.map +1 -0
- package/dist/help/commands/corrections.js +30 -0
- package/dist/help/commands/corrections.js.map +1 -0
- package/dist/help/commands/doctor.d.ts +3 -0
- package/dist/help/commands/doctor.d.ts.map +1 -0
- package/dist/help/commands/doctor.js +12 -0
- package/dist/help/commands/doctor.js.map +1 -0
- package/dist/help/commands/index.d.ts +4 -0
- package/dist/help/commands/index.d.ts.map +1 -0
- package/dist/help/commands/index.js +27 -0
- package/dist/help/commands/index.js.map +1 -0
- package/dist/help/commands/memory.d.ts +3 -0
- package/dist/help/commands/memory.d.ts.map +1 -0
- package/dist/help/commands/memory.js +33 -0
- package/dist/help/commands/memory.js.map +1 -0
- package/dist/help/commands/models.d.ts +3 -0
- package/dist/help/commands/models.d.ts.map +1 -0
- package/dist/help/commands/models.js +17 -0
- package/dist/help/commands/models.js.map +1 -0
- package/dist/help/commands/options.d.ts +4 -0
- package/dist/help/commands/options.d.ts.map +1 -0
- package/dist/help/commands/options.js +13 -0
- package/dist/help/commands/options.js.map +1 -0
- package/dist/help/commands/review.d.ts +3 -0
- package/dist/help/commands/review.d.ts.map +1 -0
- package/dist/help/commands/review.js +50 -0
- package/dist/help/commands/review.js.map +1 -0
- package/dist/help/commands/sessions.d.ts +3 -0
- package/dist/help/commands/sessions.d.ts.map +1 -0
- package/dist/help/commands/sessions.js +23 -0
- package/dist/help/commands/sessions.js.map +1 -0
- package/dist/help/commands/show.d.ts +3 -0
- package/dist/help/commands/show.d.ts.map +1 -0
- package/dist/help/commands/show.js +18 -0
- package/dist/help/commands/show.js.map +1 -0
- package/dist/help/help.d.ts +16 -0
- package/dist/help/help.d.ts.map +1 -0
- package/dist/help/help.js +68 -0
- package/dist/help/help.js.map +1 -0
- package/dist/help/index.d.ts +4 -0
- package/dist/help/index.d.ts.map +1 -0
- package/dist/help/index.js +7 -0
- package/dist/help/index.js.map +1 -0
- package/dist/index.d.ts +80 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge/block.d.ts +65 -0
- package/dist/knowledge/block.d.ts.map +1 -0
- package/dist/knowledge/block.js +89 -0
- package/dist/knowledge/block.js.map +1 -0
- package/dist/knowledge/claim.d.ts +143 -0
- package/dist/knowledge/claim.d.ts.map +1 -0
- package/dist/knowledge/claim.js +303 -0
- package/dist/knowledge/claim.js.map +1 -0
- package/dist/knowledge/index.d.ts +32 -0
- package/dist/knowledge/index.d.ts.map +1 -0
- package/dist/knowledge/index.js +29 -0
- package/dist/knowledge/index.js.map +1 -0
- package/dist/knowledge/novelty.d.ts +65 -0
- package/dist/knowledge/novelty.d.ts.map +1 -0
- package/dist/knowledge/novelty.js +100 -0
- package/dist/knowledge/novelty.js.map +1 -0
- package/dist/knowledge/recall.d.ts +134 -0
- package/dist/knowledge/recall.d.ts.map +1 -0
- package/dist/knowledge/recall.js +229 -0
- package/dist/knowledge/recall.js.map +1 -0
- package/dist/knowledge/recalled-claim.d.ts +35 -0
- package/dist/knowledge/recalled-claim.d.ts.map +1 -0
- package/dist/knowledge/recalled-claim.js +67 -0
- package/dist/knowledge/recalled-claim.js.map +1 -0
- package/dist/knowledge/recalled.d.ts +70 -0
- package/dist/knowledge/recalled.d.ts.map +1 -0
- package/dist/knowledge/recalled.js +149 -0
- package/dist/knowledge/recalled.js.map +1 -0
- package/dist/knowledge/schema.d.ts +83 -0
- package/dist/knowledge/schema.d.ts.map +1 -0
- package/dist/knowledge/schema.js +96 -0
- package/dist/knowledge/schema.js.map +1 -0
- package/dist/knowledge/staleness.d.ts +48 -0
- package/dist/knowledge/staleness.d.ts.map +1 -0
- package/dist/knowledge/staleness.js +85 -0
- package/dist/knowledge/staleness.js.map +1 -0
- package/dist/knowledge/store.d.ts +100 -0
- package/dist/knowledge/store.d.ts.map +1 -0
- package/dist/knowledge/store.js +184 -0
- package/dist/knowledge/store.js.map +1 -0
- package/dist/memory/compose-file.d.ts +14 -0
- package/dist/memory/compose-file.d.ts.map +1 -0
- package/dist/memory/compose-file.js +25 -0
- package/dist/memory/compose-file.js.map +1 -0
- package/dist/memory/index.d.ts +43 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +119 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/oss.d.ts +62 -0
- package/dist/memory/oss.d.ts.map +1 -0
- package/dist/memory/oss.js +230 -0
- package/dist/memory/oss.js.map +1 -0
- package/dist/memory/platform.d.ts +37 -0
- package/dist/memory/platform.d.ts.map +1 -0
- package/dist/memory/platform.js +131 -0
- package/dist/memory/platform.js.map +1 -0
- package/dist/memory/scope.d.ts +49 -0
- package/dist/memory/scope.d.ts.map +1 -0
- package/dist/memory/scope.js +70 -0
- package/dist/memory/scope.js.map +1 -0
- package/dist/memory/types.d.ts +113 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +18 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/memory-cli.d.ts +17 -0
- package/dist/memory-cli.d.ts.map +1 -0
- package/dist/memory-cli.js +107 -0
- package/dist/memory-cli.js.map +1 -0
- package/dist/models-cli.d.ts +12 -0
- package/dist/models-cli.d.ts.map +1 -0
- package/dist/models-cli.js +54 -0
- package/dist/models-cli.js.map +1 -0
- package/dist/models.d.ts +111 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +228 -0
- package/dist/models.js.map +1 -0
- package/dist/paths.d.ts +35 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +65 -0
- package/dist/paths.js.map +1 -0
- package/dist/profile.d.ts +28 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +154 -0
- package/dist/profile.js.map +1 -0
- package/dist/progress.d.ts +70 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +132 -0
- package/dist/progress.js.map +1 -0
- package/dist/quiet.d.ts +2 -0
- package/dist/quiet.d.ts.map +1 -0
- package/dist/quiet.js +21 -0
- package/dist/quiet.js.map +1 -0
- package/dist/reconcile/continuation.d.ts +132 -0
- package/dist/reconcile/continuation.d.ts.map +1 -0
- package/dist/reconcile/continuation.js +306 -0
- package/dist/reconcile/continuation.js.map +1 -0
- package/dist/reconcile/index.d.ts +26 -0
- package/dist/reconcile/index.d.ts.map +1 -0
- package/dist/reconcile/index.js +28 -0
- package/dist/reconcile/index.js.map +1 -0
- package/dist/reconcile/outcome-set.d.ts +53 -0
- package/dist/reconcile/outcome-set.d.ts.map +1 -0
- package/dist/reconcile/outcome-set.js +124 -0
- package/dist/reconcile/outcome-set.js.map +1 -0
- package/dist/reconcile/outcome.d.ts +56 -0
- package/dist/reconcile/outcome.d.ts.map +1 -0
- package/dist/reconcile/outcome.js +60 -0
- package/dist/reconcile/outcome.js.map +1 -0
- package/dist/reconcile/reconciliation.d.ts +49 -0
- package/dist/reconcile/reconciliation.d.ts.map +1 -0
- package/dist/reconcile/reconciliation.js +88 -0
- package/dist/reconcile/reconciliation.js.map +1 -0
- package/dist/reconcile/schema.d.ts +157 -0
- package/dist/reconcile/schema.d.ts.map +1 -0
- package/dist/reconcile/schema.js +97 -0
- package/dist/reconcile/schema.js.map +1 -0
- package/dist/record/index.d.ts +23 -0
- package/dist/record/index.d.ts.map +1 -0
- package/dist/record/index.js +25 -0
- package/dist/record/index.js.map +1 -0
- package/dist/record/review-record.d.ts +28 -0
- package/dist/record/review-record.d.ts.map +1 -0
- package/dist/record/review-record.js +78 -0
- package/dist/record/review-record.js.map +1 -0
- package/dist/record/schema.d.ts +153 -0
- package/dist/record/schema.d.ts.map +1 -0
- package/dist/record/schema.js +87 -0
- package/dist/record/schema.js.map +1 -0
- package/dist/record/store.d.ts +83 -0
- package/dist/record/store.d.ts.map +1 -0
- package/dist/record/store.js +162 -0
- package/dist/record/store.js.map +1 -0
- package/dist/record/stored-review.d.ts +36 -0
- package/dist/record/stored-review.d.ts.map +1 -0
- package/dist/record/stored-review.js +90 -0
- package/dist/record/stored-review.js.map +1 -0
- package/dist/refute.d.ts +318 -0
- package/dist/refute.d.ts.map +1 -0
- package/dist/refute.js +513 -0
- package/dist/refute.js.map +1 -0
- package/dist/render.d.ts +212 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +544 -0
- package/dist/render.js.map +1 -0
- package/dist/review-cli.d.ts +181 -0
- package/dist/review-cli.d.ts.map +1 -0
- package/dist/review-cli.js +598 -0
- package/dist/review-cli.js.map +1 -0
- package/dist/reviewer.d.ts +297 -0
- package/dist/reviewer.d.ts.map +1 -0
- package/dist/reviewer.js +584 -0
- package/dist/reviewer.js.map +1 -0
- package/dist/session-cli.d.ts +17 -0
- package/dist/session-cli.d.ts.map +1 -0
- package/dist/session-cli.js +62 -0
- package/dist/session-cli.js.map +1 -0
- package/dist/session.d.ts +36 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +105 -0
- package/dist/session.js.map +1 -0
- package/dist/settings.d.ts +68 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +175 -0
- package/dist/settings.js.map +1 -0
- package/dist/show-cli.d.ts +39 -0
- package/dist/show-cli.d.ts.map +1 -0
- package/dist/show-cli.js +56 -0
- package/dist/show-cli.js.map +1 -0
- package/dist/stdout.d.ts +28 -0
- package/dist/stdout.d.ts.map +1 -0
- package/dist/stdout.js +44 -0
- package/dist/stdout.js.map +1 -0
- package/dist/target.d.ts +58 -0
- package/dist/target.d.ts.map +1 -0
- package/dist/target.js +96 -0
- package/dist/target.js.map +1 -0
- package/dist/tools/index.d.ts +93 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +146 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/root.d.ts +62 -0
- package/dist/tools/root.d.ts.map +1 -0
- package/dist/tools/root.js +51 -0
- package/dist/tools/root.js.map +1 -0
- package/dist/usage.d.ts +75 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +100 -0
- package/dist/usage.js.map +1 -0
- package/dist/version.d.ts +14 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +26 -0
- package/dist/version.js.map +1 -0
- package/dist/workspace.d.ts +48 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +126 -0
- package/dist/workspace.js.map +1 -0
- package/docker-compose.yml +61 -0
- package/package.json +72 -1
package/dist/config.js
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
4
|
+
import { existsSync, readFileSync } from 'fs';
|
|
5
|
+
import { userInfo } from 'os';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
import { paths } from './paths.js';
|
|
8
|
+
import { resolveModel } from './models.js';
|
|
9
|
+
import { SETTINGS, SETTINGS_BY_KEY, coerce, isOwnedEnvKey } from './settings.js';
|
|
10
|
+
/**
|
|
11
|
+
* Per-provider embedder defaults. Model and dimensions travel together — Qdrant
|
|
12
|
+
* fixes the vector size when it creates a collection, so a mismatch is not a
|
|
13
|
+
* tuning error, it is a hard failure on first write.
|
|
14
|
+
*/
|
|
15
|
+
const EMBEDDER_DEFAULTS = {
|
|
16
|
+
ollama: { model: 'nomic-embed-text', dims: 768 },
|
|
17
|
+
openai: { model: 'text-embedding-3-small', dims: 1536 },
|
|
18
|
+
};
|
|
19
|
+
// ── Credentials ─────────────────────────────────────────────────────
|
|
20
|
+
/** Minimal KEY=VALUE parser: no interpolation, no exports, no surprises. */
|
|
21
|
+
export function parseEnvFile(text) {
|
|
22
|
+
const out = {};
|
|
23
|
+
for (const raw of text.split('\n')) {
|
|
24
|
+
const line = raw.trim();
|
|
25
|
+
if (!line || line.startsWith('#'))
|
|
26
|
+
continue;
|
|
27
|
+
const eq = line.indexOf('=');
|
|
28
|
+
if (eq < 1)
|
|
29
|
+
continue;
|
|
30
|
+
const key = line.slice(0, eq).trim();
|
|
31
|
+
let value = line.slice(eq + 1).trim();
|
|
32
|
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
|
33
|
+
value = value.slice(1, -1);
|
|
34
|
+
}
|
|
35
|
+
out[key] = value;
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Loads `~/.weigh/.env` into the environment, filling gaps only.
|
|
41
|
+
*
|
|
42
|
+
* This is not a separate precedence layer — it is how you persist environment
|
|
43
|
+
* variables locally, so CI, which sets them for real, needs no such file. A
|
|
44
|
+
* value already in the environment therefore wins.
|
|
45
|
+
*
|
|
46
|
+
* It writes into `process.env` rather than staying private so that anything
|
|
47
|
+
* Weigh spawns (`git`, `gh`) inherits the same credentials, and it only sets
|
|
48
|
+
* variables Weigh owns: this file configures Weigh, not the whole process.
|
|
49
|
+
*/
|
|
50
|
+
export function loadWeighEnv() {
|
|
51
|
+
const file = paths.envFile();
|
|
52
|
+
if (!existsSync(file))
|
|
53
|
+
return { loaded: [], from: null };
|
|
54
|
+
const loaded = [];
|
|
55
|
+
for (const [key, value] of Object.entries(parseEnvFile(readFileSync(file, 'utf-8')))) {
|
|
56
|
+
if (!isOwnedEnvKey(key))
|
|
57
|
+
continue;
|
|
58
|
+
if (process.env[key] !== undefined && process.env[key] !== '')
|
|
59
|
+
continue;
|
|
60
|
+
process.env[key] = value;
|
|
61
|
+
loaded.push(key);
|
|
62
|
+
}
|
|
63
|
+
return { loaded, from: file };
|
|
64
|
+
}
|
|
65
|
+
// ── Defaults ────────────────────────────────────────────────────────
|
|
66
|
+
function defaultUserId() {
|
|
67
|
+
try {
|
|
68
|
+
return process.env.USER || userInfo().username || 'default';
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return 'default';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const DEFAULTS = {
|
|
75
|
+
apiKey: '',
|
|
76
|
+
model: 'claude-sonnet-5',
|
|
77
|
+
name: 'weigh',
|
|
78
|
+
// The chat path's instructions. `weigh review` has its own, in Reviewer —
|
|
79
|
+
// this one only has to describe a read-only agent honestly, since a prompt
|
|
80
|
+
// promising file edits to an agent that cannot edit produces confident
|
|
81
|
+
// claims about work it never did.
|
|
82
|
+
systemPrompt: [
|
|
83
|
+
'You are a code reviewer with read-only access to a repository.',
|
|
84
|
+
'',
|
|
85
|
+
'Repository under review: {repoRoot}',
|
|
86
|
+
'',
|
|
87
|
+
'You can read files and search them by glob and by regex. You cannot modify',
|
|
88
|
+
'anything and you cannot run commands — propose changes as suggested patches',
|
|
89
|
+
'rather than describing them as done.',
|
|
90
|
+
'',
|
|
91
|
+
'Guidelines:',
|
|
92
|
+
'- Investigate before judging: read the definition, the callers, and the tests.',
|
|
93
|
+
'- Cite file and line for every claim you make.',
|
|
94
|
+
'- Prefer grep and glob over guessing at file locations.',
|
|
95
|
+
'- Say plainly when the evidence is insufficient rather than inferring.',
|
|
96
|
+
].join('\n'),
|
|
97
|
+
// A review is not a chat turn, and a ceiling of 20 cut real reviews off
|
|
98
|
+
// mid-read to report on whatever they had. Both of these are backstops
|
|
99
|
+
// rather than budgets: they exist to stop a run that has lost its way, and
|
|
100
|
+
// a review that reaches either one has already failed.
|
|
101
|
+
maxSteps: 60,
|
|
102
|
+
// $1 stopped a fresh 56-file review on Sonnet before it finished, and on
|
|
103
|
+
// Opus a 50-file review runs $5 to $11. Five fits the default model with
|
|
104
|
+
// room to spare and is still low enough to stop a run that is looping.
|
|
105
|
+
maxCost: 5.0,
|
|
106
|
+
// Review is the case effort was made for: the work is judging whether code
|
|
107
|
+
// is correct, which is reasoning rather than retrieval, and the failure it
|
|
108
|
+
// guards against — a confident finding about code half-understood — is the
|
|
109
|
+
// expensive one. `high` is the model default; this says so out loud so that
|
|
110
|
+
// lowering it is a decision rather than a drift.
|
|
111
|
+
effort: 'high',
|
|
112
|
+
// Enough to catch the failure this exists for — measured runs reporting after
|
|
113
|
+
// four reads of a fifty-five file diff — without demanding a full read of
|
|
114
|
+
// every branch. Deleted, binary and generated files are excluded from the
|
|
115
|
+
// denominator, so this is a share of what could actually inform the review.
|
|
116
|
+
coverageFloor: 0.6,
|
|
117
|
+
// Off. Every other default here is a judgement Weigh is entitled to make;
|
|
118
|
+
// this one is not. A confidence floor says which of the model's own doubts
|
|
119
|
+
// are worth acting on, and that threshold has to be set against findings
|
|
120
|
+
// from the repository it will run on — a number picked here would be a
|
|
121
|
+
// guess applied to everyone.
|
|
122
|
+
confidenceFloor: 0,
|
|
123
|
+
// On. A review of a branch nobody has reviewed before is unaffected, and one
|
|
124
|
+
// that has is worth less without it: the reader wants to know what became of
|
|
125
|
+
// the findings they already read.
|
|
126
|
+
continuation: true,
|
|
127
|
+
// Off, for the reason the flag is: it roughly doubles what a review costs,
|
|
128
|
+
// and a review is useful without it.
|
|
129
|
+
refute: false,
|
|
130
|
+
// Resolved lazily below — the default must follow WEIGH_HOME, and a literal
|
|
131
|
+
// here would write transcripts into whatever repo you happened to run in.
|
|
132
|
+
sessionDir: '',
|
|
133
|
+
sessionEnabled: true,
|
|
134
|
+
// Unlimited by default — transcripts are small, and silently deleting the
|
|
135
|
+
// only local record of a run should be something you opt into.
|
|
136
|
+
sessionRetention: 0,
|
|
137
|
+
outputMode: 'text',
|
|
138
|
+
// Provisional, every one of them, and said out loud rather than presented as
|
|
139
|
+
// judgement: these are the numbers the 3.4 design refused to pick from a
|
|
140
|
+
// document. They are a starting point for `weigh context recall` to be read
|
|
141
|
+
// against, not a calibration. What is known so far: an unrelated glossary
|
|
142
|
+
// claim came back at 0.406 against a hunk it had nothing to do with, which is
|
|
143
|
+
// the one measurement the threshold below rests on.
|
|
144
|
+
knowledge: {
|
|
145
|
+
enabled: true,
|
|
146
|
+
threshold: 0.45,
|
|
147
|
+
perFile: 3,
|
|
148
|
+
files: 12,
|
|
149
|
+
repoCap: 10,
|
|
150
|
+
userCap: 5,
|
|
151
|
+
scan: 200,
|
|
152
|
+
// ~2k tokens. The diff's budget is a hundred times this, and rightly: the
|
|
153
|
+
// change is what is being reviewed, and these are the notes in the margin.
|
|
154
|
+
budget: 8_000,
|
|
155
|
+
// Measured on this repository's 30 claims, vector similarity of a
|
|
156
|
+
// statement against the held claim: reworded duplicates 0.79 – 0.89,
|
|
157
|
+
// related but different claims 0.71 – 0.74, unrelated 0.68 and below. Set
|
|
158
|
+
// nearer the related end, because a claim held back costs one question and
|
|
159
|
+
// a duplicate written costs every review that recalls it.
|
|
160
|
+
similar: 0.75,
|
|
161
|
+
},
|
|
162
|
+
memory: {
|
|
163
|
+
enabled: true,
|
|
164
|
+
// Auto-detected below: the hosted platform when a Mem0 key is present,
|
|
165
|
+
// otherwise the self-hosted store.
|
|
166
|
+
backend: 'platform',
|
|
167
|
+
userId: '',
|
|
168
|
+
agentId: 'weigh',
|
|
169
|
+
topK: 8,
|
|
170
|
+
// Off. What this captured was an LLM's extraction of a whole conversation,
|
|
171
|
+
// stored untyped and unverifiable — nothing downstream can read it, and a
|
|
172
|
+
// review cannot check a claim with no evidence attached. Knowledge about a
|
|
173
|
+
// repository is written deliberately now, through `weigh context`, which
|
|
174
|
+
// validates a shape and demands a citation. The setting stays for anyone
|
|
175
|
+
// who wants the prompt path to keep a loose memory of its own.
|
|
176
|
+
autoCapture: false,
|
|
177
|
+
platform: { apiKey: '' },
|
|
178
|
+
oss: {
|
|
179
|
+
collectionName: 'weigh',
|
|
180
|
+
qdrantUrl: 'http://localhost:6333',
|
|
181
|
+
// The one thing still reached through OpenRouter, and only because Mem0's
|
|
182
|
+
// extractor wants a chat model of its own. Unset now leaves the oss
|
|
183
|
+
// backend without an extractor, rather than borrowing the agent's key —
|
|
184
|
+
// the agent no longer has one to lend.
|
|
185
|
+
openRouterApiKey: '',
|
|
186
|
+
extractionModel: 'openai/gpt-4o-mini',
|
|
187
|
+
// Local by default: `docker compose up -d` provides this, and the
|
|
188
|
+
// alternative would mean a second vendor key for embeddings alone.
|
|
189
|
+
embeddingProvider: 'ollama',
|
|
190
|
+
embeddingModel: '',
|
|
191
|
+
embeddingDims: 0,
|
|
192
|
+
ollamaUrl: 'http://localhost:11434',
|
|
193
|
+
openAiApiKey: '',
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
github: { token: '' },
|
|
197
|
+
linear: { apiKey: '' },
|
|
198
|
+
};
|
|
199
|
+
/** The shared file's name, at the repository root. */
|
|
200
|
+
export const REPO_CONFIG_FILE = '.weigh.json';
|
|
201
|
+
function flatten(obj, prefix = '', out = {}) {
|
|
202
|
+
for (const [k, v] of Object.entries(obj ?? {})) {
|
|
203
|
+
const key = prefix ? `${prefix}.${k}` : k;
|
|
204
|
+
if (v && typeof v === 'object' && !Array.isArray(v))
|
|
205
|
+
flatten(v, key, out);
|
|
206
|
+
else if (v !== undefined)
|
|
207
|
+
out[key] = v;
|
|
208
|
+
}
|
|
209
|
+
return out;
|
|
210
|
+
}
|
|
211
|
+
/** Rebuilds the nested config object from resolved dotted keys. */
|
|
212
|
+
function toNested(values) {
|
|
213
|
+
const out = {};
|
|
214
|
+
for (const { key, value } of values.values()) {
|
|
215
|
+
if (key.startsWith('$'))
|
|
216
|
+
continue; // bootstrap-only, not part of AgentConfig
|
|
217
|
+
const parts = key.split('.');
|
|
218
|
+
let node = out;
|
|
219
|
+
for (const part of parts.slice(0, -1))
|
|
220
|
+
node = node[part] ??= {};
|
|
221
|
+
node[parts.at(-1)] = value;
|
|
222
|
+
}
|
|
223
|
+
return out;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* What a repository's shared file may set: the settings marked `shared`. The
|
|
227
|
+
* rest is dropped with a warning, as an unknown key is, rather than refusing
|
|
228
|
+
* the file — one stray key should not stop every developer's run.
|
|
229
|
+
*/
|
|
230
|
+
function shareable(data, origin, warnings) {
|
|
231
|
+
const kept = {};
|
|
232
|
+
for (const [key, value] of Object.entries(data)) {
|
|
233
|
+
const setting = SETTINGS_BY_KEY.get(key);
|
|
234
|
+
if (setting?.secret) {
|
|
235
|
+
warnings.push(`${origin}: "${key}" is a secret, and a shared file is no place for one — ignored`);
|
|
236
|
+
}
|
|
237
|
+
else if (setting?.local) {
|
|
238
|
+
warnings.push(`${origin}: "${key}" belongs to one machine or person, so a shared file cannot set it — ignored`);
|
|
239
|
+
}
|
|
240
|
+
else if (setting && !setting.shared) {
|
|
241
|
+
warnings.push(`${origin}: "${key}" is not one a repository may set — ignored`);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
kept[key] = value;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return kept;
|
|
248
|
+
}
|
|
249
|
+
export function loadConfigDetailed(overrides = {}, opts) {
|
|
250
|
+
loadWeighEnv();
|
|
251
|
+
const values = new Map();
|
|
252
|
+
const warnings = [];
|
|
253
|
+
const advisory = new Set();
|
|
254
|
+
const set = (key, value, source) => values.set(key, { key, value, source });
|
|
255
|
+
for (const [key, value] of Object.entries(flatten(DEFAULTS)))
|
|
256
|
+
set(key, value, 'default');
|
|
257
|
+
const apply = (data, source, origin) => {
|
|
258
|
+
for (const [key, raw] of Object.entries(data)) {
|
|
259
|
+
const setting = SETTINGS_BY_KEY.get(key);
|
|
260
|
+
if (!setting) {
|
|
261
|
+
warnings.push(`${origin}: unknown setting "${key}" — ignored`);
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
// A JSON layer hands over real numbers and booleans. They go through
|
|
265
|
+
// `coerce` as text too, so `maxSteps: 0` in `.weigh.json` is refused
|
|
266
|
+
// just as `WEIGH_MAX_STEPS=0` is, whichever layer it arrives through.
|
|
267
|
+
const checked = typeof raw === 'number' || typeof raw === 'boolean' ? String(raw) : raw;
|
|
268
|
+
try {
|
|
269
|
+
set(key, typeof checked === 'string' ? coerce(setting, checked, key) : checked, source);
|
|
270
|
+
}
|
|
271
|
+
catch (err) {
|
|
272
|
+
if (source === 'repo') {
|
|
273
|
+
const warning = `${origin}: ${err.message} — ignored`;
|
|
274
|
+
warnings.push(warning);
|
|
275
|
+
advisory.add(warning);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
warnings.push(`${origin}: ${err.message}`);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
if (opts?.repoRoot) {
|
|
284
|
+
const shared = join(opts.repoRoot, REPO_CONFIG_FILE);
|
|
285
|
+
if (existsSync(shared)) {
|
|
286
|
+
try {
|
|
287
|
+
apply(shareable(flatten(JSON.parse(readFileSync(shared, 'utf-8'))), shared, warnings), 'repo', shared);
|
|
288
|
+
}
|
|
289
|
+
catch (err) {
|
|
290
|
+
warnings.push(`${shared}: ${err.message}`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const file = paths.config();
|
|
295
|
+
if (existsSync(file)) {
|
|
296
|
+
try {
|
|
297
|
+
apply(flatten(JSON.parse(readFileSync(file, 'utf-8'))), 'file', file);
|
|
298
|
+
}
|
|
299
|
+
catch (err) {
|
|
300
|
+
warnings.push(`${file}: ${err.message}`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
for (const setting of SETTINGS) {
|
|
304
|
+
if (!setting.env)
|
|
305
|
+
continue;
|
|
306
|
+
const raw = process.env[setting.env];
|
|
307
|
+
if (raw === undefined || raw === '')
|
|
308
|
+
continue;
|
|
309
|
+
try {
|
|
310
|
+
set(setting.key, coerce(setting, raw), 'env');
|
|
311
|
+
}
|
|
312
|
+
catch (err) {
|
|
313
|
+
warnings.push(err.message);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
// Overrides are validated like every other layer. The schema is asserted
|
|
317
|
+
// complete against the defaults, so anything unrecognised here is a typo
|
|
318
|
+
// rather than a legitimate field.
|
|
319
|
+
apply(flatten(overrides), 'flag', 'override');
|
|
320
|
+
const config = toNested(values);
|
|
321
|
+
// Derived defaults: each depends on a layer having already been applied, so
|
|
322
|
+
// none of them can live in the DEFAULTS table above.
|
|
323
|
+
if (!config.sessionDir)
|
|
324
|
+
config.sessionDir = paths.sessions();
|
|
325
|
+
if (!config.memory.userId)
|
|
326
|
+
config.memory.userId = defaultUserId();
|
|
327
|
+
// No Mem0 key anywhere, and nothing pinned a backend: the self-hosted store
|
|
328
|
+
// is the only one that can work.
|
|
329
|
+
const backendPinned = values.get('memory.backend')?.source !== 'default';
|
|
330
|
+
if (!backendPinned && !config.memory.platform.apiKey)
|
|
331
|
+
config.memory.backend = 'oss';
|
|
332
|
+
// Short names reach a model here rather than at the call site, so `-m opus`,
|
|
333
|
+
// WEIGH_MODEL and config.json all behave the same way — and a typo is
|
|
334
|
+
// refused before a subprocess starts.
|
|
335
|
+
try {
|
|
336
|
+
config.model = resolveModel(config.model);
|
|
337
|
+
}
|
|
338
|
+
catch (err) {
|
|
339
|
+
warnings.push(err.message);
|
|
340
|
+
}
|
|
341
|
+
const embedder = EMBEDDER_DEFAULTS[config.memory.oss.embeddingProvider];
|
|
342
|
+
if (!config.memory.oss.embeddingModel)
|
|
343
|
+
config.memory.oss.embeddingModel = embedder.model;
|
|
344
|
+
if (!config.memory.oss.embeddingDims)
|
|
345
|
+
config.memory.oss.embeddingDims = embedder.dims;
|
|
346
|
+
// No throw for a missing key. The Agent SDK authenticates through the
|
|
347
|
+
// Claude Code binary, which falls back to a subscription login the shell
|
|
348
|
+
// knows nothing about — so a key is one way to be authenticated, not the
|
|
349
|
+
// way, and refusing to start without one would reject a working machine.
|
|
350
|
+
// `skipApiKey` survives as a no-op parameter for callers that passed it.
|
|
351
|
+
void opts;
|
|
352
|
+
// Exported, because the SDK reads the environment and nothing hands it
|
|
353
|
+
// `config.apiKey`. `~/.weigh/.env` reaches it by the same route, through
|
|
354
|
+
// loadWeighEnv above; the config file had no such side effect, so
|
|
355
|
+
// `weigh config set apiKey …` wrote a value that was inert while doctor
|
|
356
|
+
// reported the machine as authenticated. Assigned only when nothing is
|
|
357
|
+
// already exported, so the env layer still wins — the same precedence the
|
|
358
|
+
// layering table states everywhere else.
|
|
359
|
+
if (config.apiKey && !process.env.ANTHROPIC_API_KEY) {
|
|
360
|
+
process.env.ANTHROPIC_API_KEY = config.apiKey;
|
|
361
|
+
}
|
|
362
|
+
const provenance = new Map([...values.values()].map((r) => [r.key, r.source]));
|
|
363
|
+
return { config, warnings, provenance, advisory };
|
|
364
|
+
}
|
|
365
|
+
/** Throws on the first validation problem, so callers need not inspect warnings. */
|
|
366
|
+
export function loadConfig(overrides = {}, opts) {
|
|
367
|
+
const { config, warnings, advisory } = loadConfigDetailed(overrides, opts);
|
|
368
|
+
const fatal = warnings.find((w) => !advisory.has(w) && (w.includes('must be') || w.startsWith('Unknown model:')));
|
|
369
|
+
if (fatal)
|
|
370
|
+
throw new Error(fatal);
|
|
371
|
+
return config;
|
|
372
|
+
}
|
|
373
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAE5D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAOjF;;;;GAIG;AACH,MAAM,iBAAiB,GAA8D;IACnF,MAAM,EAAE,EAAE,KAA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['add', 'list', 'search', 'recall', 'remove', 'confirm', 'clear'];
|
|
3
|
+
export type ContextVerb = (typeof CONTEXT_VERBS)[number];
|
|
4
|
+
export declare function isContextVerb(value: string | undefined): value is ContextVerb;
|
|
5
|
+
export interface ContextCommandOptions {
|
|
6
|
+
json: boolean;
|
|
7
|
+
/** Which repository the claims are about. Default: the working directory. */
|
|
8
|
+
repo?: string;
|
|
9
|
+
limit?: number;
|
|
10
|
+
/** For `recall`: the ref to compare against, as `weigh review` takes it. */
|
|
11
|
+
base?: string;
|
|
12
|
+
/** For `recall`: recall against the working tree rather than against HEAD. */
|
|
13
|
+
uncommitted?: boolean;
|
|
14
|
+
yes: boolean;
|
|
15
|
+
/** For `list`: only claims whose cited files changed since they last held. */
|
|
16
|
+
stale?: boolean;
|
|
17
|
+
/** For `list`: only claims about this path, relative to the repository root. */
|
|
18
|
+
path?: string;
|
|
19
|
+
/** JSON for `add`, read from stdin by the caller. */
|
|
20
|
+
input?: string;
|
|
21
|
+
/** For `add`: write only the claims the repository does not hold yet. */
|
|
22
|
+
ifNew?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* `weigh context <verb>` — what Weigh knows about a repository.
|
|
26
|
+
*
|
|
27
|
+
* The seam between two agents. A priming skill explores an unfamiliar
|
|
28
|
+
* repository and writes what it finds through this command rather than into the
|
|
29
|
+
* store directly: one writer, one schema, one place where a malformed claim is
|
|
30
|
+
* refused. It is also how a human corrects or clears what was written, which
|
|
31
|
+
* matters more than it sounds — knowledge you cannot read back is a liability
|
|
32
|
+
* rather than an asset.
|
|
33
|
+
*/
|
|
34
|
+
export declare function runContextCommand(verb: ContextVerb, args: string[], config: AgentConfig, options: ContextCommandOptions): Promise<number>;
|
|
35
|
+
//# sourceMappingURL=context-cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-cli.d.ts","sourceRoot":"","sources":["../src/context-cli.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO/C,eAAO,MAAM,aAAa,YAAI,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAU,CAAC;AACxG,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,IAAI,WAAW,CAE7E;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,OAAO,CAAC;IACd,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,EAAE,OAAO,CAAC;IACb,8EAA8E;IAC9E,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gFAAgF;IAChF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,MAAM,CAAC,CA4OjB"}
|