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
@@ -1,16 +1,37 @@
1
- import { z } from 'zod';
1
+ import { type FlagSpec } from './args.js';
2
2
  import type { Hafez, BatchOperation } from '../types.js';
3
3
  export interface CommandOpts {
4
4
  json?: boolean;
5
+ /** Resolved vault path — for handlers that read the vault directly
6
+ * (export) rather than through the Hafez instance. */
7
+ vaultPath?: string;
5
8
  }
6
9
  export declare function cmdRead(os: Hafez, args: string[], opts?: CommandOpts): Promise<string>;
10
+ /** Every flag the query parser accepts, for the branch-support matrix. */
11
+ export declare const QUERY_FLAG_NAMES: string[];
12
+ export type QueryBranch = 'entity' | 'knowledge' | 'all' | 'related-to';
13
+ /** Which flags each kind branch actually applies. A branch that cannot honour
14
+ * a flag rejects it (below) instead of dropping it: `--kind knowledge --filter
15
+ * stale` used to return every knowledge note with exit 0, and `--confidence`
16
+ * never reached an entity query at all. */
17
+ export declare const QUERY_FLAG_SUPPORT: Record<QueryBranch, readonly string[]>;
7
18
  export declare function cmdQuery(os: Hafez, args: string[], opts?: CommandOpts): Promise<string>;
8
19
  export declare function cmdSearch(os: Hafez, args: string[], opts?: CommandOpts): Promise<string>;
20
+ /** Exported so tests can assert the flag × kind matrix is exhaustive. */
21
+ export declare const CREATE_FLAGS: FlagSpec;
9
22
  export declare function cmdCreate(os: Hafez, args: string[], opts?: CommandOpts): Promise<string>;
23
+ /** Exported so tests can assert the table covers the update schema. */
24
+ export declare const UPDATE_FLAGS: FlagSpec;
25
+ /** Flags the generic loop skips because they are not a field of the update
26
+ * shape — each is hand-handled in cmdUpdate. */
27
+ export declare const UPDATE_SPECIAL_FLAGS: Set<string>;
28
+ /** Update-shape fields with no flag of their own, and why. The exhaustiveness
29
+ * test consults this, so a gap here is a stated decision rather than the
30
+ * silent hole `add_actions` was. */
31
+ export declare const UPDATE_FIELDS_WITHOUT_FLAGS: Record<string, string>;
10
32
  export declare function cmdUpdate(os: Hafez, args: string[], opts?: CommandOpts): Promise<string>;
11
33
  export declare function cmdLink(os: Hafez, args: string[], opts?: CommandOpts): Promise<string>;
12
34
  export declare function cmdUnlink(os: Hafez, args: string[], opts?: CommandOpts): Promise<string>;
13
- /** Top-level capture command — aligns the CLI verb with the batch op name. */
14
35
  export declare function cmdCapture(os: Hafez, args: string[], opts?: CommandOpts): Promise<string>;
15
36
  export declare function cmdPromote(os: Hafez, args: string[], opts?: CommandOpts): Promise<string>;
16
37
  export declare function cmdValidate(os: Hafez, _args: string[], opts?: CommandOpts): Promise<string>;
@@ -18,112 +39,7 @@ export declare function cmdIndexRebuild(os: Hafez): Promise<string>;
18
39
  export declare function cmdSync(os: Hafez, _args: string[]): Promise<string>;
19
40
  export declare function cmdStats(os: Hafez, _args: string[], opts?: CommandOpts): Promise<string>;
20
41
  export declare function cmdChangelog(os: Hafez, args: string[], opts?: CommandOpts): Promise<string>;
