@rejot-dev/thalo-cli 0.0.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.
- package/LICENSE +21 -0
- package/README.md +179 -0
- package/bin/run.js +2 -0
- package/dist/cli.js +175 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/actualize.js +124 -0
- package/dist/commands/actualize.js.map +1 -0
- package/dist/commands/check.js +271 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/format.js +220 -0
- package/dist/commands/format.js.map +1 -0
- package/dist/commands/init.js +192 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/lsp.js +26 -0
- package/dist/commands/lsp.js.map +1 -0
- package/dist/commands/merge-driver.js +99 -0
- package/dist/commands/merge-driver.js.map +1 -0
- package/dist/commands/query.js +162 -0
- package/dist/commands/query.js.map +1 -0
- package/dist/commands/rules.js +104 -0
- package/dist/commands/rules.js.map +1 -0
- package/dist/commands/setup-merge-driver.js +210 -0
- package/dist/commands/setup-merge-driver.js.map +1 -0
- package/dist/files.js +145 -0
- package/dist/files.js.map +1 -0
- package/dist/mod.d.ts +1 -0
- package/dist/mod.js +31 -0
- package/dist/mod.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { promisify } from "node:util";
|
|
2
|
+
import pc from "picocolors";
|
|
3
|
+
import * as fs from "node:fs/promises";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
import { execFile } from "node:child_process";
|
|
6
|
+
|
|
7
|
+
//#region src/commands/setup-merge-driver.ts
|
|
8
|
+
const execFile$1 = promisify(execFile);
|
|
9
|
+
/**
|
|
10
|
+
* Setup merge driver command
|
|
11
|
+
*
|
|
12
|
+
* Configures Git to use the thalo merge driver for .thalo files
|
|
13
|
+
*/
|
|
14
|
+
async function setupMergeDriverAction(ctx) {
|
|
15
|
+
const { options } = ctx;
|
|
16
|
+
const isGlobal = options["global"];
|
|
17
|
+
const checkOnly = options["check"];
|
|
18
|
+
const uninstall = options["uninstall"];
|
|
19
|
+
if (checkOnly) {
|
|
20
|
+
await checkConfiguration(isGlobal);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (uninstall) {
|
|
24
|
+
await uninstallConfiguration(isGlobal);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (!isGlobal) {
|
|
28
|
+
if (!await isGitRepository()) {
|
|
29
|
+
console.error(pc.red("Error: Not in a git repository"));
|
|
30
|
+
console.error(pc.dim("Run this command from a git repository, or use --global for system-wide configuration"));
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
console.log(pc.blue(`Configuring thalo merge driver ${isGlobal ? "globally" : "for this repository"}...`));
|
|
35
|
+
console.log();
|
|
36
|
+
try {
|
|
37
|
+
await configureGit(isGlobal);
|
|
38
|
+
if (!isGlobal) await configureGitAttributes();
|
|
39
|
+
console.log();
|
|
40
|
+
console.log(pc.green("✓ Thalo merge driver configured successfully"));
|
|
41
|
+
console.log();
|
|
42
|
+
console.log(pc.bold("Configuration:"));
|
|
43
|
+
if (isGlobal) {
|
|
44
|
+
console.log(pc.dim(" • Git config: ~/.gitconfig"));
|
|
45
|
+
console.log(pc.dim(" • You still need to add '*.thalo merge=thalo' to .gitattributes in each repository"));
|
|
46
|
+
} else {
|
|
47
|
+
console.log(pc.dim(" • Git config: .git/config"));
|
|
48
|
+
console.log(pc.dim(" • Git attributes: .gitattributes"));
|
|
49
|
+
}
|
|
50
|
+
console.log();
|
|
51
|
+
console.log(pc.dim("The merge driver will now be used for *.thalo files during git merge"));
|
|
52
|
+
} catch (err) {
|
|
53
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
54
|
+
console.error(pc.red(`Error: ${message}`));
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Check if we're in a git repository
|
|
60
|
+
*/
|
|
61
|
+
async function isGitRepository() {
|
|
62
|
+
try {
|
|
63
|
+
await execFile$1("git", ["rev-parse", "--git-dir"]);
|
|
64
|
+
return true;
|
|
65
|
+
} catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Configure git config for the merge driver
|
|
71
|
+
*/
|
|
72
|
+
async function configureGit(isGlobal) {
|
|
73
|
+
console.log(pc.dim("Configuring git merge driver..."));
|
|
74
|
+
const baseArgs = isGlobal ? ["config", "--global"] : ["config"];
|
|
75
|
+
try {
|
|
76
|
+
await execFile$1("git", [
|
|
77
|
+
...baseArgs,
|
|
78
|
+
"merge.thalo.name",
|
|
79
|
+
"Thalo semantic merge driver"
|
|
80
|
+
]);
|
|
81
|
+
} catch (err) {
|
|
82
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
83
|
+
throw new Error(`Failed to set merge.thalo.name: ${message}`);
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
await execFile$1("git", [
|
|
87
|
+
...baseArgs,
|
|
88
|
+
"merge.thalo.driver",
|
|
89
|
+
"thalo merge-driver %O %A %B %P"
|
|
90
|
+
]);
|
|
91
|
+
} catch (err) {
|
|
92
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
93
|
+
throw new Error(`Failed to set merge.thalo.driver: ${message}`);
|
|
94
|
+
}
|
|
95
|
+
console.log(pc.green(" ✓ Git config updated"));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Configure .gitattributes for thalo files
|
|
99
|
+
*/
|
|
100
|
+
async function configureGitAttributes() {
|
|
101
|
+
console.log(pc.dim("Configuring .gitattributes..."));
|
|
102
|
+
const attributesPath = path.join(process.cwd(), ".gitattributes");
|
|
103
|
+
const attributeLine = "*.thalo merge=thalo";
|
|
104
|
+
let content = "";
|
|
105
|
+
try {
|
|
106
|
+
content = await fs.readFile(attributesPath, "utf-8");
|
|
107
|
+
} catch {}
|
|
108
|
+
if (content.includes(attributeLine)) {
|
|
109
|
+
console.log(pc.green(" ✓ .gitattributes already configured"));
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const newContent = content.trim() ? `${content.trim()}\n${attributeLine}\n` : `${attributeLine}\n`;
|
|
113
|
+
await fs.writeFile(attributesPath, newContent, "utf-8");
|
|
114
|
+
console.log(pc.green(" ✓ .gitattributes updated"));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Check current configuration
|
|
118
|
+
*/
|
|
119
|
+
async function checkConfiguration(isGlobal) {
|
|
120
|
+
const scope = isGlobal ? "global" : "local";
|
|
121
|
+
console.log(pc.blue(`Checking ${scope} merge driver configuration...`));
|
|
122
|
+
console.log();
|
|
123
|
+
const baseArgs = isGlobal ? ["config", "--global"] : ["config"];
|
|
124
|
+
try {
|
|
125
|
+
const { stdout: name } = await execFile$1("git", [...baseArgs, "merge.thalo.name"]);
|
|
126
|
+
console.log(pc.green(`✓ merge.thalo.name: ${name.trim()}`));
|
|
127
|
+
} catch {
|
|
128
|
+
console.log(pc.red("✗ merge.thalo.name: not configured"));
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
const { stdout: driver } = await execFile$1("git", [...baseArgs, "merge.thalo.driver"]);
|
|
132
|
+
console.log(pc.green(`✓ merge.thalo.driver: ${driver.trim()}`));
|
|
133
|
+
} catch {
|
|
134
|
+
console.log(pc.red("✗ merge.thalo.driver: not configured"));
|
|
135
|
+
}
|
|
136
|
+
if (!isGlobal) {
|
|
137
|
+
const attributesPath = path.join(process.cwd(), ".gitattributes");
|
|
138
|
+
try {
|
|
139
|
+
if ((await fs.readFile(attributesPath, "utf-8")).includes("*.thalo merge=thalo")) console.log(pc.green("✓ .gitattributes: configured"));
|
|
140
|
+
else console.log(pc.yellow("⚠ .gitattributes: not configured"));
|
|
141
|
+
} catch {
|
|
142
|
+
console.log(pc.yellow("⚠ .gitattributes: file not found"));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Uninstall configuration
|
|
148
|
+
*/
|
|
149
|
+
async function uninstallConfiguration(isGlobal) {
|
|
150
|
+
console.log(pc.blue(`Removing ${isGlobal ? "global" : "local"} merge driver configuration...`));
|
|
151
|
+
console.log();
|
|
152
|
+
const baseArgs = isGlobal ? [
|
|
153
|
+
"config",
|
|
154
|
+
"--global",
|
|
155
|
+
"--unset"
|
|
156
|
+
] : ["config", "--unset"];
|
|
157
|
+
try {
|
|
158
|
+
await execFile$1("git", [...baseArgs, "merge.thalo.name"]);
|
|
159
|
+
console.log(pc.green("✓ Removed merge.thalo.name"));
|
|
160
|
+
} catch {
|
|
161
|
+
console.log(pc.dim(" merge.thalo.name not found"));
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
await execFile$1("git", [...baseArgs, "merge.thalo.driver"]);
|
|
165
|
+
console.log(pc.green("✓ Removed merge.thalo.driver"));
|
|
166
|
+
} catch {
|
|
167
|
+
console.log(pc.dim(" merge.thalo.driver not found"));
|
|
168
|
+
}
|
|
169
|
+
if (!isGlobal) {
|
|
170
|
+
const attributesPath = path.join(process.cwd(), ".gitattributes");
|
|
171
|
+
try {
|
|
172
|
+
let content = await fs.readFile(attributesPath, "utf-8");
|
|
173
|
+
const originalContent = content;
|
|
174
|
+
content = content.replace(/^\*\.thalo merge=thalo\n?/gm, "");
|
|
175
|
+
if (content !== originalContent) {
|
|
176
|
+
await fs.writeFile(attributesPath, content, "utf-8");
|
|
177
|
+
console.log(pc.green("✓ Removed from .gitattributes"));
|
|
178
|
+
} else console.log(pc.dim(" .gitattributes entry not found"));
|
|
179
|
+
} catch {}
|
|
180
|
+
}
|
|
181
|
+
console.log();
|
|
182
|
+
console.log(pc.green("✓ Merge driver configuration removed"));
|
|
183
|
+
}
|
|
184
|
+
const setupMergeDriverCommand = {
|
|
185
|
+
name: "setup-merge-driver",
|
|
186
|
+
description: "Configure Git to use the thalo merge driver",
|
|
187
|
+
options: {
|
|
188
|
+
global: {
|
|
189
|
+
type: "boolean",
|
|
190
|
+
short: "g",
|
|
191
|
+
description: "Configure globally in ~/.gitconfig",
|
|
192
|
+
default: false
|
|
193
|
+
},
|
|
194
|
+
check: {
|
|
195
|
+
type: "boolean",
|
|
196
|
+
description: "Check if merge driver is configured",
|
|
197
|
+
default: false
|
|
198
|
+
},
|
|
199
|
+
uninstall: {
|
|
200
|
+
type: "boolean",
|
|
201
|
+
description: "Remove merge driver configuration",
|
|
202
|
+
default: false
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
action: setupMergeDriverAction
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
//#endregion
|
|
209
|
+
export { setupMergeDriverCommand };
|
|
210
|
+
//# sourceMappingURL=setup-merge-driver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-merge-driver.js","names":["execFile","execFileCallback","setupMergeDriverCommand: CommandDef"],"sources":["../../src/commands/setup-merge-driver.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { execFile as execFileCallback } from \"node:child_process\";\nimport { promisify } from \"node:util\";\nimport type { CommandDef, CommandContext } from \"../cli.js\";\nimport pc from \"picocolors\";\n\nconst execFile = promisify(execFileCallback);\n\n/**\n * Setup merge driver command\n *\n * Configures Git to use the thalo merge driver for .thalo files\n */\nasync function setupMergeDriverAction(ctx: CommandContext): Promise<void> {\n const { options } = ctx;\n const isGlobal = options[\"global\"] as boolean;\n const checkOnly = options[\"check\"] as boolean;\n const uninstall = options[\"uninstall\"] as boolean;\n\n if (checkOnly) {\n await checkConfiguration(isGlobal);\n return;\n }\n\n if (uninstall) {\n await uninstallConfiguration(isGlobal);\n return;\n }\n\n if (!isGlobal) {\n if (!(await isGitRepository())) {\n console.error(pc.red(\"Error: Not in a git repository\"));\n console.error(\n pc.dim(\n \"Run this command from a git repository, or use --global for system-wide configuration\",\n ),\n );\n process.exit(1);\n }\n }\n\n console.log(\n pc.blue(`Configuring thalo merge driver ${isGlobal ? \"globally\" : \"for this repository\"}...`),\n );\n console.log();\n\n try {\n await configureGit(isGlobal);\n\n if (!isGlobal) {\n await configureGitAttributes();\n }\n\n console.log();\n console.log(pc.green(\"✓ Thalo merge driver configured successfully\"));\n console.log();\n console.log(pc.bold(\"Configuration:\"));\n if (isGlobal) {\n console.log(pc.dim(\" • Git config: ~/.gitconfig\"));\n console.log(\n pc.dim(\n \" • You still need to add '*.thalo merge=thalo' to .gitattributes in each repository\",\n ),\n );\n } else {\n console.log(pc.dim(\" • Git config: .git/config\"));\n console.log(pc.dim(\" • Git attributes: .gitattributes\"));\n }\n console.log();\n console.log(pc.dim(\"The merge driver will now be used for *.thalo files during git merge\"));\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n console.error(pc.red(`Error: ${message}`));\n process.exit(1);\n }\n}\n\n/**\n * Check if we're in a git repository\n */\nasync function isGitRepository(): Promise<boolean> {\n try {\n await execFile(\"git\", [\"rev-parse\", \"--git-dir\"]);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Configure git config for the merge driver\n */\nasync function configureGit(isGlobal: boolean): Promise<void> {\n console.log(pc.dim(\"Configuring git merge driver...\"));\n\n const baseArgs = isGlobal ? [\"config\", \"--global\"] : [\"config\"];\n\n try {\n await execFile(\"git\", [...baseArgs, \"merge.thalo.name\", \"Thalo semantic merge driver\"]);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n throw new Error(`Failed to set merge.thalo.name: ${message}`);\n }\n\n try {\n await execFile(\"git\", [...baseArgs, \"merge.thalo.driver\", \"thalo merge-driver %O %A %B %P\"]);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n throw new Error(`Failed to set merge.thalo.driver: ${message}`);\n }\n\n console.log(pc.green(\" ✓ Git config updated\"));\n}\n\n/**\n * Configure .gitattributes for thalo files\n */\nasync function configureGitAttributes(): Promise<void> {\n console.log(pc.dim(\"Configuring .gitattributes...\"));\n\n const attributesPath = path.join(process.cwd(), \".gitattributes\");\n const attributeLine = \"*.thalo merge=thalo\";\n\n let content = \"\";\n try {\n content = await fs.readFile(attributesPath, \"utf-8\");\n } catch {\n // File doesn't exist, will be created\n }\n\n if (content.includes(attributeLine)) {\n console.log(pc.green(\" ✓ .gitattributes already configured\"));\n return;\n }\n\n const newContent = content.trim()\n ? `${content.trim()}\\n${attributeLine}\\n`\n : `${attributeLine}\\n`;\n await fs.writeFile(attributesPath, newContent, \"utf-8\");\n\n console.log(pc.green(\" ✓ .gitattributes updated\"));\n}\n\n/**\n * Check current configuration\n */\nasync function checkConfiguration(isGlobal: boolean): Promise<void> {\n const scope = isGlobal ? \"global\" : \"local\";\n console.log(pc.blue(`Checking ${scope} merge driver configuration...`));\n console.log();\n\n const baseArgs = isGlobal ? [\"config\", \"--global\"] : [\"config\"];\n\n try {\n const { stdout: name } = await execFile(\"git\", [...baseArgs, \"merge.thalo.name\"]);\n console.log(pc.green(`✓ merge.thalo.name: ${name.trim()}`));\n } catch {\n console.log(pc.red(\"✗ merge.thalo.name: not configured\"));\n }\n\n try {\n const { stdout: driver } = await execFile(\"git\", [...baseArgs, \"merge.thalo.driver\"]);\n console.log(pc.green(`✓ merge.thalo.driver: ${driver.trim()}`));\n } catch {\n console.log(pc.red(\"✗ merge.thalo.driver: not configured\"));\n }\n\n if (!isGlobal) {\n const attributesPath = path.join(process.cwd(), \".gitattributes\");\n try {\n const content = await fs.readFile(attributesPath, \"utf-8\");\n if (content.includes(\"*.thalo merge=thalo\")) {\n console.log(pc.green(\"✓ .gitattributes: configured\"));\n } else {\n console.log(pc.yellow(\"⚠ .gitattributes: not configured\"));\n }\n } catch {\n console.log(pc.yellow(\"⚠ .gitattributes: file not found\"));\n }\n }\n}\n\n/**\n * Uninstall configuration\n */\nasync function uninstallConfiguration(isGlobal: boolean): Promise<void> {\n console.log(pc.blue(`Removing ${isGlobal ? \"global\" : \"local\"} merge driver configuration...`));\n console.log();\n\n const baseArgs = isGlobal ? [\"config\", \"--global\", \"--unset\"] : [\"config\", \"--unset\"];\n\n try {\n await execFile(\"git\", [...baseArgs, \"merge.thalo.name\"]);\n console.log(pc.green(\"✓ Removed merge.thalo.name\"));\n } catch {\n console.log(pc.dim(\" merge.thalo.name not found\"));\n }\n\n try {\n await execFile(\"git\", [...baseArgs, \"merge.thalo.driver\"]);\n console.log(pc.green(\"✓ Removed merge.thalo.driver\"));\n } catch {\n console.log(pc.dim(\" merge.thalo.driver not found\"));\n }\n\n if (!isGlobal) {\n const attributesPath = path.join(process.cwd(), \".gitattributes\");\n try {\n let content = await fs.readFile(attributesPath, \"utf-8\");\n const originalContent = content;\n content = content.replace(/^\\*\\.thalo merge=thalo\\n?/gm, \"\");\n\n if (content !== originalContent) {\n await fs.writeFile(attributesPath, content, \"utf-8\");\n console.log(pc.green(\"✓ Removed from .gitattributes\"));\n } else {\n console.log(pc.dim(\" .gitattributes entry not found\"));\n }\n } catch {\n // File doesn't exist, nothing to do\n }\n }\n\n console.log();\n console.log(pc.green(\"✓ Merge driver configuration removed\"));\n}\n\nexport const setupMergeDriverCommand: CommandDef = {\n name: \"setup-merge-driver\",\n description: \"Configure Git to use the thalo merge driver\",\n options: {\n global: {\n type: \"boolean\",\n short: \"g\",\n description: \"Configure globally in ~/.gitconfig\",\n default: false,\n },\n check: {\n type: \"boolean\",\n description: \"Check if merge driver is configured\",\n default: false,\n },\n uninstall: {\n type: \"boolean\",\n description: \"Remove merge driver configuration\",\n default: false,\n },\n },\n action: setupMergeDriverAction,\n};\n"],"mappings":";;;;;;;AAOA,MAAMA,aAAW,UAAUC,SAAiB;;;;;;AAO5C,eAAe,uBAAuB,KAAoC;CACxE,MAAM,EAAE,YAAY;CACpB,MAAM,WAAW,QAAQ;CACzB,MAAM,YAAY,QAAQ;CAC1B,MAAM,YAAY,QAAQ;AAE1B,KAAI,WAAW;AACb,QAAM,mBAAmB,SAAS;AAClC;;AAGF,KAAI,WAAW;AACb,QAAM,uBAAuB,SAAS;AACtC;;AAGF,KAAI,CAAC,UACH;MAAI,CAAE,MAAM,i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YAAY,iBAAiB;AAC/B,UAAM,GAAG,UAAU,gBAAgB,SAAS,QAAQ;AACpD,YAAQ,IAAI,GAAG,MAAM,gCAAgC,CAAC;SAEtD,SAAQ,IAAI,GAAG,IAAI,mCAAmC,CAAC;UAEnD;;AAKV,SAAQ,KAAK;AACb,SAAQ,IAAI,GAAG,MAAM,uCAAuC,CAAC;;AAG/D,MAAaE,0BAAsC;CACjD,MAAM;CACN,aAAa;CACb,SAAS;EACP,QAAQ;GACN,MAAM;GACN,OAAO;GACP,aAAa;GACb,SAAS;GACV;EACD,OAAO;GACL,MAAM;GACN,aAAa;GACb,SAAS;GACV;EACD,WAAW;GACT,MAAM;GACN,aAAa;GACb,SAAS;GACV;EACF;CACD,QAAQ;CACT"}
|
package/dist/files.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import pc from "picocolors";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import { readFile, readdir, stat } from "node:fs/promises";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
import { join, resolve } from "node:path";
|
|
6
|
+
import { createWorkspace } from "@rejot-dev/thalo/native";
|
|
7
|
+
|
|
8
|
+
//#region src/files.ts
|
|
9
|
+
/**
|
|
10
|
+
* Default file extensions for thalo files.
|
|
11
|
+
*/
|
|
12
|
+
const DEFAULT_EXTENSIONS = [".thalo", ".md"];
|
|
13
|
+
/**
|
|
14
|
+
* Default file types (without leading dot).
|
|
15
|
+
*/
|
|
16
|
+
const DEFAULT_FILE_TYPES = ["thalo", "md"];
|
|
17
|
+
/**
|
|
18
|
+
* Get relative path from current working directory.
|
|
19
|
+
*/
|
|
20
|
+
function relativePath(filePath) {
|
|
21
|
+
const cwd = process.cwd();
|
|
22
|
+
const resolvedCwd = path.resolve(cwd);
|
|
23
|
+
const resolvedFilePath = path.resolve(filePath);
|
|
24
|
+
return path.relative(resolvedCwd, resolvedFilePath) || filePath;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Collect all thalo files from a directory (sync).
|
|
28
|
+
*/
|
|
29
|
+
function collectThaloFilesSync(dir, extensions = DEFAULT_EXTENSIONS) {
|
|
30
|
+
const files = [];
|
|
31
|
+
function walk(currentDir) {
|
|
32
|
+
let entries;
|
|
33
|
+
try {
|
|
34
|
+
entries = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
35
|
+
} catch {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
for (const entry of entries) {
|
|
39
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
40
|
+
if (entry.isDirectory()) {
|
|
41
|
+
if (!entry.name.startsWith(".") && entry.name !== "node_modules") walk(fullPath);
|
|
42
|
+
} else if (entry.isFile()) {
|
|
43
|
+
if (extensions.some((ext) => entry.name.endsWith(ext))) files.push(fullPath);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
walk(dir);
|
|
48
|
+
return files;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Resolve file paths from command arguments (sync).
|
|
52
|
+
* Supports both file types with leading dot ([".md", ".thalo"]) or without (["md", "thalo"]).
|
|
53
|
+
*/
|
|
54
|
+
function resolveFilesSync(paths, fileTypes = DEFAULT_FILE_TYPES) {
|
|
55
|
+
const files = [];
|
|
56
|
+
const extensions = fileTypes.map((type) => type.startsWith(".") ? type : `.${type}`);
|
|
57
|
+
for (const targetPath of paths) {
|
|
58
|
+
const resolved = path.resolve(targetPath);
|
|
59
|
+
if (!fs.existsSync(resolved)) {
|
|
60
|
+
console.error(pc.red(`Error: Path not found: ${targetPath}`));
|
|
61
|
+
process.exit(2);
|
|
62
|
+
}
|
|
63
|
+
const fileStat = fs.statSync(resolved);
|
|
64
|
+
if (fileStat.isDirectory()) files.push(...collectThaloFilesSync(resolved, extensions));
|
|
65
|
+
else if (fileStat.isFile()) {
|
|
66
|
+
if (extensions.some((ext) => resolved.endsWith(ext))) files.push(resolved);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return files;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Collect all thalo files from a directory (async).
|
|
73
|
+
*/
|
|
74
|
+
async function collectThaloFiles(dir, extensions = DEFAULT_EXTENSIONS) {
|
|
75
|
+
const files = [];
|
|
76
|
+
async function walk(currentDir) {
|
|
77
|
+
let entries;
|
|
78
|
+
try {
|
|
79
|
+
entries = await readdir(currentDir, { withFileTypes: true });
|
|
80
|
+
} catch {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
for (const entry of entries) {
|
|
84
|
+
const fullPath = join(currentDir, entry.name);
|
|
85
|
+
if (entry.isDirectory()) {
|
|
86
|
+
if (!entry.name.startsWith(".") && entry.name !== "node_modules") await walk(fullPath);
|
|
87
|
+
} else if (entry.isFile()) {
|
|
88
|
+
if (extensions.some((ext) => entry.name.endsWith(ext))) files.push(fullPath);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
await walk(dir);
|
|
93
|
+
return files;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Resolve file paths from command arguments (async).
|
|
97
|
+
* Supports both file types with leading dot ([".md", ".thalo"]) or without (["md", "thalo"]).
|
|
98
|
+
*/
|
|
99
|
+
async function resolveFiles(paths, fileTypes = DEFAULT_FILE_TYPES) {
|
|
100
|
+
const files = [];
|
|
101
|
+
const extensions = fileTypes.map((type) => type.startsWith(".") ? type : `.${type}`);
|
|
102
|
+
for (const targetPath of paths) {
|
|
103
|
+
const resolved = resolve(targetPath);
|
|
104
|
+
let fileStat;
|
|
105
|
+
try {
|
|
106
|
+
fileStat = await stat(resolved);
|
|
107
|
+
} catch {
|
|
108
|
+
console.error(pc.red(`Error: Path not found: ${targetPath}`));
|
|
109
|
+
process.exit(2);
|
|
110
|
+
}
|
|
111
|
+
if (fileStat.isDirectory()) files.push(...await collectThaloFiles(resolved, extensions));
|
|
112
|
+
else if (fileStat.isFile()) {
|
|
113
|
+
if (extensions.some((ext) => resolved.endsWith(ext))) files.push(resolved);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return files;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Load workspace from files (async).
|
|
120
|
+
*/
|
|
121
|
+
async function loadWorkspace(files) {
|
|
122
|
+
const workspace = createWorkspace();
|
|
123
|
+
for (const file of files) try {
|
|
124
|
+
const source = await readFile(file, "utf-8");
|
|
125
|
+
workspace.addDocument(source, { filename: file });
|
|
126
|
+
} catch (err) {
|
|
127
|
+
console.error(pc.red(`Error reading ${file}: ${err instanceof Error ? err.message : err}`));
|
|
128
|
+
}
|
|
129
|
+
return workspace;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Load the full workspace from the current working directory (async).
|
|
133
|
+
* This is the standard way to load a workspace - always includes all files from CWD.
|
|
134
|
+
*/
|
|
135
|
+
async function loadFullWorkspace(fileTypes = DEFAULT_FILE_TYPES) {
|
|
136
|
+
const files = await resolveFiles(["."], fileTypes);
|
|
137
|
+
return {
|
|
138
|
+
workspace: await loadWorkspace(files),
|
|
139
|
+
files
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//#endregion
|
|
144
|
+
export { loadFullWorkspace, loadWorkspace, relativePath, resolveFiles, resolveFilesSync };
|
|
145
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","names":["files: string[]"],"sources":["../src/files.ts"],"sourcesContent":["/**\n * Centralized file collection and workspace utilities for CLI commands.\n */\n\nimport * as fs from \"node:fs\";\nimport { readdir, readFile, stat } from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { join, resolve } from \"node:path\";\nimport pc from \"picocolors\";\nimport { createWorkspace, type Workspace } from \"@rejot-dev/thalo/native\";\n\n/**\n * Default file extensions for thalo files.\n */\nexport const DEFAULT_EXTENSIONS = [\".thalo\", \".md\"];\n\n/**\n * Default file types (without leading dot).\n */\nexport const DEFAULT_FILE_TYPES = [\"thalo\", \"md\"];\n\n/**\n * Get relative path from current working directory.\n */\nexport function relativePath(filePath: string): string {\n const cwd = process.cwd();\n const resolvedCwd = path.resolve(cwd);\n const resolvedFilePath = path.resolve(filePath);\n const rel = path.relative(resolvedCwd, resolvedFilePath);\n return rel || filePath;\n}\n\n// ===================\n// Synchronous versions (for check, actualize)\n// ===================\n\n/**\n * Collect all thalo files from a directory (sync).\n */\nexport function collectThaloFilesSync(\n dir: string,\n extensions: string[] = DEFAULT_EXTENSIONS,\n): string[] {\n const files: string[] = [];\n\n function walk(currentDir: string): void {\n let entries;\n try {\n entries = fs.readdirSync(currentDir, { withFileTypes: true });\n } catch {\n return;\n }\n\n for (const entry of entries) {\n const fullPath = path.join(currentDir, entry.name);\n\n if (entry.isDirectory()) {\n if (!entry.name.startsWith(\".\") && entry.name !== \"node_modules\") {\n walk(fullPath);\n }\n } else if (entry.isFile()) {\n if (extensions.some((ext) => entry.name.endsWith(ext))) {\n files.push(fullPath);\n }\n }\n }\n }\n\n walk(dir);\n return files;\n}\n\n/**\n * Resolve file paths from command arguments (sync).\n * Supports both file types with leading dot ([\".md\", \".thalo\"]) or without ([\"md\", \"thalo\"]).\n */\nexport function resolveFilesSync(\n paths: string[],\n fileTypes: string[] = DEFAULT_FILE_TYPES,\n): string[] {\n const files: string[] = [];\n // Normalize to extensions with leading dot\n const extensions = fileTypes.map((type) => (type.startsWith(\".\") ? type : `.${type}`));\n\n for (const targetPath of paths) {\n const resolved = path.resolve(targetPath);\n\n if (!fs.existsSync(resolved)) {\n console.error(pc.red(`Error: Path not found: ${targetPath}`));\n process.exit(2);\n }\n\n const fileStat = fs.statSync(resolved);\n if (fileStat.isDirectory()) {\n files.push(...collectThaloFilesSync(resolved, extensions));\n } else if (fileStat.isFile()) {\n // Accept file if extension matches or if no filtering is needed\n if (extensions.some((ext) => resolved.endsWith(ext))) {\n files.push(resolved);\n }\n }\n }\n\n return files;\n}\n\n/**\n * Load workspace from files (sync).\n */\nexport function loadWorkspaceSync(files: string[]): Workspace {\n const workspace = createWorkspace();\n\n for (const file of files) {\n try {\n const source = fs.readFileSync(file, \"utf-8\");\n workspace.addDocument(source, { filename: file });\n } catch (err) {\n console.error(pc.red(`Error reading ${file}: ${err instanceof Error ? err.message : err}`));\n }\n }\n\n return workspace;\n}\n\n// ===================\n// Async versions (for query, format)\n// ===================\n\n/**\n * Collect all thalo files from a directory (async).\n */\nexport async function collectThaloFiles(\n dir: string,\n extensions: string[] = DEFAULT_EXTENSIONS,\n): Promise<string[]> {\n const files: string[] = [];\n\n async function walk(currentDir: string): Promise<void> {\n let entries;\n try {\n entries = await readdir(currentDir, { withFileTypes: true });\n } catch {\n return;\n }\n\n for (const entry of entries) {\n const fullPath = join(currentDir, entry.name);\n\n if (entry.isDirectory()) {\n if (!entry.name.startsWith(\".\") && entry.name !== \"node_modules\") {\n await walk(fullPath);\n }\n } else if (entry.isFile()) {\n if (extensions.some((ext) => entry.name.endsWith(ext))) {\n files.push(fullPath);\n }\n }\n }\n }\n\n await walk(dir);\n return files;\n}\n\n/**\n * Resolve file paths from command arguments (async).\n * Supports both file types with leading dot ([\".md\", \".thalo\"]) or without ([\"md\", \"thalo\"]).\n */\nexport async function resolveFiles(\n paths: string[],\n fileTypes: string[] = DEFAULT_FILE_TYPES,\n): Promise<string[]> {\n const files: string[] = [];\n // Normalize to extensions with leading dot\n const extensions = fileTypes.map((type) => (type.startsWith(\".\") ? type : `.${type}`));\n\n for (const targetPath of paths) {\n const resolved = resolve(targetPath);\n\n let fileStat;\n try {\n fileStat = await stat(resolved);\n } catch {\n console.error(pc.red(`Error: Path not found: ${targetPath}`));\n process.exit(2);\n }\n\n if (fileStat.isDirectory()) {\n files.push(...(await collectThaloFiles(resolved, extensions)));\n } else if (fileStat.isFile()) {\n // Accept file if extension matches\n if (extensions.some((ext) => resolved.endsWith(ext))) {\n files.push(resolved);\n }\n }\n }\n\n return files;\n}\n\n/**\n * Load workspace from files (async).\n */\nexport async function loadWorkspace(files: string[]): Promise<Workspace> {\n const workspace = createWorkspace();\n\n for (const file of files) {\n try {\n const source = await readFile(file, \"utf-8\");\n workspace.addDocument(source, { filename: file });\n } catch (err) {\n console.error(pc.red(`Error reading ${file}: ${err instanceof Error ? err.message : err}`));\n }\n }\n\n return workspace;\n}\n\n/**\n * Load the full workspace from the current working directory (async).\n * This is the standard way to load a workspace - always includes all files from CWD.\n */\nexport async function loadFullWorkspace(\n fileTypes: string[] = DEFAULT_FILE_TYPES,\n): Promise<{ workspace: Workspace; files: string[] }> {\n const files = await resolveFiles([\".\"], fileTypes);\n const workspace = await loadWorkspace(files);\n return { workspace, files };\n}\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,qBAAqB,CAAC,UAAU,MAAM;;;;AAKnD,MAAa,qBAAqB,CAAC,SAAS,KAAK;;;;AAKjD,SAAgB,aAAa,UAA0B;CACrD,MAAM,MAAM,QAAQ,KAAK;CACzB,MAAM,cAAc,KAAK,QAAQ,IAAI;CACrC,MAAM,mBAAmB,KAAK,QAAQ,SAAS;AAE/C,QADY,KAAK,SAAS,aAAa,iBAAiB,IAC1C;;;;;AAUhB,SAAgB,sBACd,KACA,aAAuB,oBACb;CACV,MAAMA,QAAkB,EAAE;CAE1B,SAAS,KAAK,YAA0B;EACtC,IAAI;AACJ,MAAI;AACF,aAAU,GAAG,YAAY,YAAY,EAAE,eAAe,MAAM,CAAC;UACvD;AACN;;AAGF,OAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,WAAW,KAAK,KAAK,YAAY,MAAM,KAAK;AAElD,OAAI,MAAM,aAAa,EACrB;QAAI,CAAC,MAAM,KAAK,WAAW,IAAI,IAAI,MAAM,SAAS,eAChD,MAAK,SAAS;cAEP,MAAM,QAAQ,EACvB;QAAI,WAAW,MAAM,QAAQ,MAAM,KAAK,SAAS,IAAI,CAAC,CACpD,OAAM,KAAK,SAAS;;;;AAM5B,MAAK,IAAI;AACT,QAAO;;;;;;AAOT,SAAgB,iBACd,OACA,YAAsB,o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AC9B,MAAM,WAAW,QAAQ,WAAW;EAEpC,IAAI;AACJ,MAAI;AACF,cAAW,MAAM,KAAK,SAAS;UACzB;AACN,WAAQ,MAAM,GAAG,IAAI,0BAA0B,aAAa,CAAC;AAC7D,WAAQ,KAAK,EAAE;;AAGjB,MAAI,SAAS,aAAa,CACxB,OAAM,KAAK,GAAI,MAAM,kBAAkB,UAAU,WAAW,CAAE;WACrD,SAAS,QAAQ,EAE1B;OAAI,WAAW,MAAM,QAAQ,SAAS,SAAS,IAAI,CAAC,CAClD,OAAM,KAAK,SAAS;;;AAK1B,QAAO;;;;;AAMT,eAAsB,cAAc,OAAqC;CACvE,MAAM,YAAY,iBAAiB;AAEnC,MAAK,MAAM,QAAQ,MACjB,KAAI;EACF,MAAM,SAAS,MAAM,SAAS,MAAM,QAAQ;AAC5C,YAAU,YAAY,QAAQ,EAAE,UAAU,MAAM,CAAC;UAC1C,KAAK;AACZ,UAAQ,MAAM,GAAG,IAAI,iBAAiB,KAAK,IAAI,eAAe,QAAQ,IAAI,UAAU,MAAM,CAAC;;AAI/F,QAAO;;;;;;AAOT,eAAsB,kBACpB,YAAsB,oBAC8B;CACpD,MAAM,QAAQ,MAAM,aAAa,CAAC,IAAI,EAAE,UAAU;AAElD,QAAO;EAAE,WADS,MAAM,cAAc,MAAM;EACxB;EAAO"}
|
package/dist/mod.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/mod.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { runCli } from "./cli.js";
|
|
2
|
+
import { actualizeCommand } from "./commands/actualize.js";
|
|
3
|
+
import { checkCommand } from "./commands/check.js";
|
|
4
|
+
import { formatCommand } from "./commands/format.js";
|
|
5
|
+
import { initCommand } from "./commands/init.js";
|
|
6
|
+
import { lspCommand } from "./commands/lsp.js";
|
|
7
|
+
import { queryCommand } from "./commands/query.js";
|
|
8
|
+
import { rulesCommand } from "./commands/rules.js";
|
|
9
|
+
import { mergeDriverCommand } from "./commands/merge-driver.js";
|
|
10
|
+
import { setupMergeDriverCommand } from "./commands/setup-merge-driver.js";
|
|
11
|
+
|
|
12
|
+
//#region src/mod.ts
|
|
13
|
+
runCli({
|
|
14
|
+
name: "thalo",
|
|
15
|
+
description: "Lint and check thalo files",
|
|
16
|
+
subcommands: {
|
|
17
|
+
actualize: actualizeCommand,
|
|
18
|
+
check: checkCommand,
|
|
19
|
+
format: formatCommand,
|
|
20
|
+
init: initCommand,
|
|
21
|
+
lsp: lspCommand,
|
|
22
|
+
query: queryCommand,
|
|
23
|
+
rules: rulesCommand,
|
|
24
|
+
"merge-driver": mergeDriverCommand,
|
|
25
|
+
"setup-merge-driver": setupMergeDriverCommand
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { };
|
|
31
|
+
//# sourceMappingURL=mod.js.map
|
package/dist/mod.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","names":[],"sources":["../src/mod.ts"],"sourcesContent":["import { runCli, type CommandDef } from \"./cli.js\";\nimport { actualizeCommand } from \"./commands/actualize.js\";\nimport { checkCommand } from \"./commands/check.js\";\nimport { formatCommand } from \"./commands/format.js\";\nimport { initCommand } from \"./commands/init.js\";\nimport { lspCommand } from \"./commands/lsp.js\";\nimport { queryCommand } from \"./commands/query.js\";\nimport { rulesCommand } from \"./commands/rules.js\";\nimport { mergeDriverCommand } from \"./commands/merge-driver.js\";\nimport { setupMergeDriverCommand } from \"./commands/setup-merge-driver.js\";\n\n/**\n * Root command definition\n *\n * When invoked without a subcommand, shows help\n */\nconst rootCommand: CommandDef = {\n name: \"thalo\",\n description: \"Lint and check thalo files\",\n subcommands: {\n actualize: actualizeCommand,\n check: checkCommand,\n format: formatCommand,\n init: initCommand,\n lsp: lspCommand,\n query: queryCommand,\n rules: rulesCommand,\n \"merge-driver\": mergeDriverCommand,\n \"setup-merge-driver\": setupMergeDriverCommand,\n },\n};\n\nrunCli(rootCommand);\n"],"mappings":";;;;;;;;;;;;AAgCA,OAhBgC;CAC9B,MAAM;CACN,aAAa;CACb,aAAa;EACX,WAAW;EACX,OAAO;EACP,QAAQ;EACR,MAAM;EACN,KAAK;EACL,OAAO;EACP,OAAO;EACP,gBAAgB;EAChB,sBAAsB;EACvB;CACF,CAEkB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rejot-dev/thalo-cli",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/rejot-dev/thalo.git",
|
|
8
|
+
"directory": "apps/thalo-cli"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"bin"
|
|
14
|
+
],
|
|
15
|
+
"bin": {
|
|
16
|
+
"thalo": "./bin/run.js"
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"development": "./src/mod.ts",
|
|
21
|
+
"types": "./dist/mod.d.ts",
|
|
22
|
+
"default": "./dist/mod.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/mod.js",
|
|
26
|
+
"types": "./dist/mod.d.ts",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"ignore": "^7.0.5",
|
|
29
|
+
"picocolors": "^1.1.1",
|
|
30
|
+
"prettier": "^3.5.3",
|
|
31
|
+
"tree-sitter": "^0.25.0",
|
|
32
|
+
"vscode-languageserver": "^9.0.1",
|
|
33
|
+
"@rejot-dev/thalo": "0.0.0",
|
|
34
|
+
"@rejot-dev/thalo-lsp": "0.0.0",
|
|
35
|
+
"@rejot-dev/thalo-prettier": "0.0.0",
|
|
36
|
+
"@rejot-dev/tree-sitter-thalo": "0.0.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^24",
|
|
40
|
+
"tsdown": "^0.15.12",
|
|
41
|
+
"tsx": "4.21.0",
|
|
42
|
+
"typescript": "^5.7.3",
|
|
43
|
+
"vitest": "^3.2.4",
|
|
44
|
+
"@rejot-private/typescript-config": "0.0.1"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"dev": "tsx src/mod.ts",
|
|
48
|
+
"build": "tsdown",
|
|
49
|
+
"build:watch": "tsdown --watch",
|
|
50
|
+
"types:check": "tsc --noEmit",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"test:watch": "vitest --watch"
|
|
53
|
+
}
|
|
54
|
+
}
|