@hiveai/core 0.3.3 → 0.4.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/dist/index.d.ts +168 -7
- package/dist/index.js +602 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
declare const MemoryScopeSchema: z.ZodEnum<["personal", "team", "module"]>;
|
|
3
|
+
declare const MemoryScopeSchema: z.ZodEnum<["personal", "team", "module", "shared"]>;
|
|
4
4
|
declare const MemoryStatusSchema: z.ZodEnum<["draft", "proposed", "validated", "deprecated", "stale", "rejected"]>;
|
|
5
5
|
declare const MemoryTypeSchema: z.ZodEnum<["convention", "decision", "gotcha", "architecture", "glossary", "attempt", "session_recap"]>;
|
|
6
6
|
declare const AnchorSchema: z.ZodObject<{
|
|
@@ -18,7 +18,7 @@ declare const AnchorSchema: z.ZodObject<{
|
|
|
18
18
|
}>;
|
|
19
19
|
declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
20
20
|
id: z.ZodString;
|
|
21
|
-
scope: z.ZodDefault<z.ZodEnum<["personal", "team", "module"]>>;
|
|
21
|
+
scope: z.ZodDefault<z.ZodEnum<["personal", "team", "module", "shared"]>>;
|
|
22
22
|
module: z.ZodOptional<z.ZodString>;
|
|
23
23
|
type: z.ZodEnum<["convention", "decision", "gotcha", "architecture", "glossary", "attempt", "session_recap"]>;
|
|
24
24
|
status: z.ZodDefault<z.ZodEnum<["draft", "proposed", "validated", "deprecated", "stale", "rejected"]>>;
|
|
@@ -46,11 +46,18 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
46
46
|
last_read_at: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
47
47
|
topic: z.ZodOptional<z.ZodString>;
|
|
48
48
|
revision_count: z.ZodDefault<z.ZodNumber>;
|
|
49
|
+
/**
|
|
50
|
+
* When true, the AI MUST NOT act on this memory autonomously.
|
|
51
|
+
* It must surface the information to the human developer and wait
|
|
52
|
+
* for explicit confirmation before modifying any code.
|
|
53
|
+
* Used for cross-repo breaking changes, dependency bumps, contract diffs.
|
|
54
|
+
*/
|
|
55
|
+
requires_human_approval: z.ZodDefault<z.ZodBoolean>;
|
|
49
56
|
}, "strip", z.ZodTypeAny, {
|
|
50
57
|
type: "convention" | "decision" | "gotcha" | "architecture" | "glossary" | "attempt" | "session_recap";
|
|
51
58
|
status: "draft" | "proposed" | "validated" | "deprecated" | "stale" | "rejected";
|
|
52
59
|
id: string;
|
|
53
|
-
scope: "personal" | "team" | "module";
|
|
60
|
+
scope: "personal" | "team" | "module" | "shared";
|
|
54
61
|
anchor: {
|
|
55
62
|
paths: string[];
|
|
56
63
|
symbols: string[];
|
|
@@ -64,6 +71,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
64
71
|
related_ids: string[];
|
|
65
72
|
last_read_at: string | null;
|
|
66
73
|
revision_count: number;
|
|
74
|
+
requires_human_approval: boolean;
|
|
67
75
|
module?: string | undefined;
|
|
68
76
|
domain?: string | undefined;
|
|
69
77
|
author?: string | undefined;
|
|
@@ -74,7 +82,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
74
82
|
created_at: string | Date;
|
|
75
83
|
module?: string | undefined;
|
|
76
84
|
status?: "draft" | "proposed" | "validated" | "deprecated" | "stale" | "rejected" | undefined;
|
|
77
|
-
scope?: "personal" | "team" | "module" | undefined;
|
|
85
|
+
scope?: "personal" | "team" | "module" | "shared" | undefined;
|
|
78
86
|
anchor?: {
|
|
79
87
|
commit?: string | undefined;
|
|
80
88
|
paths?: string[] | undefined;
|
|
@@ -90,11 +98,12 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
90
98
|
last_read_at?: string | null | undefined;
|
|
91
99
|
topic?: string | undefined;
|
|
92
100
|
revision_count?: number | undefined;
|
|
101
|
+
requires_human_approval?: boolean | undefined;
|
|
93
102
|
}>, {
|
|
94
103
|
type: "convention" | "decision" | "gotcha" | "architecture" | "glossary" | "attempt" | "session_recap";
|
|
95
104
|
status: "draft" | "proposed" | "validated" | "deprecated" | "stale" | "rejected";
|
|
96
105
|
id: string;
|
|
97
|
-
scope: "personal" | "team" | "module";
|
|
106
|
+
scope: "personal" | "team" | "module" | "shared";
|
|
98
107
|
anchor: {
|
|
99
108
|
paths: string[];
|
|
100
109
|
symbols: string[];
|
|
@@ -108,6 +117,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
108
117
|
related_ids: string[];
|
|
109
118
|
last_read_at: string | null;
|
|
110
119
|
revision_count: number;
|
|
120
|
+
requires_human_approval: boolean;
|
|
111
121
|
module?: string | undefined;
|
|
112
122
|
domain?: string | undefined;
|
|
113
123
|
author?: string | undefined;
|
|
@@ -118,7 +128,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
118
128
|
created_at: string | Date;
|
|
119
129
|
module?: string | undefined;
|
|
120
130
|
status?: "draft" | "proposed" | "validated" | "deprecated" | "stale" | "rejected" | undefined;
|
|
121
|
-
scope?: "personal" | "team" | "module" | undefined;
|
|
131
|
+
scope?: "personal" | "team" | "module" | "shared" | undefined;
|
|
122
132
|
anchor?: {
|
|
123
133
|
commit?: string | undefined;
|
|
124
134
|
paths?: string[] | undefined;
|
|
@@ -134,7 +144,24 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
134
144
|
last_read_at?: string | null | undefined;
|
|
135
145
|
topic?: string | undefined;
|
|
136
146
|
revision_count?: number | undefined;
|
|
147
|
+
requires_human_approval?: boolean | undefined;
|
|
137
148
|
}>;
|
|
149
|
+
declare const CrossRepoProvenanceSchema: z.ZodOptional<z.ZodObject<{
|
|
150
|
+
source_name: z.ZodString;
|
|
151
|
+
source_path: z.ZodString;
|
|
152
|
+
source_id: z.ZodString;
|
|
153
|
+
imported_at: z.ZodString;
|
|
154
|
+
}, "strip", z.ZodTypeAny, {
|
|
155
|
+
source_name: string;
|
|
156
|
+
source_path: string;
|
|
157
|
+
source_id: string;
|
|
158
|
+
imported_at: string;
|
|
159
|
+
}, {
|
|
160
|
+
source_name: string;
|
|
161
|
+
source_path: string;
|
|
162
|
+
source_id: string;
|
|
163
|
+
imported_at: string;
|
|
164
|
+
}>>;
|
|
138
165
|
|
|
139
166
|
type MemoryScope = z.infer<typeof MemoryScopeSchema>;
|
|
140
167
|
type MemoryStatus = z.infer<typeof MemoryStatusSchema>;
|
|
@@ -163,6 +190,7 @@ declare function buildFrontmatter(input: {
|
|
|
163
190
|
commit?: string;
|
|
164
191
|
topic?: string;
|
|
165
192
|
status?: MemoryFrontmatter["status"];
|
|
193
|
+
relatedIds?: string[];
|
|
166
194
|
}): MemoryFrontmatter;
|
|
167
195
|
|
|
168
196
|
declare const HAIVE_DIR = ".ai";
|
|
@@ -359,6 +387,31 @@ declare function queryCodeMap(map: CodeMap, options: CodeMapQueryOptions): {
|
|
|
359
387
|
};
|
|
360
388
|
|
|
361
389
|
declare const CONFIG_FILE = "haive.config.json";
|
|
390
|
+
/** A remote or local repo to pull shared memories from. */
|
|
391
|
+
interface CrossRepoSource {
|
|
392
|
+
/** Human-readable name for this source (used in imported memory tags). */
|
|
393
|
+
name: string;
|
|
394
|
+
/** Local filesystem path to the other project's root (relative or absolute). */
|
|
395
|
+
path?: string;
|
|
396
|
+
/** Git URL — clone/fetch performed automatically. */
|
|
397
|
+
git?: string;
|
|
398
|
+
/** Only import memories matching all of these filters. */
|
|
399
|
+
filter?: {
|
|
400
|
+
/** Only import memories with these tags. */
|
|
401
|
+
tags?: string[];
|
|
402
|
+
/** Only import memories of these types. */
|
|
403
|
+
types?: string[];
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
/** An API contract file to snapshot and monitor for breaking changes. */
|
|
407
|
+
interface ContractFile {
|
|
408
|
+
/** Human-readable name for this contract. */
|
|
409
|
+
name: string;
|
|
410
|
+
/** Path to the contract file, relative to the project root. */
|
|
411
|
+
path: string;
|
|
412
|
+
/** Format of the contract file. */
|
|
413
|
+
format: "openapi" | "graphql" | "proto" | "typescript" | "json-schema";
|
|
414
|
+
}
|
|
362
415
|
interface HaiveConfig {
|
|
363
416
|
/** Autopilot mode: maximum autonomy, minimum human intervention. Default: false. */
|
|
364
417
|
autopilot?: boolean;
|
|
@@ -384,6 +437,35 @@ interface HaiveConfig {
|
|
|
384
437
|
* the template. Default: true in autopilot, false otherwise.
|
|
385
438
|
*/
|
|
386
439
|
autoContext?: boolean;
|
|
440
|
+
/**
|
|
441
|
+
* Other repos to pull `shared`-scoped memories from during `haive sync`.
|
|
442
|
+
* Each source must have either `path` (local) or `git` (remote URL).
|
|
443
|
+
*
|
|
444
|
+
* Example:
|
|
445
|
+
* { "name": "backend", "path": "../repo-backend", "filter": { "tags": ["api-contract"] } }
|
|
446
|
+
*/
|
|
447
|
+
crossRepoSources?: CrossRepoSource[];
|
|
448
|
+
/**
|
|
449
|
+
* API contract files to snapshot and watch for breaking changes.
|
|
450
|
+
* `haive sync` compares the current file against `.ai/contracts/<name>.lock`
|
|
451
|
+
* and creates a `gotcha` memory if a breaking change is detected.
|
|
452
|
+
*
|
|
453
|
+
* Example:
|
|
454
|
+
* { "name": "payment-api", "path": "docs/openapi.yaml", "format": "openapi" }
|
|
455
|
+
*/
|
|
456
|
+
contractFiles?: ContractFile[];
|
|
457
|
+
/**
|
|
458
|
+
* Local path to a shared team-knowledge hub repo.
|
|
459
|
+
* Used by `haive hub pull` and `haive hub push`.
|
|
460
|
+
* Can be relative (resolved from project root) or absolute.
|
|
461
|
+
*/
|
|
462
|
+
hubPath?: string;
|
|
463
|
+
/**
|
|
464
|
+
* Lock file paths to watch for dependency version changes.
|
|
465
|
+
* Auto-detected if not specified (package.json, pom.xml, go.mod, etc.).
|
|
466
|
+
* Set to [] to disable dependency tracking entirely.
|
|
467
|
+
*/
|
|
468
|
+
dependencyFiles?: string[];
|
|
387
469
|
}
|
|
388
470
|
declare const DEFAULT_CONFIG: HaiveConfig;
|
|
389
471
|
declare const AUTOPILOT_DEFAULTS: HaiveConfig;
|
|
@@ -391,4 +473,83 @@ declare function configPath(paths: HaivePaths): string;
|
|
|
391
473
|
declare function loadConfig(paths: HaivePaths): Promise<HaiveConfig>;
|
|
392
474
|
declare function saveConfig(paths: HaivePaths, config: HaiveConfig): Promise<void>;
|
|
393
475
|
|
|
394
|
-
|
|
476
|
+
interface CrossRepoReport {
|
|
477
|
+
source: string;
|
|
478
|
+
imported: string[];
|
|
479
|
+
updated: string[];
|
|
480
|
+
skipped: string[];
|
|
481
|
+
errors: string[];
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Pull shared memories from all configured cross-repo sources.
|
|
485
|
+
* Returns one report per source.
|
|
486
|
+
*/
|
|
487
|
+
declare function pullCrossRepoSources(paths: HaivePaths, config: HaiveConfig, projectRoot: string): Promise<CrossRepoReport[]>;
|
|
488
|
+
|
|
489
|
+
interface DependencySnapshot {
|
|
490
|
+
file: string;
|
|
491
|
+
format: string;
|
|
492
|
+
captured_at: string;
|
|
493
|
+
deps: Record<string, string>;
|
|
494
|
+
}
|
|
495
|
+
interface DepChange {
|
|
496
|
+
name: string;
|
|
497
|
+
from: string;
|
|
498
|
+
to: string;
|
|
499
|
+
/** true if the major version number changed */
|
|
500
|
+
isMajorBump: boolean;
|
|
501
|
+
}
|
|
502
|
+
interface DepTrackResult {
|
|
503
|
+
file: string;
|
|
504
|
+
changes: DepChange[];
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Resolve which manifest files to track.
|
|
508
|
+
* Uses config.dependencyFiles if set, otherwise auto-detects from KNOWN_MANIFESTS.
|
|
509
|
+
*/
|
|
510
|
+
declare function resolveManifestFiles(projectRoot: string, configuredFiles?: string[]): string[];
|
|
511
|
+
/**
|
|
512
|
+
* Check all manifest files for version changes since last snapshot.
|
|
513
|
+
* Returns one result per file that has changes.
|
|
514
|
+
*/
|
|
515
|
+
declare function trackDependencies(projectRoot: string, haiveDir: string, manifestFiles: string[]): Promise<DepTrackResult[]>;
|
|
516
|
+
|
|
517
|
+
interface ContractSnapshot {
|
|
518
|
+
name: string;
|
|
519
|
+
path: string;
|
|
520
|
+
format: string;
|
|
521
|
+
captured_at: string;
|
|
522
|
+
hash: string;
|
|
523
|
+
endpoints?: string[];
|
|
524
|
+
types?: string[];
|
|
525
|
+
fields?: Record<string, string[]>;
|
|
526
|
+
raw_lines?: string[];
|
|
527
|
+
}
|
|
528
|
+
interface BreakingChange {
|
|
529
|
+
kind: "endpoint_removed" | "endpoint_added" | "type_removed" | "type_added" | "field_removed" | "field_added" | "content_changed";
|
|
530
|
+
description: string;
|
|
531
|
+
severity: "breaking" | "additive" | "unknown";
|
|
532
|
+
}
|
|
533
|
+
interface ContractDiffResult {
|
|
534
|
+
contract: string;
|
|
535
|
+
file: string;
|
|
536
|
+
changes: BreakingChange[];
|
|
537
|
+
unchanged: boolean;
|
|
538
|
+
}
|
|
539
|
+
declare function contractLockPath(haiveDir: string, name: string): string;
|
|
540
|
+
/**
|
|
541
|
+
* Take a snapshot of a contract file and save it to .ai/contracts/<name>.lock.
|
|
542
|
+
* Returns the snapshot.
|
|
543
|
+
*/
|
|
544
|
+
declare function snapshotContract(projectRoot: string, haiveDir: string, contract: ContractFile): Promise<ContractSnapshot>;
|
|
545
|
+
/**
|
|
546
|
+
* Compare a contract file against its stored snapshot.
|
|
547
|
+
* Returns the diff result. If no snapshot exists, creates one and returns unchanged.
|
|
548
|
+
*/
|
|
549
|
+
declare function diffContract(projectRoot: string, haiveDir: string, contract: ContractFile): Promise<ContractDiffResult>;
|
|
550
|
+
/**
|
|
551
|
+
* Check all configured contract files for changes.
|
|
552
|
+
*/
|
|
553
|
+
declare function watchContracts(projectRoot: string, haiveDir: string, contractFiles: ContractFile[]): Promise<ContractDiffResult[]>;
|
|
554
|
+
|
|
555
|
+
export { AUTOPILOT_DEFAULTS, type Anchor, AnchorSchema, type AutoPromoteRule, type BreakingChange, type BudgetPart, type BudgetSlice, type BuildCodeMapOptions, CHARS_PER_TOKEN, CODE_MAP_FILE, CONFIG_FILE, type CodeExport, type CodeExportKind, type CodeFileEntry, type CodeMap, type CodeMapQueryOptions, type ConfidenceLevel, type ConfidenceThresholds, type ContractDiffResult, type ContractFile, type ContractSnapshot, CrossRepoProvenanceSchema, type CrossRepoReport, type CrossRepoSource, DECAY_DAYS, DEFAULT_AUTO_PROMOTE_RULE, DEFAULT_CONFIDENCE_THRESHOLDS, DEFAULT_CONFIG, type DepChange, type DepTrackResult, type DependencySnapshot, HAIVE_DIR, type HaiveConfig, type HaivePaths, type LoadedMemory, MEMORIES_DIR, type Memory, type MemoryFrontmatter, MemoryFrontmatterSchema, type MemoryScope, MemoryScopeSchema, type MemoryStatus, MemoryStatusSchema, type MemoryType, MemoryTypeSchema, type MemoryUsage, PROJECT_CONTEXT_FILE, type TruncateOptions, type TruncateResult, USAGE_FILE, type UsageIndex, type VerifyOptions, type VerifyResult, allocateBudget, buildCodeMap, buildFrontmatter, bumpRead, codeMapPath, configPath, contractLockPath, deriveConfidence, diffContract, emptyUsage, emptyUsageIndex, estimateTokens, extractSnippet, findProjectRoot, getUsage, inferModulesFromPaths, isAutoPromoteEligible, isDecaying, listMarkdownFilesRecursive, literalMatchesAllTokens, literalMatchesAnyToken, loadCodeMap, loadConfig, loadMemoriesFromDir, loadMemory, loadUsageIndex, memoryFilePath, memoryMatchesAnchorPaths, newMemoryId, parseMemory, pathsOverlap, pickSnippetNeedle, pullCrossRepoSources, queryCodeMap, recordRejection, relPathFrom, resolveHaivePaths, resolveManifestFiles, saveCodeMap, saveConfig, saveUsageIndex, serializeMemory, snapshotContract, stripPrivate, tokenizeQuery, trackDependencies, trackReads, truncateToTokens, usagePath, verifyAnchor, watchContracts };
|