hafez 1.2.0 → 1.4.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.
Files changed (52) hide show
  1. package/README.md +67 -9
  2. package/dist/apply.d.ts +30 -0
  3. package/dist/apply.js +582 -0
  4. package/dist/batch-ops.d.ts +470 -0
  5. package/dist/batch-ops.js +446 -0
  6. package/dist/cli/args.d.ts +19 -0
  7. package/dist/cli/args.js +53 -0
  8. package/dist/cli/batch-errors.js +6 -3
  9. package/dist/cli/commands.d.ts +24 -108
  10. package/dist/cli/commands.js +297 -313
  11. package/dist/cli/help-agent.d.ts +0 -5
  12. package/dist/cli/help-agent.js +44 -5
  13. package/dist/cli/index.d.ts +41 -0
  14. package/dist/cli/index.js +172 -172
  15. package/dist/cli/resolve-vault.js +2 -1
  16. package/dist/cli/schema-introspect.d.ts +1 -1
  17. package/dist/cli/schema-introspect.js +6 -22
  18. package/dist/cli/upgrade.d.ts +42 -0
  19. package/dist/cli/upgrade.js +305 -0
  20. package/dist/cli.js +0 -0
  21. package/dist/contracts.d.ts +55 -6
  22. package/dist/contracts.js +110 -23
  23. package/dist/dates.d.ts +10 -0
  24. package/dist/dates.js +27 -0
  25. package/dist/db.d.ts +27 -2
  26. package/dist/db.js +318 -56
  27. package/dist/digest.js +2 -0
  28. package/dist/document.d.ts +117 -0
  29. package/dist/document.js +578 -0
  30. package/dist/export-okf.js +48 -34
  31. package/dist/git.d.ts +7 -8
  32. package/dist/git.js +198 -63
  33. package/dist/index.d.ts +3 -4
  34. package/dist/index.js +302 -915
  35. package/dist/knowledge-index.d.ts +23 -1
  36. package/dist/knowledge-index.js +71 -13
  37. package/dist/merge.d.ts +1 -1
  38. package/dist/merge.js +106 -86
  39. package/dist/schema.js +4 -4
  40. package/dist/templates.d.ts +6 -0
  41. package/dist/templates.js +27 -27
  42. package/dist/types.d.ts +86 -12
  43. package/dist/vault.d.ts +51 -6
  44. package/dist/vault.js +114 -11
  45. package/package.json +2 -2
  46. package/skill/SKILL.md +51 -110
  47. package/dist/parser.d.ts +0 -18
  48. package/dist/parser.js +0 -68
  49. package/dist/query.d.ts +0 -24
  50. package/dist/query.js +0 -167
  51. package/dist/sections.d.ts +0 -54
  52. package/dist/sections.js +0 -297
