@cad0p/napkin 0.8.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.
Files changed (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +342 -0
  3. package/dist/commands/aliases.d.ts +7 -0
  4. package/dist/commands/aliases.js +25 -0
  5. package/dist/commands/bases.d.ts +23 -0
  6. package/dist/commands/bases.js +139 -0
  7. package/dist/commands/bookmarks.d.ts +15 -0
  8. package/dist/commands/bookmarks.js +51 -0
  9. package/dist/commands/canvas.d.ts +49 -0
  10. package/dist/commands/canvas.js +186 -0
  11. package/dist/commands/config.d.ts +13 -0
  12. package/dist/commands/config.js +48 -0
  13. package/dist/commands/crud.d.ts +40 -0
  14. package/dist/commands/crud.js +195 -0
  15. package/dist/commands/daily.d.ts +20 -0
  16. package/dist/commands/daily.js +58 -0
  17. package/dist/commands/files.d.ts +23 -0
  18. package/dist/commands/files.js +132 -0
  19. package/dist/commands/graph.d.ts +4 -0
  20. package/dist/commands/graph.js +461 -0
  21. package/dist/commands/init.d.ts +7 -0
  22. package/dist/commands/init.js +52 -0
  23. package/dist/commands/links.d.ts +26 -0
  24. package/dist/commands/links.js +119 -0
  25. package/dist/commands/outline.d.ts +7 -0
  26. package/dist/commands/outline.js +48 -0
  27. package/dist/commands/overview.d.ts +6 -0
  28. package/dist/commands/overview.js +40 -0
  29. package/dist/commands/properties.d.ts +24 -0
  30. package/dist/commands/properties.js +115 -0
  31. package/dist/commands/search.d.ts +13 -0
  32. package/dist/commands/search.js +48 -0
  33. package/dist/commands/tags.d.ts +13 -0
  34. package/dist/commands/tags.js +51 -0
  35. package/dist/commands/tasks.d.ts +22 -0
  36. package/dist/commands/tasks.js +106 -0
  37. package/dist/commands/templates.d.ts +16 -0
  38. package/dist/commands/templates.js +70 -0
  39. package/dist/commands/vault.d.ts +4 -0
  40. package/dist/commands/vault.js +17 -0
  41. package/dist/commands/wordcount.d.ts +7 -0
  42. package/dist/commands/wordcount.js +43 -0
  43. package/dist/core/aliases.d.ts +5 -0
  44. package/dist/core/aliases.js +26 -0
  45. package/dist/core/bases.d.ts +29 -0
  46. package/dist/core/bases.js +67 -0
  47. package/dist/core/bookmarks.d.ts +14 -0
  48. package/dist/core/bookmarks.js +34 -0
  49. package/dist/core/canvas.d.ts +74 -0
  50. package/dist/core/canvas.js +125 -0
  51. package/dist/core/config.d.ts +7 -0
  52. package/dist/core/config.js +35 -0
  53. package/dist/core/crud.d.ts +32 -0
  54. package/dist/core/crud.js +119 -0
  55. package/dist/core/daily.d.ts +12 -0
  56. package/dist/core/daily.js +102 -0
  57. package/dist/core/files.d.ts +15 -0
  58. package/dist/core/files.js +30 -0
  59. package/dist/core/init.d.ts +31 -0
  60. package/dist/core/init.js +119 -0
  61. package/dist/core/links.d.ts +11 -0
  62. package/dist/core/links.js +66 -0
  63. package/dist/core/outline.d.ts +3 -0
  64. package/dist/core/outline.js +12 -0
  65. package/dist/core/overview.d.ts +15 -0
  66. package/dist/core/overview.js +384 -0
  67. package/dist/core/properties.d.ts +14 -0
  68. package/dist/core/properties.js +60 -0
  69. package/dist/core/search.d.ts +17 -0
  70. package/dist/core/search.js +153 -0
  71. package/dist/core/tags.d.ts +11 -0
  72. package/dist/core/tags.js +40 -0
  73. package/dist/core/tasks.d.ts +35 -0
  74. package/dist/core/tasks.js +97 -0
  75. package/dist/core/templates.d.ts +14 -0
  76. package/dist/core/templates.js +55 -0
  77. package/dist/core/vault.d.ts +10 -0
  78. package/dist/core/vault.js +37 -0
  79. package/dist/core/wordcount.d.ts +5 -0
  80. package/dist/core/wordcount.js +16 -0
  81. package/dist/index.d.ts +17 -0
  82. package/dist/index.js +1 -0
  83. package/dist/main.d.ts +2 -0
  84. package/dist/main.js +715 -0
  85. package/dist/sdk.d.ts +179 -0
  86. package/dist/sdk.js +232 -0
  87. package/dist/templates/coding.d.ts +2 -0
  88. package/dist/templates/coding.js +104 -0
  89. package/dist/templates/company.d.ts +2 -0
  90. package/dist/templates/company.js +121 -0
  91. package/dist/templates/index.d.ts +4 -0
  92. package/dist/templates/index.js +15 -0
  93. package/dist/templates/personal.d.ts +2 -0
  94. package/dist/templates/personal.js +91 -0
  95. package/dist/templates/product.d.ts +2 -0
  96. package/dist/templates/product.js +123 -0
  97. package/dist/templates/research.d.ts +2 -0
  98. package/dist/templates/research.js +114 -0
  99. package/dist/templates/types.d.ts +7 -0
  100. package/dist/templates/types.js +1 -0
  101. package/dist/utils/bases.d.ts +61 -0
  102. package/dist/utils/bases.js +661 -0
  103. package/dist/utils/config.d.ts +42 -0
  104. package/dist/utils/config.js +112 -0
  105. package/dist/utils/exit-codes.d.ts +5 -0
  106. package/dist/utils/exit-codes.js +5 -0
  107. package/dist/utils/files.d.ts +135 -0
  108. package/dist/utils/files.js +299 -0
  109. package/dist/utils/formula.d.ts +28 -0
  110. package/dist/utils/formula.js +462 -0
  111. package/dist/utils/frontmatter.d.ts +17 -0
  112. package/dist/utils/frontmatter.js +34 -0
  113. package/dist/utils/markdown.d.ts +31 -0
  114. package/dist/utils/markdown.js +80 -0
  115. package/dist/utils/output.d.ts +28 -0
  116. package/dist/utils/output.js +48 -0
  117. package/dist/utils/search-cache.d.ts +29 -0
  118. package/dist/utils/search-cache.js +41 -0
  119. package/dist/utils/test-helpers.d.ts +13 -0
  120. package/dist/utils/test-helpers.js +40 -0
  121. package/dist/utils/vault.d.ts +21 -0
  122. package/dist/utils/vault.js +144 -0
  123. package/package.json +76 -0
@@ -0,0 +1,186 @@
1
+ import { Napkin } from "../sdk.js";
2
+ import { EXIT_NOT_FOUND, EXIT_USER_ERROR } from "../utils/exit-codes.js";
3
+ import { bold, dim, error, output, success, } from "../utils/output.js";
4
+ export async function canvases(opts) {
5
+ const n = new Napkin(opts.vault || process.cwd());
6
+ const files = n.canvases();
7
+ output(opts, {
8
+ json: () => (opts.total ? { total: files.length } : { canvases: files }),
9
+ human: () => {
10
+ if (opts.total) {
11
+ console.log(files.length);
12
+ }
13
+ else if (files.length === 0) {
14
+ console.log("No .canvas files found");
15
+ }
16
+ else {
17
+ for (const f of files)
18
+ console.log(f);
19
+ }
20
+ },
21
+ });
22
+ }
23
+ export async function canvasRead(opts) {
24
+ const n = new Napkin(opts.vault || process.cwd());
25
+ if (!opts.file) {
26
+ error("No file specified. Use --file <name>");
27
+ process.exit(EXIT_USER_ERROR);
28
+ }
29
+ let canvas;
30
+ let filePath;
31
+ try {
32
+ ({ canvas, filePath } = n.canvasRead(opts.file));
33
+ }
34
+ catch (e) {
35
+ error(e.message);
36
+ process.exit(EXIT_NOT_FOUND);
37
+ }
38
+ output(opts, {
39
+ json: () => ({ path: filePath, ...canvas }),
40
+ human: () => {
41
+ console.log(bold(filePath));
42
+ console.log(`${canvas.nodes.length} nodes, ${canvas.edges.length} edges`);
43
+ console.log();
44
+ for (const node of canvas.nodes) {
45
+ const desc = node.type === "text"
46
+ ? (node.text?.split("\n")[0] || "").slice(0, 60)
47
+ : node.type === "file"
48
+ ? node.file
49
+ : node.type === "link"
50
+ ? node.url
51
+ : node.type === "group"
52
+ ? node.label || "(unnamed group)"
53
+ : "";
54
+ console.log(` ${dim(node.id.slice(0, 8))} ${node.type.padEnd(6)} ${desc}`);
55
+ }
56
+ if (canvas.edges.length > 0) {
57
+ console.log();
58
+ for (const edge of canvas.edges) {
59
+ const label = edge.label ? ` "${edge.label}"` : "";
60
+ console.log(` ${dim(edge.id.slice(0, 8))} ${edge.fromNode.slice(0, 8)} → ${edge.toNode.slice(0, 8)}${label}`);
61
+ }
62
+ }
63
+ },
64
+ });
65
+ }
66
+ export async function canvasNodes(opts) {
67
+ const n = new Napkin(opts.vault || process.cwd());
68
+ if (!opts.file) {
69
+ error("No file specified. Use --file <name>");
70
+ process.exit(EXIT_USER_ERROR);
71
+ }
72
+ let canvas;
73
+ try {
74
+ ({ canvas } = n.canvasRead(opts.file));
75
+ }
76
+ catch (e) {
77
+ error(e.message);
78
+ process.exit(EXIT_NOT_FOUND);
79
+ }
80
+ let nodes = canvas.nodes;
81
+ if (opts.type) {
82
+ nodes = nodes.filter((n) => n.type === opts.type);
83
+ }
84
+ output(opts, {
85
+ json: () => ({ nodes }),
86
+ human: () => {
87
+ for (const node of nodes) {
88
+ const desc = node.type === "text"
89
+ ? (node.text?.split("\n")[0] || "").slice(0, 60)
90
+ : node.type === "file"
91
+ ? node.file
92
+ : node.type === "link"
93
+ ? node.url
94
+ : node.label || "";
95
+ console.log(`${node.id} ${node.type.padEnd(6)} ${desc}`);
96
+ }
97
+ },
98
+ });
99
+ }
100
+ export async function canvasCreate(opts) {
101
+ const n = new Napkin(opts.vault || process.cwd());
102
+ if (!opts.file) {
103
+ error("No file name specified. Use --file <name>");
104
+ process.exit(EXIT_USER_ERROR);
105
+ }
106
+ let result;
107
+ try {
108
+ result = n.canvasCreate(opts.file, opts.path);
109
+ }
110
+ catch (e) {
111
+ error(e.message);
112
+ process.exit(EXIT_USER_ERROR);
113
+ }
114
+ output(opts, {
115
+ json: () => result,
116
+ human: () => success(`Created ${result.path}`),
117
+ });
118
+ }
119
+ export async function canvasAddNode(opts) {
120
+ const n = new Napkin(opts.vault || process.cwd());
121
+ if (!opts.file) {
122
+ error("No canvas file specified. Use --file <name>");
123
+ process.exit(EXIT_USER_ERROR);
124
+ }
125
+ let result;
126
+ try {
127
+ result = n.canvasAddNode(opts.file, opts);
128
+ }
129
+ catch (e) {
130
+ error(e.message);
131
+ process.exit(EXIT_NOT_FOUND);
132
+ }
133
+ output(opts, {
134
+ json: () => result,
135
+ human: () => success(`Added ${result.type} node ${result.id}`),
136
+ });
137
+ }
138
+ export async function canvasAddEdge(opts) {
139
+ const n = new Napkin(opts.vault || process.cwd());
140
+ if (!opts.file) {
141
+ error("No canvas file specified. Use --file <name>");
142
+ process.exit(EXIT_USER_ERROR);
143
+ }
144
+ if (!opts.from || !opts.to) {
145
+ error("Both --from and --to node IDs required");
146
+ process.exit(EXIT_USER_ERROR);
147
+ }
148
+ let result;
149
+ try {
150
+ result = n.canvasAddEdge(opts.file, {
151
+ from: opts.from,
152
+ to: opts.to,
153
+ fromSide: opts.fromSide,
154
+ toSide: opts.toSide,
155
+ label: opts.label,
156
+ color: opts.color,
157
+ });
158
+ }
159
+ catch (e) {
160
+ error(e.message);
161
+ process.exit(EXIT_NOT_FOUND);
162
+ }
163
+ output(opts, {
164
+ json: () => result,
165
+ human: () => success(`Added edge ${result.from.slice(0, 8)} → ${result.to.slice(0, 8)}`),
166
+ });
167
+ }
168
+ export async function canvasRemoveNode(opts) {
169
+ const n = new Napkin(opts.vault || process.cwd());
170
+ if (!opts.file || !opts.id) {
171
+ error("Both --file and --id required");
172
+ process.exit(EXIT_USER_ERROR);
173
+ }
174
+ let result;
175
+ try {
176
+ result = n.canvasRemoveNode(opts.file, opts.id);
177
+ }
178
+ catch (e) {
179
+ error(e.message);
180
+ process.exit(EXIT_NOT_FOUND);
181
+ }
182
+ output(opts, {
183
+ json: () => result,
184
+ human: () => success(`Removed node ${result.id}`),
185
+ });
186
+ }
@@ -0,0 +1,13 @@
1
+ import { type OutputOptions } from "../utils/output.js";
2
+ export declare function configShow(opts: OutputOptions & {
3
+ vault?: string;
4
+ }): Promise<void>;
5
+ export declare function configSet(opts: OutputOptions & {
6
+ vault?: string;
7
+ key?: string;
8
+ value?: string;
9
+ }): Promise<void>;
10
+ export declare function configGet(opts: OutputOptions & {
11
+ vault?: string;
12
+ key?: string;
13
+ }): Promise<void>;
@@ -0,0 +1,48 @@
1
+ import { Napkin } from "../sdk.js";
2
+ import { EXIT_USER_ERROR } from "../utils/exit-codes.js";
3
+ import { bold, dim, error, output, } from "../utils/output.js";
4
+ export async function configShow(opts) {
5
+ const n = new Napkin(opts.vault || process.cwd());
6
+ const config = n.config();
7
+ output(opts, {
8
+ json: () => config,
9
+ human: () => {
10
+ console.log(JSON.stringify(config, null, 2));
11
+ },
12
+ });
13
+ }
14
+ export async function configSet(opts) {
15
+ const n = new Napkin(opts.vault || process.cwd());
16
+ if (!opts.key || opts.value === undefined) {
17
+ error("Usage: napkin config set --key <path> --value <value>");
18
+ process.exit(EXIT_USER_ERROR);
19
+ }
20
+ const { config: updated, parsed } = n.configSet(opts.key, opts.value);
21
+ output(opts, {
22
+ json: () => updated,
23
+ human: () => {
24
+ console.log(`${dim("set")} ${bold(opts.key)} = ${JSON.stringify(parsed)}`);
25
+ },
26
+ });
27
+ }
28
+ export async function configGet(opts) {
29
+ const n = new Napkin(opts.vault || process.cwd());
30
+ if (!opts.key) {
31
+ error("Usage: napkin config get --key <path>");
32
+ process.exit(EXIT_USER_ERROR);
33
+ }
34
+ const value = n.configGet(opts.key);
35
+ output(opts, {
36
+ json: () => ({ key: opts.key, value }),
37
+ human: () => {
38
+ if (value === undefined) {
39
+ console.log(dim("(not set)"));
40
+ }
41
+ else {
42
+ console.log(typeof value === "object"
43
+ ? JSON.stringify(value, null, 2)
44
+ : String(value));
45
+ }
46
+ },
47
+ });
48
+ }
@@ -0,0 +1,40 @@
1
+ import { type OutputOptions } from "../utils/output.js";
2
+ export declare function read(fileRef: string | undefined, opts: OutputOptions & {
3
+ vault?: string;
4
+ }): Promise<void>;
5
+ export declare function create(opts: OutputOptions & {
6
+ vault?: string;
7
+ name?: string;
8
+ path?: string;
9
+ content?: string;
10
+ template?: string;
11
+ overwrite?: boolean;
12
+ open?: boolean;
13
+ }): Promise<void>;
14
+ export declare function append(opts: OutputOptions & {
15
+ vault?: string;
16
+ file?: string;
17
+ content?: string;
18
+ inline?: boolean;
19
+ }): Promise<void>;
20
+ export declare function prepend(opts: OutputOptions & {
21
+ vault?: string;
22
+ file?: string;
23
+ content?: string;
24
+ inline?: boolean;
25
+ }): Promise<void>;
26
+ export declare function move(opts: OutputOptions & {
27
+ vault?: string;
28
+ file?: string;
29
+ to?: string;
30
+ }): Promise<void>;
31
+ export declare function rename(opts: OutputOptions & {
32
+ vault?: string;
33
+ file?: string;
34
+ name?: string;
35
+ }): Promise<void>;
36
+ export declare function del(opts: OutputOptions & {
37
+ vault?: string;
38
+ file?: string;
39
+ permanent?: boolean;
40
+ }): Promise<void>;
@@ -0,0 +1,195 @@
1
+ import { Napkin } from "../sdk.js";
2
+ import { EXIT_NOT_FOUND, EXIT_USER_ERROR } from "../utils/exit-codes.js";
3
+ import { suggestFile } from "../utils/files.js";
4
+ import { error, fileNotFound, output, success, } from "../utils/output.js";
5
+ export async function read(fileRef, opts) {
6
+ const n = new Napkin(opts.vault || process.cwd());
7
+ if (!fileRef) {
8
+ error("No file specified. Usage: napkin read <file>");
9
+ process.exit(EXIT_USER_ERROR);
10
+ }
11
+ let result;
12
+ try {
13
+ result = n.read(fileRef);
14
+ }
15
+ catch (e) {
16
+ const msg = e.message;
17
+ if (msg.startsWith("File not found:")) {
18
+ fileNotFound(fileRef, suggestFile(n.vault.contentPath, fileRef));
19
+ process.exit(EXIT_NOT_FOUND);
20
+ }
21
+ throw e;
22
+ }
23
+ output(opts, {
24
+ json: () => result,
25
+ human: () => console.log(result.content),
26
+ });
27
+ }
28
+ export async function create(opts) {
29
+ const n = new Napkin(opts.vault || process.cwd());
30
+ let result;
31
+ try {
32
+ result = n.create({
33
+ name: opts.name,
34
+ path: opts.path,
35
+ content: opts.content,
36
+ template: opts.template,
37
+ overwrite: opts.overwrite,
38
+ });
39
+ }
40
+ catch (e) {
41
+ error(e.message);
42
+ process.exit(EXIT_USER_ERROR);
43
+ }
44
+ output(opts, {
45
+ json: () => result,
46
+ human: () => success(`Created ${result.path}`),
47
+ });
48
+ }
49
+ async function readStdin() {
50
+ if (process.stdin.isTTY)
51
+ return undefined;
52
+ const chunks = [];
53
+ for await (const chunk of process.stdin) {
54
+ chunks.push(chunk);
55
+ }
56
+ const result = Buffer.concat(chunks).toString("utf-8").trimEnd();
57
+ return result || undefined;
58
+ }
59
+ export async function append(opts) {
60
+ const n = new Napkin(opts.vault || process.cwd());
61
+ if (!opts.file) {
62
+ error("No file specified. Use: napkin append <file> [content]");
63
+ process.exit(EXIT_USER_ERROR);
64
+ }
65
+ if (!opts.content) {
66
+ opts.content = await readStdin();
67
+ }
68
+ if (!opts.content) {
69
+ error("No content specified. Use: napkin append <file> <content>");
70
+ process.exit(EXIT_USER_ERROR);
71
+ }
72
+ let resolved;
73
+ try {
74
+ resolved = n.append(opts.file, opts.content, opts.inline);
75
+ }
76
+ catch (e) {
77
+ const msg = e.message;
78
+ if (msg.startsWith("File not found:")) {
79
+ fileNotFound(opts.file, suggestFile(n.vault.contentPath, opts.file));
80
+ process.exit(EXIT_NOT_FOUND);
81
+ }
82
+ throw e;
83
+ }
84
+ output(opts, {
85
+ json: () => ({ path: resolved, appended: true }),
86
+ human: () => success(`Appended to ${resolved}`),
87
+ });
88
+ }
89
+ export async function prepend(opts) {
90
+ const n = new Napkin(opts.vault || process.cwd());
91
+ if (!opts.file) {
92
+ error("No file specified. Use: napkin prepend <file> [content]");
93
+ process.exit(EXIT_USER_ERROR);
94
+ }
95
+ if (!opts.content) {
96
+ opts.content = await readStdin();
97
+ }
98
+ if (!opts.content) {
99
+ error("No content specified. Use: napkin prepend <file> <content>");
100
+ process.exit(EXIT_USER_ERROR);
101
+ }
102
+ let resolved;
103
+ try {
104
+ resolved = n.prepend(opts.file, opts.content, opts.inline);
105
+ }
106
+ catch (e) {
107
+ const msg = e.message;
108
+ if (msg.startsWith("File not found:")) {
109
+ fileNotFound(opts.file, suggestFile(n.vault.contentPath, opts.file));
110
+ process.exit(EXIT_NOT_FOUND);
111
+ }
112
+ throw e;
113
+ }
114
+ output(opts, {
115
+ json: () => ({ path: resolved, prepended: true }),
116
+ human: () => success(`Prepended to ${resolved}`),
117
+ });
118
+ }
119
+ export async function move(opts) {
120
+ const n = new Napkin(opts.vault || process.cwd());
121
+ if (!opts.file) {
122
+ error("No file specified. Use --file <name>");
123
+ process.exit(EXIT_USER_ERROR);
124
+ }
125
+ if (!opts.to) {
126
+ error("No destination specified. Use --to <path>");
127
+ process.exit(EXIT_USER_ERROR);
128
+ }
129
+ let result;
130
+ try {
131
+ result = n.move(opts.file, opts.to);
132
+ }
133
+ catch (e) {
134
+ const msg = e.message;
135
+ if (msg.startsWith("File not found:")) {
136
+ fileNotFound(opts.file, suggestFile(n.vault.contentPath, opts.file));
137
+ process.exit(EXIT_NOT_FOUND);
138
+ }
139
+ throw e;
140
+ }
141
+ output(opts, {
142
+ json: () => result,
143
+ human: () => success(`Moved ${result.from} → ${result.to}`),
144
+ });
145
+ }
146
+ export async function rename(opts) {
147
+ const n = new Napkin(opts.vault || process.cwd());
148
+ if (!opts.file) {
149
+ error("No file specified. Use --file <name>");
150
+ process.exit(EXIT_USER_ERROR);
151
+ }
152
+ if (!opts.name) {
153
+ error("No new name specified. Use --name <name>");
154
+ process.exit(EXIT_USER_ERROR);
155
+ }
156
+ let result;
157
+ try {
158
+ result = n.rename(opts.file, opts.name);
159
+ }
160
+ catch (e) {
161
+ const msg = e.message;
162
+ if (msg.startsWith("File not found:")) {
163
+ fileNotFound(opts.file, suggestFile(n.vault.contentPath, opts.file));
164
+ process.exit(EXIT_NOT_FOUND);
165
+ }
166
+ throw e;
167
+ }
168
+ output(opts, {
169
+ json: () => result,
170
+ human: () => success(`Renamed ${result.from} → ${result.to}`),
171
+ });
172
+ }
173
+ export async function del(opts) {
174
+ const n = new Napkin(opts.vault || process.cwd());
175
+ if (!opts.file) {
176
+ error("No file specified. Use --file <name>");
177
+ process.exit(EXIT_USER_ERROR);
178
+ }
179
+ let result;
180
+ try {
181
+ result = n.delete(opts.file, opts.permanent);
182
+ }
183
+ catch (e) {
184
+ const msg = e.message;
185
+ if (msg.startsWith("File not found:")) {
186
+ fileNotFound(opts.file, suggestFile(n.vault.contentPath, opts.file));
187
+ process.exit(EXIT_NOT_FOUND);
188
+ }
189
+ throw e;
190
+ }
191
+ output(opts, {
192
+ json: () => result,
193
+ human: () => success(`Deleted ${result.path}${result.permanent ? " (permanent)" : " (moved to .trash)"}`),
194
+ });
195
+ }
@@ -0,0 +1,20 @@
1
+ import { type OutputOptions } from "../utils/output.js";
2
+ export declare function daily(opts: OutputOptions & {
3
+ vault?: string;
4
+ }): Promise<void>;
5
+ export declare function dailyPath(opts: OutputOptions & {
6
+ vault?: string;
7
+ }): Promise<void>;
8
+ export declare function dailyRead(opts: OutputOptions & {
9
+ vault?: string;
10
+ }): Promise<void>;
11
+ export declare function dailyAppend(opts: OutputOptions & {
12
+ vault?: string;
13
+ content?: string;
14
+ inline?: boolean;
15
+ }): Promise<void>;
16
+ export declare function dailyPrepend(opts: OutputOptions & {
17
+ vault?: string;
18
+ content?: string;
19
+ inline?: boolean;
20
+ }): Promise<void>;
@@ -0,0 +1,58 @@
1
+ import { Napkin } from "../sdk.js";
2
+ import { EXIT_NOT_FOUND, EXIT_USER_ERROR } from "../utils/exit-codes.js";
3
+ import { error, output, success } from "../utils/output.js";
4
+ export async function daily(opts) {
5
+ const n = new Napkin(opts.vault || process.cwd());
6
+ const result = n.dailyEnsure();
7
+ output(opts, {
8
+ json: () => result,
9
+ human: () => success(`Daily note: ${result.path}`),
10
+ });
11
+ }
12
+ export async function dailyPath(opts) {
13
+ const n = new Napkin(opts.vault || process.cwd());
14
+ const dp = n.dailyPath();
15
+ output(opts, {
16
+ json: () => ({ path: dp }),
17
+ human: () => console.log(dp),
18
+ });
19
+ }
20
+ export async function dailyRead(opts) {
21
+ const n = new Napkin(opts.vault || process.cwd());
22
+ let result;
23
+ try {
24
+ result = n.dailyRead();
25
+ }
26
+ catch (e) {
27
+ error(e.message);
28
+ process.exit(EXIT_NOT_FOUND);
29
+ }
30
+ output(opts, {
31
+ json: () => result,
32
+ human: () => console.log(result.content),
33
+ });
34
+ }
35
+ export async function dailyAppend(opts) {
36
+ const n = new Napkin(opts.vault || process.cwd());
37
+ if (!opts.content) {
38
+ error("No content specified. Use --content <text>");
39
+ process.exit(EXIT_USER_ERROR);
40
+ }
41
+ const dp = n.dailyAppend(opts.content, opts.inline);
42
+ output(opts, {
43
+ json: () => ({ path: dp, appended: true }),
44
+ human: () => success(`Appended to ${dp}`),
45
+ });
46
+ }
47
+ export async function dailyPrepend(opts) {
48
+ const n = new Napkin(opts.vault || process.cwd());
49
+ if (!opts.content) {
50
+ error("No content specified. Use --content <text>");
51
+ process.exit(EXIT_USER_ERROR);
52
+ }
53
+ const dp = n.dailyPrepend(opts.content, opts.inline);
54
+ output(opts, {
55
+ json: () => ({ path: dp, prepended: true }),
56
+ human: () => success(`Prepended to ${dp}`),
57
+ });
58
+ }
@@ -0,0 +1,23 @@
1
+ import { type OutputOptions } from "../utils/output.js";
2
+ export declare function file(fileRef: string | undefined, opts: OutputOptions & {
3
+ vault?: string;
4
+ }): Promise<void>;
5
+ export declare function files(opts: OutputOptions & {
6
+ vault?: string;
7
+ folder?: string;
8
+ ext?: string;
9
+ total?: boolean;
10
+ }): Promise<void>;
11
+ export declare function folders(opts: OutputOptions & {
12
+ vault?: string;
13
+ folder?: string;
14
+ total?: boolean;
15
+ }): Promise<void>;
16
+ export declare function folder(folderPath: string | undefined, opts: OutputOptions & {
17
+ vault?: string;
18
+ info?: string;
19
+ }): Promise<void>;
20
+ export declare function open(fileRef: string | undefined, opts: OutputOptions & {
21
+ vault?: string;
22
+ newtab?: boolean;
23
+ }): Promise<void>;