hafez 1.0.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/LICENSE +21 -0
- package/README.md +190 -0
- package/dist/cli/batch-errors.d.ts +24 -0
- package/dist/cli/batch-errors.js +236 -0
- package/dist/cli/commands-schema.d.ts +3 -0
- package/dist/cli/commands-schema.js +80 -0
- package/dist/cli/commands.d.ts +133 -0
- package/dist/cli/commands.js +628 -0
- package/dist/cli/format.d.ts +9 -0
- package/dist/cli/format.js +158 -0
- package/dist/cli/help-agent.d.ts +6 -0
- package/dist/cli/help-agent.js +158 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +304 -0
- package/dist/cli/resolve-vault.d.ts +13 -0
- package/dist/cli/resolve-vault.js +124 -0
- package/dist/cli/schema-introspect.d.ts +70 -0
- package/dist/cli/schema-introspect.js +372 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +3 -0
- package/dist/contracts.d.ts +26 -0
- package/dist/contracts.js +87 -0
- package/dist/db.d.ts +68 -0
- package/dist/db.js +663 -0
- package/dist/digest.d.ts +29 -0
- package/dist/digest.js +94 -0
- package/dist/export-okf.d.ts +12 -0
- package/dist/export-okf.js +176 -0
- package/dist/git.d.ts +12 -0
- package/dist/git.js +355 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +909 -0
- package/dist/knowledge-index.d.ts +3 -0
- package/dist/knowledge-index.js +135 -0
- package/dist/merge.d.ts +1 -0
- package/dist/merge.js +176 -0
- package/dist/migrate-knowledge-v2.d.ts +11 -0
- package/dist/migrate-knowledge-v2.js +158 -0
- package/dist/migrate-next-actions.d.ts +6 -0
- package/dist/migrate-next-actions.js +32 -0
- package/dist/migrate-types.d.ts +11 -0
- package/dist/migrate-types.js +142 -0
- package/dist/parser.d.ts +18 -0
- package/dist/parser.js +68 -0
- package/dist/query.d.ts +24 -0
- package/dist/query.js +167 -0
- package/dist/schema.d.ts +9 -0
- package/dist/schema.js +59 -0
- package/dist/sections.d.ts +54 -0
- package/dist/sections.js +297 -0
- package/dist/templates.d.ts +8 -0
- package/dist/templates.js +39 -0
- package/dist/types.d.ts +321 -0
- package/dist/types.js +11 -0
- package/dist/vault.d.ts +12 -0
- package/dist/vault.js +45 -0
- package/package.json +67 -0
- package/skill/SKILL.md +190 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const CAPTURE = {
|
|
2
|
+
type: 'capture',
|
|
3
|
+
description: 'Quick capture. A link, a thought, a bug report. No structure required — just get it in.',
|
|
4
|
+
kind: 'item',
|
|
5
|
+
requiredFields: ['name', 'type', 'status', 'created', 'last-touched'],
|
|
6
|
+
optionalFields: ['domain', 'tags'],
|
|
7
|
+
validStatuses: ['active', 'done'],
|
|
8
|
+
defaultSections: ['Notes'],
|
|
9
|
+
// Brief/Next Actions: the CLI never type-gated setBrief/addNextAction, so captures
|
|
10
|
+
// carrying a delivery brief and actions are established practice — the contract
|
|
11
|
+
// follows observed behaviour (decided 2026-07-19).
|
|
12
|
+
optionalSections: ['Session Log', 'Brief', 'Next Actions'],
|
|
13
|
+
canPromoteTo: ['entity', 'project', 'knowledge'],
|
|
14
|
+
};
|
|
15
|
+
const ENTITY = {
|
|
16
|
+
type: 'entity',
|
|
17
|
+
description: 'Tracked work with substance. A bug, feature, decision, or task. The atomic unit of work.',
|
|
18
|
+
kind: 'item',
|
|
19
|
+
requiredFields: ['name', 'type', 'status', 'created', 'last-touched'],
|
|
20
|
+
optionalFields: ['domain', 'parent', 'related', 'tags', 'staleness-days'],
|
|
21
|
+
validStatuses: ['active', 'paused', 'done'],
|
|
22
|
+
defaultSections: ['Context', 'Session Log'],
|
|
23
|
+
optionalSections: ['Brief', 'Next Actions', 'Current State'],
|
|
24
|
+
canPromoteTo: ['project'],
|
|
25
|
+
};
|
|
26
|
+
const PROJECT = {
|
|
27
|
+
type: 'project',
|
|
28
|
+
description: 'Scoped effort with goals and deliverables. Can have children. Can be finite or perpetual.',
|
|
29
|
+
kind: 'item',
|
|
30
|
+
requiredFields: ['name', 'type', 'status', 'created', 'last-touched'],
|
|
31
|
+
optionalFields: ['domain', 'parent', 'related', 'tags', 'staleness-days'],
|
|
32
|
+
validStatuses: ['active', 'paused', 'done'],
|
|
33
|
+
defaultSections: ['Purpose', 'Goals', 'Session Log'],
|
|
34
|
+
optionalSections: ['Brief', 'Next Actions', 'Current State', 'Open Questions'],
|
|
35
|
+
canPromoteTo: [],
|
|
36
|
+
};
|
|
37
|
+
const KNOWLEDGE = {
|
|
38
|
+
type: 'knowledge',
|
|
39
|
+
description: 'Insight or plan. Searchable, linkable, timestamped. Insights mature through reinforcement.',
|
|
40
|
+
kind: 'knowledge',
|
|
41
|
+
requiredFields: ['name', 'created'],
|
|
42
|
+
optionalFields: ['subtype', 'domain', 'related', 'tags', 'confidence', 'reinforcement-count', 'last-reinforced', 'session-date', 'status', 'last-touched'],
|
|
43
|
+
validStatuses: [],
|
|
44
|
+
defaultSections: ['Synthesis', 'Evidence', 'Sources'],
|
|
45
|
+
optionalSections: [],
|
|
46
|
+
canPromoteTo: [],
|
|
47
|
+
};
|
|
48
|
+
const CONTRACT_MAP = {
|
|
49
|
+
capture: CAPTURE,
|
|
50
|
+
entity: ENTITY,
|
|
51
|
+
project: PROJECT,
|
|
52
|
+
knowledge: KNOWLEDGE,
|
|
53
|
+
};
|
|
54
|
+
export const ALL_CONTRACTS = [CAPTURE, ENTITY, PROJECT, KNOWLEDGE];
|
|
55
|
+
export function getContract(type) {
|
|
56
|
+
const contract = CONTRACT_MAP[type];
|
|
57
|
+
if (!contract)
|
|
58
|
+
throw new Error(`Unknown type: ${type}. Valid types: ${Object.keys(CONTRACT_MAP).join(', ')}`);
|
|
59
|
+
return contract;
|
|
60
|
+
}
|
|
61
|
+
export function hasCapability(type, section) {
|
|
62
|
+
const contract = getContract(type);
|
|
63
|
+
return contract.defaultSections.includes(section) || contract.optionalSections.includes(section);
|
|
64
|
+
}
|
|
65
|
+
// --- Canonical enum tuples (single source of truth) ---
|
|
66
|
+
// Every consumer (file validators, CLI input validator, help renderer) imports these.
|
|
67
|
+
// The cli-schema-parity test enforces that no other file declares local copies.
|
|
68
|
+
export const ENTITY_TYPES = ['capture', 'entity', 'project'];
|
|
69
|
+
export const ENTITY_STATUSES = ['active', 'paused', 'done'];
|
|
70
|
+
export const SESSION_LOG_TYPES = ['progress', 'decision', 'blocker', 'research'];
|
|
71
|
+
export const CONFIDENCE_LEVELS = ['observation', 'pattern', 'principle'];
|
|
72
|
+
// 'insight' is the subtype (frontmatter classification), 'Synthesis' is the section heading.
|
|
73
|
+
// The rename was insight→synthesis for the section/field only; the subtype stays 'insight'.
|
|
74
|
+
export const VALID_SUBTYPES = ['insight', 'plan'];
|
|
75
|
+
// --- Alias table ---
|
|
76
|
+
// Declared-alias fields that parseBatchInput normalizes to their canonical name.
|
|
77
|
+
// schema-introspect cannot infer these from Zod alone (both are declared .optional()),
|
|
78
|
+
// so rendering code reads this table to strip aliased keys from user-facing output.
|
|
79
|
+
export const ALIAS_KEYS = {
|
|
80
|
+
'update.fields.insight': 'synthesis',
|
|
81
|
+
'create.knowledge.fields.insight': 'synthesis',
|
|
82
|
+
'create.session.fields.insight': 'synthesis',
|
|
83
|
+
};
|
|
84
|
+
export const SUBTYPE_SECTIONS = {
|
|
85
|
+
insight: ['Synthesis', 'Evidence', 'Sources'],
|
|
86
|
+
plan: ['Goal', 'Steps', 'Dependencies'],
|
|
87
|
+
};
|
package/dist/db.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { SearchResult, VaultStats } from './types.js';
|
|
2
|
+
export declare const SCHEMA_VERSION = "7";
|
|
3
|
+
interface IndexItem {
|
|
4
|
+
slug: string;
|
|
5
|
+
kind: 'entity' | 'knowledge';
|
|
6
|
+
name: string;
|
|
7
|
+
type: string | null;
|
|
8
|
+
status: string | null;
|
|
9
|
+
parent: string | null;
|
|
10
|
+
next_action: string | null;
|
|
11
|
+
next_action_count: number;
|
|
12
|
+
staleness_days: number | null;
|
|
13
|
+
confidence: string | null;
|
|
14
|
+
reinforcement_count: number | null;
|
|
15
|
+
last_reinforced: string | null;
|
|
16
|
+
created: string;
|
|
17
|
+
last_touched: string | null;
|
|
18
|
+
body: string;
|
|
19
|
+
file_hash: string;
|
|
20
|
+
subtype: string | null;
|
|
21
|
+
description: string | null;
|
|
22
|
+
resource: string | null;
|
|
23
|
+
brief: string | null;
|
|
24
|
+
session_log_count: number;
|
|
25
|
+
last_session_date: string | null;
|
|
26
|
+
last_session_type: string | null;
|
|
27
|
+
last_session_summary: string | null;
|
|
28
|
+
}
|
|
29
|
+
export interface IndexQueryResult {
|
|
30
|
+
items: IndexItem[];
|
|
31
|
+
total: number;
|
|
32
|
+
}
|
|
33
|
+
export interface HafezIndex {
|
|
34
|
+
rebuild(): void;
|
|
35
|
+
syncIfStale(): void;
|
|
36
|
+
upsertFromFile(slug: string, kind: 'entity' | 'knowledge'): void;
|
|
37
|
+
removeItem(slug: string): void;
|
|
38
|
+
queryItems(opts: QueryOpts): IndexQueryResult;
|
|
39
|
+
search(query: string, kind?: 'entity' | 'knowledge' | 'all'): SearchResult[];
|
|
40
|
+
getStats(): VaultStats;
|
|
41
|
+
close(): void;
|
|
42
|
+
}
|
|
43
|
+
export interface QueryOpts {
|
|
44
|
+
kind?: 'entity' | 'knowledge' | 'all';
|
|
45
|
+
status?: string;
|
|
46
|
+
type?: string;
|
|
47
|
+
subtype?: string;
|
|
48
|
+
parent?: string;
|
|
49
|
+
relatedTo?: string;
|
|
50
|
+
relation?: string;
|
|
51
|
+
domain?: string;
|
|
52
|
+
confidence?: string;
|
|
53
|
+
filter?: string;
|
|
54
|
+
since?: string;
|
|
55
|
+
before?: string;
|
|
56
|
+
createdSince?: string;
|
|
57
|
+
createdBefore?: string;
|
|
58
|
+
tags?: string[];
|
|
59
|
+
sort_by?: 'last_touched' | 'created' | 'name' | 'staleness' | 'last_reinforced' | 'reinforcement_count';
|
|
60
|
+
sort_order?: 'asc' | 'desc';
|
|
61
|
+
limit?: number;
|
|
62
|
+
offset?: number;
|
|
63
|
+
}
|
|
64
|
+
export declare function createIndex(vaultPath: string): HafezIndex;
|
|
65
|
+
export declare function createIndex(vaultPath: string, opts: {
|
|
66
|
+
readonly: true;
|
|
67
|
+
}): HafezIndex | null;
|
|
68
|
+
export {};
|