@treeseed/cli 0.4.5 → 0.4.7
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/README.md +2 -2
- package/dist/cli/help.js +1 -1
- package/dist/cli/runtime.d.ts +4 -4
- package/dist/cli/runtime.js +47 -1
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -14,10 +14,10 @@ This package publishes the `treeseed` binary. `@treeseed/sdk` owns the reusable
|
|
|
14
14
|
Install the CLI with its runtime dependencies:
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
npm install @treeseed/cli @treeseed/core @treeseed/sdk
|
|
17
|
+
npm install @treeseed/cli @treeseed/core @treeseed/sdk
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
`@treeseed/cli` is a thin installable wrapper over `@treeseed/sdk` workflow and operations interfaces plus the `@treeseed/
|
|
20
|
+
`@treeseed/cli` is a thin installable wrapper over `@treeseed/sdk` workflow and operations interfaces plus the `@treeseed/core` runtime namespaces. `treeseed dev` and `treeseed agents ...` resolve and delegate to the tenant-installed or sibling-workspace `@treeseed/core` runtime. In normal consumer installs, npm resolves the runtime dependencies automatically.
|
|
21
21
|
|
|
22
22
|
After installation, the published binary is available as:
|
|
23
23
|
|
package/dist/cli/help.js
CHANGED
|
@@ -108,7 +108,7 @@ function renderTreeseedHelp(commandName) {
|
|
|
108
108
|
" treeseed agents --help",
|
|
109
109
|
"",
|
|
110
110
|
"Notes",
|
|
111
|
-
" - Delegates to the `@treeseed/
|
|
111
|
+
" - Delegates to the integrated `@treeseed/core` agent runtime.",
|
|
112
112
|
" - Use `treeseed agents --help` to list supported agent subcommands."
|
|
113
113
|
].join("\n");
|
|
114
114
|
}
|
package/dist/cli/runtime.d.ts
CHANGED
|
@@ -19,13 +19,13 @@ export declare class TreeseedOperationsSdk {
|
|
|
19
19
|
private executeHandler;
|
|
20
20
|
private executeAdapter;
|
|
21
21
|
private executeAgents;
|
|
22
|
-
executeOperation(request: TreeseedOperationRequest, overrides?: Partial<TreeseedCommandContext>): Promise<
|
|
23
|
-
run(argv: string[], overrides?: Partial<TreeseedCommandContext>): Promise<
|
|
22
|
+
executeOperation(request: TreeseedOperationRequest, overrides?: Partial<TreeseedCommandContext>): Promise<any>;
|
|
23
|
+
run(argv: string[], overrides?: Partial<TreeseedCommandContext>): Promise<any>;
|
|
24
24
|
}
|
|
25
25
|
export declare function resolveTreeseedCommandCwd(spec: TreeseedOperationSpec, cwd: string): {
|
|
26
26
|
cwd: string;
|
|
27
27
|
resolvedProjectRoot: string | null;
|
|
28
28
|
resolvedWorkspaceRoot: any;
|
|
29
29
|
};
|
|
30
|
-
export declare function executeTreeseedCommand(commandName: string, argv: string[], context: TreeseedCommandContext): Promise<
|
|
31
|
-
export declare function runTreeseedCli(argv: string[], overrides?: Partial<TreeseedCommandContext>): Promise<
|
|
30
|
+
export declare function executeTreeseedCommand(commandName: string, argv: string[], context: TreeseedCommandContext): Promise<any>;
|
|
31
|
+
export declare function runTreeseedCli(argv: string[], overrides?: Partial<TreeseedCommandContext>): Promise<any>;
|
package/dist/cli/runtime.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
1
2
|
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
2
6
|
import { findNearestTreeseedRoot, findNearestTreeseedWorkspaceRoot } from "@treeseed/sdk/workflow-support";
|
|
3
7
|
import { TreeseedOperationsSdk as SdkOperationsRuntime } from "@treeseed/sdk/operations";
|
|
4
8
|
import { COMMAND_HANDLERS } from "./registry.js";
|
|
5
9
|
import { renderTreeseedHelp, renderUsage, suggestTreeseedCommands } from "./operations-help.js";
|
|
6
10
|
import { parseTreeseedInvocation, validateTreeseedInvocation } from "./operations-parser.js";
|
|
7
11
|
import { findTreeseedOperation, TRESEED_OPERATION_SPECS } from "./operations-registry.js";
|
|
12
|
+
const require2 = createRequire(import.meta.url);
|
|
8
13
|
function isHelpFlag(value) {
|
|
9
14
|
return value === "--help" || value === "-h";
|
|
10
15
|
}
|
|
@@ -16,6 +21,43 @@ function defaultWrite(output, stream = "stdout") {
|
|
|
16
21
|
function defaultSpawn(command, args, options) {
|
|
17
22
|
return spawnSync(command, args, options);
|
|
18
23
|
}
|
|
24
|
+
function resolveCoreAgentCliEntrypoint(cwd) {
|
|
25
|
+
const workspaceRoot = findNearestTreeseedWorkspaceRoot(cwd) ?? cwd;
|
|
26
|
+
const workspacePackageJsonPath = resolve(workspaceRoot, "packages", "core", "package.json");
|
|
27
|
+
const siblingPackageJsonPath = resolve(cwd, "..", "core", "package.json");
|
|
28
|
+
const installedPackageJsonPath = resolve(cwd, "node_modules", "@treeseed", "core", "package.json");
|
|
29
|
+
let packageJsonPath = workspacePackageJsonPath;
|
|
30
|
+
if (!existsSync(packageJsonPath)) {
|
|
31
|
+
packageJsonPath = existsSync(siblingPackageJsonPath) ? siblingPackageJsonPath : installedPackageJsonPath;
|
|
32
|
+
}
|
|
33
|
+
if (!existsSync(packageJsonPath)) {
|
|
34
|
+
try {
|
|
35
|
+
const resolvedPath = require2.resolve("@treeseed/core", { paths: [cwd] });
|
|
36
|
+
let currentDir = dirname(resolvedPath);
|
|
37
|
+
while (!existsSync(resolve(currentDir, "package.json"))) {
|
|
38
|
+
const parentDir = dirname(currentDir);
|
|
39
|
+
if (parentDir === currentDir) {
|
|
40
|
+
throw new Error("Unable to resolve the installed @treeseed/core package root.");
|
|
41
|
+
}
|
|
42
|
+
currentDir = parentDir;
|
|
43
|
+
}
|
|
44
|
+
packageJsonPath = resolve(currentDir, "package.json");
|
|
45
|
+
} catch {
|
|
46
|
+
throw new Error(
|
|
47
|
+
"Treeseed agent commands require the integrated `@treeseed/core` runtime. Install `@treeseed/core` in the current project or run the CLI inside a Treeseed workspace."
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const packageRoot = dirname(packageJsonPath);
|
|
52
|
+
const sourceEntrypoint = resolve(packageRoot, "src", "agents", "cli.ts");
|
|
53
|
+
if (existsSync(sourceEntrypoint)) {
|
|
54
|
+
return pathToFileURL(sourceEntrypoint).href;
|
|
55
|
+
}
|
|
56
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
57
|
+
const exportedEntrypoint = packageJson.exports?.["./agent/cli"];
|
|
58
|
+
const distRelativePath = typeof exportedEntrypoint === "string" ? exportedEntrypoint : exportedEntrypoint?.default ?? "./dist/agents/cli.js";
|
|
59
|
+
return pathToFileURL(resolve(packageRoot, distRelativePath)).href;
|
|
60
|
+
}
|
|
19
61
|
const sdkOperationsRuntime = new SdkOperationsRuntime();
|
|
20
62
|
function formatValidationError(spec, errors) {
|
|
21
63
|
return [
|
|
@@ -148,7 +190,7 @@ class TreeseedOperationsSdk {
|
|
|
148
190
|
}
|
|
149
191
|
async executeAgents(argv, context) {
|
|
150
192
|
try {
|
|
151
|
-
const { runTreeseedAgentCli } = await import(
|
|
193
|
+
const { runTreeseedAgentCli } = await import(resolveCoreAgentCliEntrypoint(context.cwd));
|
|
152
194
|
return await runTreeseedAgentCli(argv, {
|
|
153
195
|
cwd: context.cwd,
|
|
154
196
|
env: context.env,
|
|
@@ -172,6 +214,10 @@ class TreeseedOperationsSdk {
|
|
|
172
214
|
const argv = request.argv ?? [];
|
|
173
215
|
const commandName = request.commandName;
|
|
174
216
|
if (commandName === "agents") {
|
|
217
|
+
if (argv.some(isHelpFlag)) {
|
|
218
|
+
context.write(renderTreeseedHelp("agents"), "stdout");
|
|
219
|
+
return 0;
|
|
220
|
+
}
|
|
175
221
|
return this.executeAgents(argv, context);
|
|
176
222
|
}
|
|
177
223
|
const spec = findTreeseedOperation(commandName);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treeseed/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "Operator-facing Treeseed CLI package.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -43,8 +43,7 @@
|
|
|
43
43
|
"release:publish": "node ./scripts/run-ts.mjs ./scripts/publish-package.ts"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@treeseed/
|
|
47
|
-
"@treeseed/sdk": "^0.4.4"
|
|
46
|
+
"@treeseed/sdk": "^0.4.6"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
49
|
"@types/node": "^24.6.0",
|