21
- export declare const SessionLogSchema: z.ZodObject<{
22
- type: z.ZodEnum<{
23
- [x: string]: string;
24
- }>;
25
- summary: z.ZodString;
26
- body: z.ZodOptional<z.ZodString>;
27
- agent: z.ZodString;
28
- }, z.core.$strict>;
29
- export declare const UpdateFieldsSchema: z.ZodObject<{
30
- status: z.ZodOptional<z.ZodEnum<{
31
- [x: string]: string;
32
- }>>;
33
- current_state: z.ZodOptional<z.ZodString>;
34
- session_log: z.ZodOptional<z.ZodObject<{
35
- type: z.ZodEnum<{
36
- [x: string]: string;
37
- }>;
38
- summary: z.ZodString;
39
- body: z.ZodOptional<z.ZodString>;
40
- agent: z.ZodString;
41
- }, z.core.$strict>>;
42
- brief: z.ZodOptional<z.ZodNullable<z.ZodString>>;
43
- add_action: z.ZodOptional<z.ZodString>;
44
- add_actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
45
- complete_action: z.ZodOptional<z.ZodString>;
46
- remove_action: z.ZodOptional<z.ZodString>;
47
- clear_actions: z.ZodOptional<z.ZodBoolean>;
48
- description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
49
- resource: z.ZodOptional<z.ZodNullable<z.ZodString>>;
50
- domain: z.ZodOptional<z.ZodArray<z.ZodString>>;
51
- confidence: z.ZodOptional<z.ZodEnum<{
52
- [x: string]: string;
53
- }>>;
54
- tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
55
- related: z.ZodOptional<z.ZodArray<z.ZodString>>;
56
- synthesis: z.ZodOptional<z.ZodString>;
57
- insight: z.ZodOptional<z.ZodString>;
58
- add_evidence: z.ZodOptional<z.ZodString>;
59
- add_source: z.ZodOptional<z.ZodString>;
60
- }, z.core.$strict>;
61
- export declare const BatchOperationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
62
- op: z.ZodLiteral<"update">;
63
- slug: z.ZodString;
64
- fields: z.ZodObject<{
65
- status: z.ZodOptional<z.ZodEnum<{
66
- [x: string]: string;
67
- }>>;
68
- current_state: z.ZodOptional<z.ZodString>;
69
- session_log: z.ZodOptional<z.ZodObject<{
70
- type: z.ZodEnum<{
71
- [x: string]: string;
72
- }>;
73
- summary: z.ZodString;
74
- body: z.ZodOptional<z.ZodString>;
75
- agent: z.ZodString;
76
- }, z.core.$strict>>;
77
- brief: z.ZodOptional<z.ZodNullable<z.ZodString>>;
78
- add_action: z.ZodOptional<z.ZodString>;
79
- add_actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
80
- complete_action: z.ZodOptional<z.ZodString>;
81
- remove_action: z.ZodOptional<z.ZodString>;
82
- clear_actions: z.ZodOptional<z.ZodBoolean>;
83
- description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
84
- resource: z.ZodOptional<z.ZodNullable<z.ZodString>>;
85
- domain: z.ZodOptional<z.ZodArray<z.ZodString>>;
86
- confidence: z.ZodOptional<z.ZodEnum<{
87
- [x: string]: string;
88
- }>>;
89
- tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
90
- related: z.ZodOptional<z.ZodArray<z.ZodString>>;
91
- synthesis: z.ZodOptional<z.ZodString>;
92
- insight: z.ZodOptional<z.ZodString>;
93
- add_evidence: z.ZodOptional<z.ZodString>;
94
- add_source: z.ZodOptional<z.ZodString>;
95
- }, z.core.$strict>;
96
- }, z.core.$strict>, z.ZodObject<{
97
- op: z.ZodLiteral<"create">;
98
- }, z.core.$strip>, z.ZodObject<{
99
- op: z.ZodLiteral<"capture">;
100
- name: z.ZodString;
101
- notes: z.ZodOptional<z.ZodString>;
102
- }, z.core.$strict>, z.ZodObject<{
103
- op: z.ZodLiteral<"link">;
104
- slug: z.ZodString;
105
- target: z.ZodString;
106
- relation: z.ZodEnum<{
107
- parent: "parent";
108
- related: "related";
109
- }>;
110
- }, z.core.$strict>, z.ZodObject<{
111
- op: z.ZodLiteral<"unlink">;
112
- slug: z.ZodString;
113
- target: z.ZodString;
114
- relation: z.ZodEnum<{
115
- parent: "parent";
116
- related: "related";
117
- }>;
118
- }, z.core.$strict>, z.ZodObject<{
119
- op: z.ZodLiteral<"promote">;
120
- slug: z.ZodString;
121
- target: z.ZodEnum<{
122
- entity: "entity";
123
- project: "project";
124
- knowledge: "knowledge";
125
- }>;
126
- }, z.core.$strict>], "op">;
127
42
  export declare function parseBatchInput(json: string): BatchOperation[];
128
43
  export declare function cmdBatch(os: Hafez, args: string[], opts?: CommandOpts): Promise<string>;
129
44
  export declare function cmdDigest(os: Hafez, args: string[], _opts?: CommandOpts): Promise<string>;
45
+ export declare function cmdExport(_os: Hafez, args: string[], opts?: CommandOpts): Promise<string>;