@hivelore/core 0.57.4 → 0.57.5
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/dist/index.d.ts +19 -2
- package/dist/index.js +36 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -304,6 +304,16 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
304
304
|
* Lets a human distinguish reviewed knowledge from AI/auto-trusted knowledge.
|
|
305
305
|
*/
|
|
306
306
|
validated_by: z.ZodDefault<z.ZodNullable<z.ZodEnum<["human", "agent", "auto"]>>>;
|
|
307
|
+
/**
|
|
308
|
+
* Does this memory describe code that EXISTS today, or a decision not yet built? Orthogonal to
|
|
309
|
+
* `confidence`/`status`: a `planned` decision can be fully trusted AS a decision while being false
|
|
310
|
+
* AS a description of the current code. Surfaced distinctly in briefings so an agent does not write
|
|
311
|
+
* code against a cookie/route/Node version that was only decided, never implemented (field report §3.3).
|
|
312
|
+
* applied — reflected in the code now (the default when omitted)
|
|
313
|
+
* planned — decided/intended, NOT yet implemented
|
|
314
|
+
* abandoned — considered and rejected; kept so it is not re-attempted
|
|
315
|
+
*/
|
|
316
|
+
lifecycle: z.ZodOptional<z.ZodEnum<["applied", "planned", "abandoned"]>>;
|
|
307
317
|
}, "strip", z.ZodTypeAny, {
|
|
308
318
|
type: "convention" | "decision" | "gotcha" | "architecture" | "glossary" | "skill" | "attempt" | "session_recap";
|
|
309
319
|
status: "draft" | "proposed" | "validated" | "deprecated" | "stale" | "rejected";
|
|
@@ -351,6 +361,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
351
361
|
domain?: string | undefined;
|
|
352
362
|
author?: string | undefined;
|
|
353
363
|
topic?: string | undefined;
|
|
364
|
+
lifecycle?: "applied" | "planned" | "abandoned" | undefined;
|
|
354
365
|
}, {
|
|
355
366
|
type: "convention" | "decision" | "gotcha" | "architecture" | "glossary" | "skill" | "attempt" | "session_recap";
|
|
356
367
|
id: string;
|
|
@@ -398,6 +409,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
398
409
|
revision_count?: number | undefined;
|
|
399
410
|
requires_human_approval?: boolean | undefined;
|
|
400
411
|
validated_by?: "human" | "agent" | "auto" | null | undefined;
|
|
412
|
+
lifecycle?: "applied" | "planned" | "abandoned" | undefined;
|
|
401
413
|
}>, {
|
|
402
414
|
type: "convention" | "decision" | "gotcha" | "architecture" | "glossary" | "skill" | "attempt" | "session_recap";
|
|
403
415
|
status: "draft" | "proposed" | "validated" | "deprecated" | "stale" | "rejected";
|
|
@@ -445,6 +457,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
445
457
|
domain?: string | undefined;
|
|
446
458
|
author?: string | undefined;
|
|
447
459
|
topic?: string | undefined;
|
|
460
|
+
lifecycle?: "applied" | "planned" | "abandoned" | undefined;
|
|
448
461
|
}, {
|
|
449
462
|
type: "convention" | "decision" | "gotcha" | "architecture" | "glossary" | "skill" | "attempt" | "session_recap";
|
|
450
463
|
id: string;
|
|
@@ -492,6 +505,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
492
505
|
revision_count?: number | undefined;
|
|
493
506
|
requires_human_approval?: boolean | undefined;
|
|
494
507
|
validated_by?: "human" | "agent" | "auto" | null | undefined;
|
|
508
|
+
lifecycle?: "applied" | "planned" | "abandoned" | undefined;
|
|
495
509
|
}>;
|
|
496
510
|
declare const CrossRepoProvenanceSchema: z.ZodOptional<z.ZodObject<{
|
|
497
511
|
source_name: z.ZodString;
|
|
@@ -542,6 +556,7 @@ declare function buildFrontmatter(input: {
|
|
|
542
556
|
relatedIds?: string[];
|
|
543
557
|
sensor?: Sensor;
|
|
544
558
|
activation?: Activation;
|
|
559
|
+
lifecycle?: MemoryFrontmatter["lifecycle"];
|
|
545
560
|
}): MemoryFrontmatter;
|
|
546
561
|
|
|
547
562
|
declare const HAIVE_DIR = ".ai";
|
|
@@ -2624,8 +2639,10 @@ declare function isRetiredMemory(fm: MemoryFrontmatter, body?: string, now?: Dat
|
|
|
2624
2639
|
/**
|
|
2625
2640
|
* Is a regex sensor pattern brittle — over-fit to incident-specific literals that rot when code
|
|
2626
2641
|
* shifts (hardcoded line numbers / ranges like `1131-1186`)? High-precision by design: digits that
|
|
2627
|
-
* live inside a character class (`[0-9]`) or quantifier (`{2,}`)
|
|
2628
|
-
*
|
|
2642
|
+
* live inside a character class (`[0-9]`) or quantifier (`{2,}`), regex escapes (`\d`, `\w`, `\s`),
|
|
2643
|
+
* or a dotted-quad IP / version literal (`127\.0\.0\.1`, `1\.2\.3`) all GENERALIZE and are NOT
|
|
2644
|
+
* flagged — so durable patterns like `v[0-9]+\.[0-9]+`, `:\s*any\b`, or `https?://127\.0\.0\.1:\d+`
|
|
2645
|
+
* stay clean. Returns a short reason naming the offending token, or null.
|
|
2629
2646
|
*
|
|
2630
2647
|
* Used to keep brittle legacy sensors from being counted as real protection or promoted to `block`.
|
|
2631
2648
|
*/
|
package/dist/index.js
CHANGED
|
@@ -135,7 +135,17 @@ var MemoryFrontmatterSchema = z.object({
|
|
|
135
135
|
* null when the memory is not yet validated, or on legacy memories written before this field.
|
|
136
136
|
* Lets a human distinguish reviewed knowledge from AI/auto-trusted knowledge.
|
|
137
137
|
*/
|
|
138
|
-
validated_by: z.enum(["human", "agent", "auto"]).nullable().default(null)
|
|
138
|
+
validated_by: z.enum(["human", "agent", "auto"]).nullable().default(null),
|
|
139
|
+
/**
|
|
140
|
+
* Does this memory describe code that EXISTS today, or a decision not yet built? Orthogonal to
|
|
141
|
+
* `confidence`/`status`: a `planned` decision can be fully trusted AS a decision while being false
|
|
142
|
+
* AS a description of the current code. Surfaced distinctly in briefings so an agent does not write
|
|
143
|
+
* code against a cookie/route/Node version that was only decided, never implemented (field report §3.3).
|
|
144
|
+
* applied — reflected in the code now (the default when omitted)
|
|
145
|
+
* planned — decided/intended, NOT yet implemented
|
|
146
|
+
* abandoned — considered and rejected; kept so it is not re-attempted
|
|
147
|
+
*/
|
|
148
|
+
lifecycle: z.enum(["applied", "planned", "abandoned"]).optional()
|
|
139
149
|
}).refine(
|
|
140
150
|
(data) => data.scope !== "module" || !!data.module,
|
|
141
151
|
{ message: "module name is required when scope is 'module'", path: ["module"] }
|
|
@@ -153,15 +163,30 @@ var CrossRepoProvenanceSchema = z.object({
|
|
|
153
163
|
|
|
154
164
|
// src/parser.ts
|
|
155
165
|
import matter from "gray-matter";
|
|
166
|
+
import "zod";
|
|
156
167
|
var PRIVATE_BLOCK_RE = /<private>[\s\S]*?<\/private>/g;
|
|
157
168
|
function stripPrivate(body) {
|
|
158
169
|
return body.replace(PRIVATE_BLOCK_RE, "").trimEnd();
|
|
159
170
|
}
|
|
171
|
+
function formatFrontmatterError(err) {
|
|
172
|
+
const issue = err.issues[0];
|
|
173
|
+
if (!issue) return "invalid frontmatter";
|
|
174
|
+
const field = issue.path.length > 0 ? issue.path.join(".") : "frontmatter";
|
|
175
|
+
if (issue.code === "invalid_enum_value") {
|
|
176
|
+
const got = JSON.stringify(issue.received);
|
|
177
|
+
const allowed = issue.options.join(" | ");
|
|
178
|
+
return `invalid ${field}: ${got} is not a supported value \u2014 expected one of: ${allowed}`;
|
|
179
|
+
}
|
|
180
|
+
return `invalid ${field}: ${issue.message}`;
|
|
181
|
+
}
|
|
160
182
|
function parseMemory(raw) {
|
|
161
183
|
const parsed = matter(raw);
|
|
162
|
-
const
|
|
184
|
+
const result = MemoryFrontmatterSchema.safeParse(parsed.data);
|
|
185
|
+
if (!result.success) {
|
|
186
|
+
throw new Error(formatFrontmatterError(result.error));
|
|
187
|
+
}
|
|
163
188
|
return {
|
|
164
|
-
frontmatter,
|
|
189
|
+
frontmatter: result.data,
|
|
165
190
|
body: stripPrivate(parsed.content.trim())
|
|
166
191
|
};
|
|
167
192
|
}
|
|
@@ -210,6 +235,7 @@ function buildFrontmatter(input) {
|
|
|
210
235
|
topic: input.topic,
|
|
211
236
|
sensor: input.sensor,
|
|
212
237
|
activation: input.activation,
|
|
238
|
+
lifecycle: input.lifecycle,
|
|
213
239
|
revision_count: 0,
|
|
214
240
|
related_ids: input.relatedIds ?? []
|
|
215
241
|
});
|
|
@@ -1752,9 +1778,13 @@ function generateBridges(memories, sensors, opts) {
|
|
|
1752
1778
|
|
|
1753
1779
|
// src/sensors.ts
|
|
1754
1780
|
function sensorPatternBrittleness(pattern) {
|
|
1755
|
-
const literal = pattern.replace(/\[[^\]]*\]/g, "").replace(/\{[^}]*\}/g, "");
|
|
1756
|
-
|
|
1757
|
-
if (
|
|
1781
|
+
const literal = pattern.replace(/\\[a-zA-Z]/g, " ").replace(/\[[^\]]*\]/g, " ").replace(/\{[^}]*\}/g, " ").replace(/\b\d{1,3}(?:\s*\\?\.\s*\d{1,3}){2,3}\b/g, " ");
|
|
1782
|
+
const range = literal.match(/\d{2,}\s*-\s*\d{2,}/);
|
|
1783
|
+
if (range) return `hardcoded line/number range "${range[0].replace(/\s+/g, "")}" \u2014 rots when code shifts`;
|
|
1784
|
+
const numeric = literal.match(/\d{3,}/);
|
|
1785
|
+
if (numeric) {
|
|
1786
|
+
return `hardcoded numeric literal "${numeric[0]}" (likely a line number) \u2014 rots when code shifts; if it is a real constant, put it in a character class ([0-9]) or anchor it to a stable token`;
|
|
1787
|
+
}
|
|
1758
1788
|
return null;
|
|
1759
1789
|
}
|
|
1760
1790
|
function normalizeProjectPath(value) {
|