@ldlework/workmark 1.4.2 → 1.5.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/dist/cli.js +15 -0
- package/dist/lib/jiti-options.d.ts +1 -1
- package/dist/lib/jiti-options.js +14 -11
- package/package.json +1 -1
- package/src/cli.ts +32 -0
- package/src/lib/jiti-options.ts +14 -11
package/dist/cli.js
CHANGED
|
@@ -69,6 +69,17 @@ function printCommandHelp(cmd) {
|
|
|
69
69
|
console.log(`${flag.padEnd(20)} ${desc}${parts.length ? " " + parts.join(", ") : ""}`);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
+
function toCommandMeta(cmd) {
|
|
73
|
+
return {
|
|
74
|
+
name: cmd.name,
|
|
75
|
+
label: cmd.label,
|
|
76
|
+
group: cmd.group,
|
|
77
|
+
description: cmd.description,
|
|
78
|
+
inputSchema: cmd.inputSchema,
|
|
79
|
+
positional: cmd.positional,
|
|
80
|
+
sourceFile: cmd.sourceFile ?? null,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
72
83
|
// ---------------------------------------------------------------------------
|
|
73
84
|
// Main
|
|
74
85
|
// ---------------------------------------------------------------------------
|
|
@@ -76,6 +87,10 @@ async function main() {
|
|
|
76
87
|
const [command, ...rest] = process.argv.slice(2);
|
|
77
88
|
const workspace = await loadWorkspace();
|
|
78
89
|
const commands = await loadCommands(workspace);
|
|
90
|
+
if (command === "--introspect") {
|
|
91
|
+
process.stdout.write(JSON.stringify(commands.map(toCommandMeta)) + "\n");
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
79
94
|
if (!command || command === "--help" || command === "-h") {
|
|
80
95
|
printHelp(commands);
|
|
81
96
|
return;
|
|
@@ -2,6 +2,6 @@ import type { JitiOptions } from "jiti";
|
|
|
2
2
|
/**
|
|
3
3
|
* Build jiti options that let wm.ts / command files import from
|
|
4
4
|
* `@ldlework/workmark/*` and from workmark's own dependencies (zod, etc.)
|
|
5
|
-
* regardless of how the package is installed or
|
|
5
|
+
* regardless of how the package is installed, linked, or baked into a host.
|
|
6
6
|
*/
|
|
7
7
|
export declare function jitiOptions(opts?: Partial<JitiOptions>): JitiOptions;
|
package/dist/lib/jiti-options.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import { dirname, join } from "node:path";
|
|
1
|
+
import { dirname, extname, join } from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
// Resolve
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
// Resolve sibling modules from this file's own location and extension, so the
|
|
4
|
+
// aliases work whether we're running from src/ (.ts) or a shipped/baked dist/
|
|
5
|
+
// (.js) — no dependency on src/ being present alongside the compiled output.
|
|
6
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const EXT = extname(fileURLToPath(import.meta.url));
|
|
8
|
+
const lib = (name) => join(HERE, `${name}${EXT}`);
|
|
6
9
|
/**
|
|
7
10
|
* Build jiti options that let wm.ts / command files import from
|
|
8
11
|
* `@ldlework/workmark/*` and from workmark's own dependencies (zod, etc.)
|
|
9
|
-
* regardless of how the package is installed or
|
|
12
|
+
* regardless of how the package is installed, linked, or baked into a host.
|
|
10
13
|
*/
|
|
11
14
|
export function jitiOptions(opts) {
|
|
12
15
|
return {
|
|
13
16
|
interopDefault: true,
|
|
14
17
|
moduleCache: false,
|
|
15
18
|
alias: {
|
|
16
|
-
"@ldlework/workmark/types":
|
|
17
|
-
"@ldlework/workmark/helpers":
|
|
18
|
-
"@ldlework/workmark/define":
|
|
19
|
-
"@ldlework/workmark/workspace":
|
|
20
|
-
"@ldlework/workmark/project":
|
|
21
|
-
"@ldlework/workmark":
|
|
19
|
+
"@ldlework/workmark/types": lib("types"),
|
|
20
|
+
"@ldlework/workmark/helpers": lib("helpers"),
|
|
21
|
+
"@ldlework/workmark/define": lib("define"),
|
|
22
|
+
"@ldlework/workmark/workspace": lib("workspace"),
|
|
23
|
+
"@ldlework/workmark/project": lib("project"),
|
|
24
|
+
"@ldlework/workmark": lib("load"),
|
|
22
25
|
},
|
|
23
26
|
nativeModules: ["zod", "@modelcontextprotocol/sdk"],
|
|
24
27
|
...opts,
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -79,6 +79,33 @@ function printCommandHelp(cmd: ResolvedCommand): void {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
// Introspection — machine-readable command metadata (consumed by the VS Code
|
|
84
|
+
// extension, which spawns `wm --introspect` instead of importing the loader).
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
|
|
87
|
+
interface CommandMetaJson {
|
|
88
|
+
name: string;
|
|
89
|
+
label: string;
|
|
90
|
+
group: string;
|
|
91
|
+
description: string;
|
|
92
|
+
inputSchema: unknown;
|
|
93
|
+
positional: string[];
|
|
94
|
+
sourceFile: string | null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function toCommandMeta(cmd: ResolvedCommand): CommandMetaJson {
|
|
98
|
+
return {
|
|
99
|
+
name: cmd.name,
|
|
100
|
+
label: cmd.label,
|
|
101
|
+
group: cmd.group,
|
|
102
|
+
description: cmd.description,
|
|
103
|
+
inputSchema: cmd.inputSchema,
|
|
104
|
+
positional: cmd.positional,
|
|
105
|
+
sourceFile: cmd.sourceFile ?? null,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
82
109
|
// ---------------------------------------------------------------------------
|
|
83
110
|
// Main
|
|
84
111
|
// ---------------------------------------------------------------------------
|
|
@@ -89,6 +116,11 @@ async function main(): Promise<void> {
|
|
|
89
116
|
const workspace = await loadWorkspace();
|
|
90
117
|
const commands = await loadCommands(workspace);
|
|
91
118
|
|
|
119
|
+
if (command === "--introspect") {
|
|
120
|
+
process.stdout.write(JSON.stringify(commands.map(toCommandMeta)) + "\n");
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
92
124
|
if (!command || command === "--help" || command === "-h") {
|
|
93
125
|
printHelp(commands);
|
|
94
126
|
return;
|
package/src/lib/jiti-options.ts
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
import { dirname, join } from "node:path";
|
|
1
|
+
import { dirname, extname, join } from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import type { JitiOptions } from "jiti";
|
|
4
4
|
|
|
5
|
-
// Resolve
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
// Resolve sibling modules from this file's own location and extension, so the
|
|
6
|
+
// aliases work whether we're running from src/ (.ts) or a shipped/baked dist/
|
|
7
|
+
// (.js) — no dependency on src/ being present alongside the compiled output.
|
|
8
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const EXT = extname(fileURLToPath(import.meta.url));
|
|
10
|
+
const lib = (name: string) => join(HERE, `${name}${EXT}`);
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* Build jiti options that let wm.ts / command files import from
|
|
11
14
|
* `@ldlework/workmark/*` and from workmark's own dependencies (zod, etc.)
|
|
12
|
-
* regardless of how the package is installed or
|
|
15
|
+
* regardless of how the package is installed, linked, or baked into a host.
|
|
13
16
|
*/
|
|
14
17
|
export function jitiOptions(opts?: Partial<JitiOptions>): JitiOptions {
|
|
15
18
|
return {
|
|
16
19
|
interopDefault: true,
|
|
17
20
|
moduleCache: false,
|
|
18
21
|
alias: {
|
|
19
|
-
"@ldlework/workmark/types":
|
|
20
|
-
"@ldlework/workmark/helpers":
|
|
21
|
-
"@ldlework/workmark/define":
|
|
22
|
-
"@ldlework/workmark/workspace":
|
|
23
|
-
"@ldlework/workmark/project":
|
|
24
|
-
"@ldlework/workmark":
|
|
22
|
+
"@ldlework/workmark/types": lib("types"),
|
|
23
|
+
"@ldlework/workmark/helpers": lib("helpers"),
|
|
24
|
+
"@ldlework/workmark/define": lib("define"),
|
|
25
|
+
"@ldlework/workmark/workspace": lib("workspace"),
|
|
26
|
+
"@ldlework/workmark/project": lib("project"),
|
|
27
|
+
"@ldlework/workmark": lib("load"),
|
|
25
28
|
},
|
|
26
29
|
nativeModules: ["zod", "@modelcontextprotocol/sdk"],
|
|
27
30
|
...opts,
|