@jmtrin/opencode-kevin 0.6.0 → 0.8.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/README.md +771 -580
- package/dist/migrations/001_initial.sql +91 -91
- package/dist/migrations/003_v02_signal.sql +57 -57
- package/dist/migrations/004_v03_knowledge.sql +138 -138
- package/dist/migrations/005_v04_signal.sql +57 -57
- package/dist/migrations/006_v05_glassbox.sql +118 -118
- package/dist/migrations/007_v06_pull.sql +144 -144
- package/dist/migrations/008_v07_truth.sql +124 -0
- package/dist/migrations/009_v08_team.sql +100 -0
- package/dist/plugin/ArtifactWriter.d.ts +28 -0
- package/dist/plugin/ArtifactWriter.js +35 -2
- package/dist/plugin/ArtifactWriter.js.map +1 -1
- package/dist/plugin/ConflictDetector.d.ts +35 -0
- package/dist/plugin/ConflictDetector.js +283 -0
- package/dist/plugin/ConflictDetector.js.map +1 -0
- package/dist/plugin/ContextInjector.d.ts +9 -0
- package/dist/plugin/ContextInjector.js +14 -3
- package/dist/plugin/ContextInjector.js.map +1 -1
- package/dist/plugin/ConventionMiner.d.ts +35 -0
- package/dist/plugin/ConventionMiner.js +243 -0
- package/dist/plugin/ConventionMiner.js.map +1 -0
- package/dist/plugin/Curator.d.ts +22 -2
- package/dist/plugin/Curator.js +101 -28
- package/dist/plugin/Curator.js.map +1 -1
- package/dist/plugin/InjectionLedger.d.ts +6 -0
- package/dist/plugin/InjectionLedger.js +6 -0
- package/dist/plugin/InjectionLedger.js.map +1 -1
- package/dist/plugin/Materializer.d.ts +4 -5
- package/dist/plugin/Materializer.js +9 -6
- package/dist/plugin/Materializer.js.map +1 -1
- package/dist/plugin/MemoryService.d.ts +49 -2
- package/dist/plugin/MemoryService.js +306 -8
- package/dist/plugin/MemoryService.js.map +1 -1
- package/dist/plugin/Migrate.js +61 -2
- package/dist/plugin/Migrate.js.map +1 -1
- package/dist/plugin/Reflector.js +13 -0
- package/dist/plugin/Reflector.js.map +1 -1
- package/dist/plugin/RepoIdentity.d.ts +113 -0
- package/dist/plugin/RepoIdentity.js +266 -0
- package/dist/plugin/RepoIdentity.js.map +1 -0
- package/dist/plugin/RepoTruth.d.ts +80 -0
- package/dist/plugin/RepoTruth.js +600 -0
- package/dist/plugin/RepoTruth.js.map +1 -0
- package/dist/plugin/Retrospective.js +17 -0
- package/dist/plugin/Retrospective.js.map +1 -1
- package/dist/plugin/SharedLayer.d.ts +159 -0
- package/dist/plugin/SharedLayer.js +463 -0
- package/dist/plugin/SharedLayer.js.map +1 -0
- package/dist/plugin/index.d.ts +36 -2
- package/dist/plugin/index.js +591 -10
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/kevin_approve.js +7 -4
- package/dist/plugin/kevin_approve.js.map +1 -1
- package/dist/plugin/kevin_audit.d.ts +59 -1
- package/dist/plugin/kevin_audit.js +190 -3
- package/dist/plugin/kevin_audit.js.map +1 -1
- package/dist/plugin/kevin_conflicts.d.ts +9 -0
- package/dist/plugin/kevin_conflicts.js +51 -0
- package/dist/plugin/kevin_conflicts.js.map +1 -0
- package/dist/plugin/kevin_facts.d.ts +42 -0
- package/dist/plugin/kevin_facts.js +37 -0
- package/dist/plugin/kevin_facts.js.map +1 -0
- package/dist/plugin/metrics.d.ts +3 -3
- package/dist/plugin/metrics.js +21 -2
- package/dist/plugin/metrics.js.map +1 -1
- package/dist/plugin/okf-export.d.ts +2 -2
- package/dist/plugin/okf-export.js +15 -7
- package/dist/plugin/okf-export.js.map +1 -1
- package/dist/plugin/okf.d.ts +107 -0
- package/dist/plugin/okf.js +304 -0
- package/dist/plugin/okf.js.map +1 -0
- package/dist/plugin/replay-types.d.ts +29 -287
- package/dist/plugin/replay-types.js +145 -53
- package/dist/plugin/replay-types.js.map +1 -1
- package/migrations/001_initial.sql +91 -91
- package/migrations/003_v02_signal.sql +57 -57
- package/migrations/004_v03_knowledge.sql +138 -138
- package/migrations/005_v04_signal.sql +57 -57
- package/migrations/006_v05_glassbox.sql +118 -118
- package/migrations/007_v06_pull.sql +144 -144
- package/migrations/008_v07_truth.sql +124 -0
- package/migrations/009_v08_team.sql +100 -0
- package/package.json +4 -4
package/dist/plugin/Migrate.js
CHANGED
|
@@ -2,8 +2,8 @@ import { readFileSync, readdirSync } from "node:fs";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
// Built-in post-apply hooks, keyed by migration version. Each hook runs inside
|
|
4
4
|
// the same transaction as the migration's DDL, so a hook failure rolls back the
|
|
5
|
-
// whole migration. Hooks
|
|
6
|
-
//
|
|
5
|
+
// whole migration. Hooks run when their version is applied. Migration 008's
|
|
6
|
+
// reconciliation hook is also safe to run on later no-op starts (K7-002).
|
|
7
7
|
const DEFAULT_POST_APPLY_HOOKS = {
|
|
8
8
|
// v0.2.0 Signal Quality: defensive backfill of memories.origin for legacy
|
|
9
9
|
// rows. The column is NOT NULL DEFAULT 'agent', so SQLite already populates
|
|
@@ -78,6 +78,53 @@ const DEFAULT_POST_APPLY_HOOKS = {
|
|
|
78
78
|
.prepare("UPDATE kevin_metrics SET value = (SELECT COUNT(*) FROM artifact_writes WHERE outcome = 'written') WHERE key = 'artifact_writes_total'")
|
|
79
79
|
.run();
|
|
80
80
|
},
|
|
81
|
+
// v0.7.0 (K7-002 / plan §6, D7-02) — Truth: four re-derivations, all
|
|
82
|
+
// idempotent by re-derivation (same discipline as "006"/"007", D5-13).
|
|
83
|
+
// 1. Normalize any NULL truth_penalty to 0.0 (belt-and-braces; the column
|
|
84
|
+
// is NOT NULL DEFAULT 0.0, so SQLite already back-fills on ALTER TABLE).
|
|
85
|
+
// 2-4. repo_facts_scanned / conflicts_detected / memories_contradicted
|
|
86
|
+
// are re-derived from their tables, NOT trusted from the counters, so
|
|
87
|
+
// the metrics survive a database restored from backup or edited by
|
|
88
|
+
// hand. A missing row makes the UPDATE a harmless no-op.
|
|
89
|
+
"008": (store) => {
|
|
90
|
+
store
|
|
91
|
+
.prepare("UPDATE memories SET truth_penalty = 0.0 WHERE truth_penalty IS NULL")
|
|
92
|
+
.run();
|
|
93
|
+
store
|
|
94
|
+
.prepare("UPDATE kevin_metrics SET value = (SELECT COUNT(*) FROM repo_facts) WHERE key = 'repo_facts_scanned'")
|
|
95
|
+
.run();
|
|
96
|
+
store
|
|
97
|
+
.prepare("UPDATE kevin_metrics SET value = (SELECT COUNT(*) FROM memory_conflicts) WHERE key = 'conflicts_detected'")
|
|
98
|
+
.run();
|
|
99
|
+
store
|
|
100
|
+
.prepare("UPDATE kevin_metrics SET value = (SELECT COUNT(*) FROM memories WHERE truth_penalty > 0.0) WHERE key = 'memories_contradicted'")
|
|
101
|
+
.run();
|
|
102
|
+
},
|
|
103
|
+
// v0.8.0 (K8-002 / plan §6.1, D8-03) — Team: three operations, all
|
|
104
|
+
// idempotent by re-derivation (same discipline as "006"/"007"/"008").
|
|
105
|
+
// 1. Back-fill the new scope from the old one: repo_id = project_id
|
|
106
|
+
// keeps every pre-v0.8 row retrievable on the same machine with an
|
|
107
|
+
// identical result set. Guarded by `repo_id IS NULL`; a row whose
|
|
108
|
+
// project_id is also NULL keeps a NULL repo_id — the retrieval
|
|
109
|
+
// path handles NULL as global (K8-007) instead of the hook faking
|
|
110
|
+
// a value. No git-derived identity here: the hook runs inside a
|
|
111
|
+
// migration and must not read the filesystem (K8-002 criterion).
|
|
112
|
+
// 2. Normalize the layer marker for any row written by a concurrent
|
|
113
|
+
// v0.7.0 process between ALTER and hook (belt and braces; the
|
|
114
|
+
// column DEFAULT already covers the ordinary case).
|
|
115
|
+
// 3. Re-derive shared_entries_total from state rather than trusting
|
|
116
|
+
// an incremented value that may predate a crash.
|
|
117
|
+
"009": (store) => {
|
|
118
|
+
store
|
|
119
|
+
.prepare("UPDATE memories SET repo_id = project_id WHERE repo_id IS NULL")
|
|
120
|
+
.run();
|
|
121
|
+
store
|
|
122
|
+
.prepare("UPDATE memories SET layer = 'local' WHERE layer IS NULL OR layer = ''")
|
|
123
|
+
.run();
|
|
124
|
+
store
|
|
125
|
+
.prepare("UPDATE kevin_metrics SET value = (SELECT COUNT(*) FROM shared_entries) WHERE key = 'shared_entries_total'")
|
|
126
|
+
.run();
|
|
127
|
+
},
|
|
81
128
|
};
|
|
82
129
|
export class Migrate {
|
|
83
130
|
store;
|
|
@@ -105,6 +152,18 @@ export class Migrate {
|
|
|
105
152
|
const from = currentRow?.version ?? "000";
|
|
106
153
|
const pending = this.listPending(from);
|
|
107
154
|
if (pending.length === 0) {
|
|
155
|
+
// v0.7.0 (K7-002) — heal drift in the 008 counters on a no-op
|
|
156
|
+
// startup while preserving `applied: []` idempotency. v0.8.0
|
|
157
|
+
// (K8-002 / plan §6.1) extends the same repair to the 009
|
|
158
|
+
// back-fill and the shared_entries_total re-derivation: both
|
|
159
|
+
// hooks are idempotent by guarded updates and re-derivation,
|
|
160
|
+
// so a no-op startup can heal a crash that landed between the
|
|
161
|
+
// ALTER and the hook without re-applying DDL.
|
|
162
|
+
if (from === "008" || from === "009") {
|
|
163
|
+
const repairHook = this.postApplyHooks.get(from);
|
|
164
|
+
if (repairHook)
|
|
165
|
+
this.store.transaction(() => repairHook(this.store));
|
|
166
|
+
}
|
|
108
167
|
return { from, to: from, applied: [] };
|
|
109
168
|
}
|
|
110
169
|
const insertVersion = this.store.prepare("INSERT OR IGNORE INTO schema_version (version) VALUES (?)");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migrate.js","sourceRoot":"","sources":["../../plugin/Migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAWjC,+EAA+E;AAC/E,gFAAgF;AAChF,
|
|
1
|
+
{"version":3,"file":"Migrate.js","sourceRoot":"","sources":["../../plugin/Migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAA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AC,IAAI,EAAE,EAAE;YACb,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YACrC,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACnD,CAAC,CAAC;aACD,MAAM,CACN,CAAC,CAAC,EAA0C,EAAE,CAC7C,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,OAAO,GAAG,OAAO,CAClC,CAAC;IACJ,CAAC;CACD"}
|
package/dist/plugin/Reflector.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fingerprint as computeFingerprint } from "./fingerprint.js";
|
|
2
|
+
import { classify } from "./inferability.js";
|
|
2
3
|
import { redactPaths as redactPathsText } from "./redact.js";
|
|
3
4
|
const DEFAULT_THROTTLE_MS = 60_000;
|
|
4
5
|
const MAX_CONTENT_CHARS = 4096;
|
|
@@ -128,6 +129,18 @@ export class Reflector {
|
|
|
128
129
|
return null;
|
|
129
130
|
}
|
|
130
131
|
this.lastReflectionByFp.set(fp, now);
|
|
132
|
+
const configurableMemoryService = this.memoryService;
|
|
133
|
+
const lessonMode = configurableMemoryService.getSetting?.("error_lesson_mode", "all") ??
|
|
134
|
+
"all";
|
|
135
|
+
const verdict = classify({
|
|
136
|
+
type: "error",
|
|
137
|
+
content: lesson,
|
|
138
|
+
metadata: { dispatch: { code: dispatched.code, hint: dispatched.hint } },
|
|
139
|
+
});
|
|
140
|
+
if (lessonMode === "triage_only" && verdict === "inferable") {
|
|
141
|
+
this.metrics?.incr("error_lessons_suppressed", 1);
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
131
144
|
// v0.3.0 (K3-018): optional LLM enrichment opt-in. Runs only when
|
|
132
145
|
// the throttle check passed (bug #5).
|
|
133
146
|
let enrichedLesson = lesson;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Reflector.js","sourceRoot":"","sources":["../../plugin/Reflector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,IAAI,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"Reflector.js","sourceRoot":"","sources":["../../plugin/Reflector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,IAAI,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,aAAa,CAAC;AA6D7D,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACnC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,YAAY,GAAG,iBAAiB,CAAC;AACvC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAExC,MAAM,CAAC,MAAM,aAAa,GACzB,gKAAgK,CAAC;AAElK,MAAM,CAAC,MAAM,eAAe,GAC3B,8NAA8N,CAAC;AAEhO;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,WAAW,GAA2B;IAClD,SAAS,EAAE,0CAA0C;IACrD,IAAI,EAAE,gDAAgD;IACtD,IAAI,EAAE,+CAA+C;IACrD,OAAO,EAAE,qDAAqD;IAC9D,OAAO,EAAE,sDAAsD;IAC/D,OAAO,EAAE,sCAAsC;CAC/C,CAAC;AAEF,iFAAiF;AACjF,+EAA+E;AAC/E,gFAAgF;AAChF,kEAAkE;AAElE,kEAAkE;AAClE,iEAAiE;AACjE,YAAY;AACZ,uEAAuE;AACvE,sEAAsE;AACtE,mBAAmB;AACnB,MAAM,CAAC,MAAM,aAAa,GAA2B;IACpD,MAAM,EAAE,gBAAgB;IACxB,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,2BAA2B;IACnC,MAAM,EAAE,sBAAsB;IAC9B,OAAO,EAAE,eAAe;IACxB,MAAM,EAAE,mE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,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE;gBAChC,+CAA+C;gBAC/C,oDAAoD;gBACpD,qBAAqB;gBACrB,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;gBAClD,IAAI,CAAC,EAAE,CAAC;oBACP,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;gBACnC,CAAC;gBACD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACjC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC;YACjC,CAAC,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IAEO,qBAAqB,CAAC,IAAY;QACzC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBACvD,OAAO,OAAO,CAAC;YAChB,CAAC;QACF,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;gBAAE,OAAO,OAAO,CAAC;QACxC,CAAC;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { ArtifactWriter } from "./ArtifactWriter.js";
|
|
2
|
+
/**
|
|
3
|
+
* The three sources `resolve()` tries, in order (plan §5.1).
|
|
4
|
+
*/
|
|
5
|
+
export type IdentitySource = "declared" | "remote" | "path";
|
|
6
|
+
/**
|
|
7
|
+
* The outcome of resolving a repository identity.
|
|
8
|
+
*/
|
|
9
|
+
export interface ResolvedIdentity {
|
|
10
|
+
/** The repository-scoped id every Team scope is keyed on. */
|
|
11
|
+
repoId: string;
|
|
12
|
+
/** Which source produced `repoId`. */
|
|
13
|
+
source: IdentitySource;
|
|
14
|
+
/**
|
|
15
|
+
* A short, non-secret description of how the id was derived,
|
|
16
|
+
* surfaced by `kevin_project show`. Never contains a credential
|
|
17
|
+
* or an absolute path.
|
|
18
|
+
*/
|
|
19
|
+
evidence: string;
|
|
20
|
+
/** The v0.7.0 project scope, always returned regardless of source. */
|
|
21
|
+
projectId: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Read the first `url = …` value inside `[remote "<name>"]` of a
|
|
25
|
+
* `.git/config`-style INI text.
|
|
26
|
+
*
|
|
27
|
+
* Line-oriented reader, not an INI library: tracks the current
|
|
28
|
+
* `[section "sub"]` header, tolerates tabs, spaces around `=`,
|
|
29
|
+
* CRLF, and comment lines. Returns `null` on anything unrecognised
|
|
30
|
+
* and never throws — on any input, including binary.
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseGitConfigRemote(text: string, name?: string): string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Fold the URL shapes git accepts into one canonical string.
|
|
35
|
+
*
|
|
36
|
+
* Steps, in order (K8-005):
|
|
37
|
+
* 1. strip a trailing `.git`;
|
|
38
|
+
* 2. strip a `scheme://` prefix;
|
|
39
|
+
* 3. strip everything up to and including the last `@` in the
|
|
40
|
+
* authority (userinfo and embedded credentials — a token must
|
|
41
|
+
* never reach a hash that lands in a committed file, D8-04);
|
|
42
|
+
* 4. strip a numeric port (`:8443`, `:443`, …) so the same repo
|
|
43
|
+
* served over different transports folds to one id;
|
|
44
|
+
* 5. rewrite the scp-style `host:path` separator to `host/path`;
|
|
45
|
+
* 6. strip a trailing `/`;
|
|
46
|
+
* 7. lowercase the whole result.
|
|
47
|
+
*
|
|
48
|
+
* Returns `null` when the result contains no `/` (e.g. a local
|
|
49
|
+
* path remote) — the caller falls through to the path source.
|
|
50
|
+
*/
|
|
51
|
+
export declare function normalizeRemote(url: string): string | null;
|
|
52
|
+
/**
|
|
53
|
+
* Derive a repository id from a normalized remote (K8-006).
|
|
54
|
+
*
|
|
55
|
+
* The domain prefix means a repo id can never collide with a memory
|
|
56
|
+
* fingerprint computed over the same string, and it leaves room to
|
|
57
|
+
* version the derivation later.
|
|
58
|
+
*/
|
|
59
|
+
export declare function computeRepoId(normalized: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Resolve the repository identity for `cwd`, trying the three
|
|
62
|
+
* sources in order (plan §5.1):
|
|
63
|
+
*
|
|
64
|
+
* 1. `declared` — `.kevin/project.json` → `id` (validated as
|
|
65
|
+
* exactly 16 lowercase hex characters; anything else is ignored
|
|
66
|
+
* and falls through, because a hand-edited garbage id in a
|
|
67
|
+
* committed file would otherwise scope a whole team's corpus
|
|
68
|
+
* onto a typo);
|
|
69
|
+
* 2. `remote` — `.git/config` → `[remote "origin"] url`,
|
|
70
|
+
* normalized and hashed;
|
|
71
|
+
* 3. `path` — `fingerprint(cwd)`, the v0.7.0 behaviour.
|
|
72
|
+
*
|
|
73
|
+
* Never throws: a directory that is not a git repository, an
|
|
74
|
+
* unreadable `.git/config`, and a malformed `project.json` all fall
|
|
75
|
+
* through to source 3. `projectId` is always returned alongside
|
|
76
|
+
* `repoId`, regardless of which source won.
|
|
77
|
+
*/
|
|
78
|
+
export declare function resolve(cwd: string): ResolvedIdentity;
|
|
79
|
+
/**
|
|
80
|
+
* The outcome of `initProjectFile` (K8-008).
|
|
81
|
+
*/
|
|
82
|
+
export interface InitProjectResult {
|
|
83
|
+
/** Whether the file was written. */
|
|
84
|
+
ok: boolean;
|
|
85
|
+
/** The absolute path the file was written to, or refused. */
|
|
86
|
+
path: string;
|
|
87
|
+
/** Human-readable refusal reason when `ok` is false. */
|
|
88
|
+
reason?: string;
|
|
89
|
+
/** The pinned id when the file was written. */
|
|
90
|
+
id?: string;
|
|
91
|
+
/** The ISO-8601 Z timestamp written into the file. */
|
|
92
|
+
createdAt?: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Write `.kevin/project.json` pinning the repository identity (K8-008
|
|
96
|
+
* / plan §5.8). The id comes from the current `resolve(cwd)` — so `init`
|
|
97
|
+
* in a repository with a remote *pins* the remote-derived id, which is
|
|
98
|
+
* the point: it survives the organisation renaming the repo (a remote
|
|
99
|
+
* URL change would otherwise silently re-scope the corpus).
|
|
100
|
+
*
|
|
101
|
+
* The file is `{"id": "<16 hex>", "created_at": "<ISO-8601 Z>",
|
|
102
|
+
* "generator": "opencode-kevin/0.8.0"}` with sorted keys and a
|
|
103
|
+
* terminating newline (deterministic bytes, the codec discipline of
|
|
104
|
+
* plan §7.3). `init` refuses when the file already exists: overwriting
|
|
105
|
+
* it re-scopes a team's corpus, and that is `rekey`'s job (K8-009),
|
|
106
|
+
* with a confirmation.
|
|
107
|
+
*
|
|
108
|
+
* NOTE (K8-019): the write goes through `ArtifactWriter` in whole-file
|
|
109
|
+
* mode — `.kevin/project.json` is a Kevin-owned file, and D8-08 leaves
|
|
110
|
+
* no scenario in which a second raw write path is acceptable (asserted
|
|
111
|
+
* by tests/unit/single_write_path.test.ts).
|
|
112
|
+
*/
|
|
113
|
+
export declare function initProjectFile(cwd: string, writer: ArtifactWriter): InitProjectResult;
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { fingerprint, fnv1a64 } from "./fingerprint.js";
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Kevin 0.8.0 — RepoIdentity (K8-005/K8-006 / plan §5.1, D8-04)
|
|
6
|
+
// ============================================================
|
|
7
|
+
// Repository-derived identity that survives a clone. Two clones
|
|
8
|
+
// of the same remote must agree on one `repo_id` even though
|
|
9
|
+
// `process.cwd()` differs.
|
|
10
|
+
//
|
|
11
|
+
// This file deliberately contains no process-launching calls (D8-01)
|
|
12
|
+
// and no `new URL()` — the scp-style `git@host:path` form that git
|
|
13
|
+
// accepts and roughly half of all clones use rejects URL parsing
|
|
14
|
+
// (K8-005).
|
|
15
|
+
// ============================================================
|
|
16
|
+
// Comment lines git accepts inside a config section: `#` and `;`.
|
|
17
|
+
const COMMENT_RE = /^[#;]/;
|
|
18
|
+
// A declared id must be exactly 16 lowercase hex characters (K8-006).
|
|
19
|
+
const DECLARED_ID_RE = /^[0-9a-f]{16}$/;
|
|
20
|
+
const PROJECT_JSON_PATH = join(".kevin", "project.json");
|
|
21
|
+
const GIT_CONFIG_PATH = join(".git", "config");
|
|
22
|
+
/**
|
|
23
|
+
* Read the first `url = …` value inside `[remote "<name>"]` of a
|
|
24
|
+
* `.git/config`-style INI text.
|
|
25
|
+
*
|
|
26
|
+
* Line-oriented reader, not an INI library: tracks the current
|
|
27
|
+
* `[section "sub"]` header, tolerates tabs, spaces around `=`,
|
|
28
|
+
* CRLF, and comment lines. Returns `null` on anything unrecognised
|
|
29
|
+
* and never throws — on any input, including binary.
|
|
30
|
+
*/
|
|
31
|
+
export function parseGitConfigRemote(text, name = "origin") {
|
|
32
|
+
// Never throw on any input, including binary and huge strings.
|
|
33
|
+
if (typeof text !== "string" || text.length === 0)
|
|
34
|
+
return null;
|
|
35
|
+
const lines = text.split(/\r\n|\n|\r/);
|
|
36
|
+
let currentSection = null;
|
|
37
|
+
let currentSub = null;
|
|
38
|
+
for (const raw of lines) {
|
|
39
|
+
const line = raw.trim();
|
|
40
|
+
if (line.length === 0)
|
|
41
|
+
continue;
|
|
42
|
+
if (COMMENT_RE.test(line))
|
|
43
|
+
continue;
|
|
44
|
+
// Section header: `[section "sub"]` or `[section]`.
|
|
45
|
+
if (line.startsWith("[")) {
|
|
46
|
+
const header = line.slice(1, line.indexOf("]"));
|
|
47
|
+
if (header === null)
|
|
48
|
+
return null;
|
|
49
|
+
const q = header.indexOf('"');
|
|
50
|
+
if (q === -1) {
|
|
51
|
+
currentSection = header.trim();
|
|
52
|
+
currentSub = null;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
currentSection = header.slice(0, q).trim();
|
|
56
|
+
const sub = header.slice(q + 1, header.lastIndexOf('"'));
|
|
57
|
+
currentSub = sub;
|
|
58
|
+
}
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (currentSection !== "remote")
|
|
62
|
+
continue;
|
|
63
|
+
const eq = line.indexOf("=");
|
|
64
|
+
if (eq === -1)
|
|
65
|
+
return null;
|
|
66
|
+
const key = line.slice(0, eq).trim();
|
|
67
|
+
const value = line.slice(eq + 1).trim();
|
|
68
|
+
if (key !== "url")
|
|
69
|
+
continue;
|
|
70
|
+
if (currentSub === name)
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Fold the URL shapes git accepts into one canonical string.
|
|
77
|
+
*
|
|
78
|
+
* Steps, in order (K8-005):
|
|
79
|
+
* 1. strip a trailing `.git`;
|
|
80
|
+
* 2. strip a `scheme://` prefix;
|
|
81
|
+
* 3. strip everything up to and including the last `@` in the
|
|
82
|
+
* authority (userinfo and embedded credentials — a token must
|
|
83
|
+
* never reach a hash that lands in a committed file, D8-04);
|
|
84
|
+
* 4. strip a numeric port (`:8443`, `:443`, …) so the same repo
|
|
85
|
+
* served over different transports folds to one id;
|
|
86
|
+
* 5. rewrite the scp-style `host:path` separator to `host/path`;
|
|
87
|
+
* 6. strip a trailing `/`;
|
|
88
|
+
* 7. lowercase the whole result.
|
|
89
|
+
*
|
|
90
|
+
* Returns `null` when the result contains no `/` (e.g. a local
|
|
91
|
+
* path remote) — the caller falls through to the path source.
|
|
92
|
+
*/
|
|
93
|
+
export function normalizeRemote(url) {
|
|
94
|
+
if (typeof url !== "string" || url.length === 0)
|
|
95
|
+
return null;
|
|
96
|
+
// 1. Strip a trailing `.git` (case-insensitive for file names
|
|
97
|
+
// like `App.GIT`; hosts are lowercased later anyway).
|
|
98
|
+
let s = url.replace(/\.git$/i, "");
|
|
99
|
+
// 2. Strip a `scheme://` prefix — any scheme, including
|
|
100
|
+
// `ssh://`, `https://`, `git://`, `file://`. A `file://`
|
|
101
|
+
// remote collapses to a local path and will fall through.
|
|
102
|
+
s = s.replace(/^[a-z][a-z0-9+.-]*:\/\//i, "");
|
|
103
|
+
// 3. Strip userinfo: everything up to and including the last
|
|
104
|
+
// `@` in the authority. `https://user:token@host/…` and
|
|
105
|
+
// `ssh://git@host/…` both lose the credential half here,
|
|
106
|
+
// before anything else can retain a copy.
|
|
107
|
+
const at = s.lastIndexOf("@");
|
|
108
|
+
if (at !== -1)
|
|
109
|
+
s = s.slice(at + 1);
|
|
110
|
+
// 4. Strip a numeric port: `https://host:8443/org/repo`, `host:8443/
|
|
111
|
+
// org/repo` and `host/org/repo` are the same repository served
|
|
112
|
+
// over different transports — they must fold to one id or the
|
|
113
|
+
// team silently splits by transport form. The scp-style
|
|
114
|
+
// `host:path` form (path not starting with digits) is rewritten
|
|
115
|
+
// by the step below.
|
|
116
|
+
s = s.replace(/^([^/]+):(\d+)(\/|$)/, "$1$3");
|
|
117
|
+
// 5. scp-style `host:path` → `host/path`. The first `:` that
|
|
118
|
+
// remains is the separator; everything after it is the path.
|
|
119
|
+
// After step 3 there is no userinfo `:` left to confuse it.
|
|
120
|
+
const colon = s.indexOf(":");
|
|
121
|
+
if (colon !== -1) {
|
|
122
|
+
s = `${s.slice(0, colon)}/${s.slice(colon + 1)}`;
|
|
123
|
+
}
|
|
124
|
+
// 6. Strip a trailing `/`.
|
|
125
|
+
s = s.replace(/\/+$/, "");
|
|
126
|
+
// 7. Lowercase.
|
|
127
|
+
s = s.toLowerCase();
|
|
128
|
+
if (s.length === 0)
|
|
129
|
+
return null;
|
|
130
|
+
// Anything without a `/` is a bare host or a bare local name,
|
|
131
|
+
// not a remote repository path — the caller falls through.
|
|
132
|
+
if (!s.includes("/"))
|
|
133
|
+
return null;
|
|
134
|
+
// A leading `/` means the remote is a local filesystem path
|
|
135
|
+
// (e.g. `/srv/git/bare.git` or a `file://` remote) — plan §5.1's
|
|
136
|
+
// fifth fixture — and the caller falls through to source 3.
|
|
137
|
+
if (s.startsWith("/"))
|
|
138
|
+
return null;
|
|
139
|
+
return s;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Derive a repository id from a normalized remote (K8-006).
|
|
143
|
+
*
|
|
144
|
+
* The domain prefix means a repo id can never collide with a memory
|
|
145
|
+
* fingerprint computed over the same string, and it leaves room to
|
|
146
|
+
* version the derivation later.
|
|
147
|
+
*/
|
|
148
|
+
export function computeRepoId(normalized) {
|
|
149
|
+
return fnv1a64(`okf:repo:v1\u0000${normalized}`);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Resolve the repository identity for `cwd`, trying the three
|
|
153
|
+
* sources in order (plan §5.1):
|
|
154
|
+
*
|
|
155
|
+
* 1. `declared` — `.kevin/project.json` → `id` (validated as
|
|
156
|
+
* exactly 16 lowercase hex characters; anything else is ignored
|
|
157
|
+
* and falls through, because a hand-edited garbage id in a
|
|
158
|
+
* committed file would otherwise scope a whole team's corpus
|
|
159
|
+
* onto a typo);
|
|
160
|
+
* 2. `remote` — `.git/config` → `[remote "origin"] url`,
|
|
161
|
+
* normalized and hashed;
|
|
162
|
+
* 3. `path` — `fingerprint(cwd)`, the v0.7.0 behaviour.
|
|
163
|
+
*
|
|
164
|
+
* Never throws: a directory that is not a git repository, an
|
|
165
|
+
* unreadable `.git/config`, and a malformed `project.json` all fall
|
|
166
|
+
* through to source 3. `projectId` is always returned alongside
|
|
167
|
+
* `repoId`, regardless of which source won.
|
|
168
|
+
*/
|
|
169
|
+
export function resolve(cwd) {
|
|
170
|
+
const projectId = fingerprint(cwd);
|
|
171
|
+
// 1. Declared.
|
|
172
|
+
try {
|
|
173
|
+
const raw = readFileSync(join(cwd, PROJECT_JSON_PATH), "utf8");
|
|
174
|
+
const parsed = JSON.parse(raw);
|
|
175
|
+
if (typeof parsed.id === "string" && DECLARED_ID_RE.test(parsed.id)) {
|
|
176
|
+
return {
|
|
177
|
+
repoId: parsed.id,
|
|
178
|
+
source: "declared",
|
|
179
|
+
evidence: ".kevin/project.json#id",
|
|
180
|
+
projectId,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
// Missing, unreadable, or malformed — fall through.
|
|
186
|
+
}
|
|
187
|
+
// 2. Remote.
|
|
188
|
+
try {
|
|
189
|
+
const config = readFileSync(join(cwd, GIT_CONFIG_PATH), "utf8");
|
|
190
|
+
const url = parseGitConfigRemote(config);
|
|
191
|
+
const normalized = url === null ? null : normalizeRemote(url);
|
|
192
|
+
if (normalized !== null) {
|
|
193
|
+
return {
|
|
194
|
+
repoId: computeRepoId(normalized),
|
|
195
|
+
source: "remote",
|
|
196
|
+
evidence: `remote:${normalized}`,
|
|
197
|
+
projectId,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
// Unreadable or missing — fall through.
|
|
203
|
+
}
|
|
204
|
+
// 3. Path — the v0.7.0 behaviour, preserved exactly.
|
|
205
|
+
return { repoId: projectId, source: "path", evidence: "cwd", projectId };
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Write `.kevin/project.json` pinning the repository identity (K8-008
|
|
209
|
+
* / plan §5.8). The id comes from the current `resolve(cwd)` — so `init`
|
|
210
|
+
* in a repository with a remote *pins* the remote-derived id, which is
|
|
211
|
+
* the point: it survives the organisation renaming the repo (a remote
|
|
212
|
+
* URL change would otherwise silently re-scope the corpus).
|
|
213
|
+
*
|
|
214
|
+
* The file is `{"id": "<16 hex>", "created_at": "<ISO-8601 Z>",
|
|
215
|
+
* "generator": "opencode-kevin/0.8.0"}` with sorted keys and a
|
|
216
|
+
* terminating newline (deterministic bytes, the codec discipline of
|
|
217
|
+
* plan §7.3). `init` refuses when the file already exists: overwriting
|
|
218
|
+
* it re-scopes a team's corpus, and that is `rekey`'s job (K8-009),
|
|
219
|
+
* with a confirmation.
|
|
220
|
+
*
|
|
221
|
+
* NOTE (K8-019): the write goes through `ArtifactWriter` in whole-file
|
|
222
|
+
* mode — `.kevin/project.json` is a Kevin-owned file, and D8-08 leaves
|
|
223
|
+
* no scenario in which a second raw write path is acceptable (asserted
|
|
224
|
+
* by tests/unit/single_write_path.test.ts).
|
|
225
|
+
*/
|
|
226
|
+
export function initProjectFile(cwd, writer) {
|
|
227
|
+
const path = join(cwd, PROJECT_JSON_PATH);
|
|
228
|
+
try {
|
|
229
|
+
readFileSync(path, "utf8");
|
|
230
|
+
return {
|
|
231
|
+
ok: false,
|
|
232
|
+
path,
|
|
233
|
+
reason: `.kevin/project.json already exists — overwriting it would re-scope the corpus; use "kevin_project rekey" instead`,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
// Absent or unreadable — proceed.
|
|
238
|
+
}
|
|
239
|
+
const id = resolve(cwd).repoId;
|
|
240
|
+
const createdAt = new Date().toISOString();
|
|
241
|
+
const payload = `${JSON.stringify({
|
|
242
|
+
created_at: createdAt,
|
|
243
|
+
generator: "opencode-kevin/0.8.0",
|
|
244
|
+
id,
|
|
245
|
+
})}\n`;
|
|
246
|
+
try {
|
|
247
|
+
mkdirSync(join(cwd, ".kevin"), { recursive: true });
|
|
248
|
+
const outcome = writer.write({ path, mode: "whole", content: payload });
|
|
249
|
+
if (outcome !== "written") {
|
|
250
|
+
return {
|
|
251
|
+
ok: false,
|
|
252
|
+
path,
|
|
253
|
+
reason: `could not write .kevin/project.json: ${outcome}`,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
return { ok: true, path, id, createdAt };
|
|
257
|
+
}
|
|
258
|
+
catch (err) {
|
|
259
|
+
return {
|
|
260
|
+
ok: false,
|
|
261
|
+
path,
|
|
262
|
+
reason: `could not write .kevin/project.json: ${err?.message ?? "unknown error"}`,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
//# sourceMappingURL=RepoIdentity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepoIdentity.js","sourceRoot":"","sources":["../../plugin/RepoIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAExD,+DAA+D;AAC/D,gEAAgE;AAChE,+DAA+D;AAC/D,gEAAgE;AAChE,6DAA6D;AAC7D,2BAA2B;AAC3B,EAAE;AACF,qEAAqE;AACrE,mEAAmE;AACnE,iEAAiE;AACjE,YAAY;AACZ,+DAA+D;AAE/D,kEAAkE;AAClE,MAAM,UAAU,GAAG,OAAO,CAAC;AAE3B,sEAAsE;AACtE,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAExC,MAAM,iBAAiB,GAAG,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;AACzD,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAyB/C;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CACnC,IAAY,EACZ,IAAI,GAAG,QAAQ;IAEf,+DAA+D;IAC/D,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAE/D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACvC,IAAI,cAAc,GAAkB,IAAI,CAAC;IACzC,IAAI,UAAU,GAAkB,IAAI,CAAC;IAErC,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,GAAG,C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GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,UAAU,EAAE,SAAS;QACrB,SAAS,EAAE,sBAAsB;QACjC,EAAE;KACF,CAAC,IAAI,CAAC;IACP,IAAI,CAAC;QACJ,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QACxE,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO;gBACN,EAAE,EAAE,KAAK;gBACT,IAAI;gBACJ,MAAM,EAAE,wCAAwC,OAAO,EAAE;aACzD,CAAC;QACH,CAAC;QACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;IAC1C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,OAAO;YACN,EAAE,EAAE,KAAK;YACT,IAAI;YACJ,MAAM,EAAE,wCAAyC,GAA4B,EAAE,OAAO,IAAI,eAAe,EAAE;SAC3G,CAAC;IACH,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Memory } from "./MemoryService.js";
|
|
2
|
+
import type { Store } from "./Store.js";
|
|
3
|
+
import type { Metrics } from "./metrics.js";
|
|
4
|
+
declare const MAX_FACTS_PER_PROJECT = 500;
|
|
5
|
+
export interface RepoFact {
|
|
6
|
+
/** "package.json" | "tsconfig.json" */
|
|
7
|
+
readonly file: string;
|
|
8
|
+
/** "scripts.test", "dependencies.zod", "compilerOptions.strict" */
|
|
9
|
+
readonly keyPath: string;
|
|
10
|
+
/** always stringified */
|
|
11
|
+
readonly value: string;
|
|
12
|
+
}
|
|
13
|
+
export interface RepoFactRow extends RepoFact {
|
|
14
|
+
id: string;
|
|
15
|
+
projectId: string;
|
|
16
|
+
fingerprint: string;
|
|
17
|
+
sourceMtime: string | null;
|
|
18
|
+
scannedAt: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class RepoTruth {
|
|
21
|
+
private readonly store;
|
|
22
|
+
private readonly projectId;
|
|
23
|
+
private readonly projectRoot;
|
|
24
|
+
private readonly metrics;
|
|
25
|
+
private hasTable;
|
|
26
|
+
private readonly lastMtimes;
|
|
27
|
+
private readonly lastFacts;
|
|
28
|
+
private lastScanAt;
|
|
29
|
+
private readonly prevDeps;
|
|
30
|
+
constructor(store: Store, projectId: string, projectRoot: string, metrics?: Metrics | null);
|
|
31
|
+
private ensureTables;
|
|
32
|
+
/**
|
|
33
|
+
* v0.7.0 (K7-005/006 / plan §5.1-5.2, D7-13) — refresh the repository
|
|
34
|
+
* truth. The steady state of an idle session is two `stat` calls: a file
|
|
35
|
+
* whose `source_mtime` is unchanged is NOT re-parsed (no JSON.parse, no
|
|
36
|
+
* readFileSync). A changed file replaces that file's facts for THIS
|
|
37
|
+
* project only; a file no longer present has its facts removed for this
|
|
38
|
+
* project only. The project-wide 500-fact cap is applied to the combined,
|
|
39
|
+
* deterministically-ordered fact set and the truncation is recorded, never
|
|
40
|
+
* silent. Returns the project's stored fact view after the scan (including
|
|
41
|
+
* a `_truncated` row when the cap was hit), so repeated scans of unchanged
|
|
42
|
+
* files return identical results.
|
|
43
|
+
*/
|
|
44
|
+
scan(_now?: Date): RepoFact[];
|
|
45
|
+
private hasStoredFileFacts;
|
|
46
|
+
private currentScanFacts;
|
|
47
|
+
private storedFileFacts;
|
|
48
|
+
private getStoredMtime;
|
|
49
|
+
private persistAll;
|
|
50
|
+
private storedFactCount;
|
|
51
|
+
private storedTruncation;
|
|
52
|
+
/**
|
|
53
|
+
* v0.7.0 (K7-006 / plan §5.2) — extract a file's facts WITHOUT writing
|
|
54
|
+
* anything. Used by scan to keep a single source of truth for extraction.
|
|
55
|
+
*/
|
|
56
|
+
private extractFile;
|
|
57
|
+
private fileMtimes;
|
|
58
|
+
/**
|
|
59
|
+
* v0.7.0 (K7-006 / plan §5.2, D7-02) — the project-scoped stored facts.
|
|
60
|
+
* Every read filters on `project_id`, so a second project's facts never
|
|
61
|
+
* leak into this project's view.
|
|
62
|
+
*/
|
|
63
|
+
facts(): RepoFact[];
|
|
64
|
+
/** v0.7.0 (K7-009) — human-readable fact rows for `kevin_facts`. */
|
|
65
|
+
storeFacts(): RepoFactRow[];
|
|
66
|
+
/** Timestamp of the latest scan in this process or persisted facts. */
|
|
67
|
+
scannedAt(): string | null;
|
|
68
|
+
/**
|
|
69
|
+
* v0.7.0 (K7-007 / plan §5.1, D7-05) — exact-match contradiction detection:
|
|
70
|
+
* the three and only three checks. Each returns a human-readable reason;
|
|
71
|
+
* empty when consistent. Pure read — writes nothing (K7-008 and K7-014 own
|
|
72
|
+
* the penalty and conflict-row writes).
|
|
73
|
+
*/
|
|
74
|
+
contradictions(memory: Memory): string[];
|
|
75
|
+
private checkMissingScripts;
|
|
76
|
+
private checkMissingDependencies;
|
|
77
|
+
private checkChangedCompilerOptions;
|
|
78
|
+
private currentDepPackages;
|
|
79
|
+
}
|
|
80
|
+
export { MAX_FACTS_PER_PROJECT };
|