@@ -0,0 +1,117 @@
1
+ import type { SessionLogEntry, SessionLogType } from './types.js';
2
+ export declare function parseSessionLogHeading(line: string): {
3
+ date: string;
4
+ agent: string;
5
+ type: SessionLogType;
6
+ } | null;
7
+ export declare function formatSessionLogEntry(entry: SessionLogEntry): string;
8
+ /**
9
+ * Split a Session Log section's content into raw entry blocks, each beginning
10
+ * with a parseable entry heading. Non-entry text before the first heading is
11
+ * not an entry and is dropped. Document owns entry block splitting — merge's
12
+ * dedup/sort policy stays in merge.ts.
13
+ */
14
+ export declare function splitLogEntries(content: string): string[];
15
+ export declare function firstNonEmptyLine(s: string | null | undefined): string;
16
+ /** The one wiki-link syntax the vault recognizes: [[slug]] or
17
+ * [[slug|display text]] — slug in group 1, display text in group 2.
18
+ * Padding inside the brackets is Obsidian-idiomatic ([[ slug ]], [[slug | Label]])
19
+ * and is absorbed by the pattern, so both captures come out already trimmed —
20
+ * every consumer (Related coverage, mention harvesting, export) sees the bare slug.
21
+ * Non-global — wrap with `new RegExp(WIKI_LINK_RE.source, 'g')` for iteration. */
22
+ export declare const WIKI_LINK_RE: RegExp;
23
+ /** What documentFor needs to know about a file to bind its section set.
24
+ *
25
+ * KIND is the whole context — deliberately no type/subtype narrowing. A file
26
+ * can legitimately carry sections outside its current type's contract (a
27
+ * promote race merged in a capture's Notes, a plan-shaped note never had its
28
+ * subtype persisted, a hand edit added Open Questions to a plain entity), and
29
+ * a narrower binding demotes those headings to non-structural text that the
30
+ * next section rewrite silently deletes. The kind-level union makes every
31
+ * same-kind heading a boundary, so no same-kind section is ever swallowed;
32
+ * the cost is that a same-kind heading quoted at line start inside a section
33
+ * strands as its own section on rewrite — visible and recoverable, unlike
34
+ * deletion. Cross-KIND headings (a session-only ## Decisions quoted in an
35
+ * entity Brief) are still not boundaries. */
36
+ export interface DocContext {
37
+ kind: 'entity' | 'knowledge' | 'session';
38
+ }
39
+ /** The structural set a context binds — exposed for introspection and the
40
+ * contract-coverage tests; runtime consumers go through documentFor. */
41
+ export declare function structuralSectionsFor(ctx: DocContext): ReadonlySet<string>;
42
+ /** The Document operations bound to one file's structural section set. */
43
+ export declare function documentFor(ctx: DocContext): Doc;
44
+ /** Bind from a parsed vault file — kind from Layout. */
45
+ export declare function documentForFile(parsed: {
46
+ kind: 'entity' | 'knowledge' | 'session';
47
+ }): Doc;
48
+ export interface DocSection {
49
+ heading: string;
50
+ content: string;
51
+ }
52
+ export interface Doc {
53
+ findNextStructuralHeading(body: string, from: number): number;
54
+ findSection(body: string, heading: string): {
55
+ start: number;
56
+ headingEnd: number;
57
+ end: number;
58
+ content: string;
59
+ } | null;
60
+ splitStructural(body: string): {
61
+ preamble: string;
62
+ sections: DocSection[];
63
+ };
64
+ setSection(body: string, heading: string, content: string, insertBefore?: string): string;
65
+ appendToSection(body: string, heading: string, content: string): string;
66
+ renameSection(body: string, from: string, to: string): string;
67
+ ensureSection(body: string, heading: string, opts?: {
68
+ after?: string;
69
+ }): string;
70
+ prependSessionLogEntry(body: string, entry: string): string;
71
+ bodyBeforeSessionLog(body: string): string;
72
+ countSessionLogEntries(body: string): number;
73
+ parseSessionLog(body: string): Array<{
74
+ date: string;
75
+ agent: string;
76
+ type: SessionLogType;
77
+ summary: string;
78
+ }>;
79
+ extractOldestSessionLogEntry(body: string): {
80
+ entry: string;
81
+ remaining: string;
82
+ } | null;
83
+ getBrief(body: string): string | null;
84
+ setBrief(body: string, content: string): string;
85
+ removeBrief(body: string): string;
86
+ getNextActions(body: string): string[];
87
+ addNextAction(body: string, action: string): string;
88
+ completeNextAction(body: string, query: string): {
89
+ matched: string;
90
+ body: string;
91
+ };
92
+ removeNextAction(body: string, query: string): {
93
+ matched: string;
94
+ body: string;
95
+ };
96
+ clearNextActions(body: string): string;
97
+ syncRelatedSection(body: string, frontmatter: {
98
+ parent?: string;
99
+ related?: string[];
100
+ }): string;
101
+ }
102
+ export declare function getBrief(body: string): string | null;
103
+ export declare function getNextActions(body: string): string[];
104
+ export declare function parseSessionLog(body: string): Array<{
105
+ date: string;
106
+ agent: string;
107
+ type: SessionLogType;
108
+ summary: string;
109
+ }>;
110
+ export declare function countSessionLogEntries(body: string): number;
111
+ /**
112
+ * One-line summary for a doc: frontmatter description first, then the first
113
+ * non-empty line of the kind's primary section (entity: Brief; knowledge:
114
+ * Synthesis, falling back to Goal for plans; session: Summary).
115
+ * Shared by the vault index and the OKF export so the two surfaces agree.
116
+ */
117
+ export declare function deriveSummary(kind: 'entity' | 'knowledge' | 'session', fm: Record<string, any>, body: string): string;