@pluginfinity/cli 0.0.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.
- package/LICENSE +21 -0
- package/README.md +24 -0
- package/cli/program.js +30 -0
- package/cli/run.js +38 -0
- package/commands/build.js +25 -0
- package/commands/doctor.js +28 -0
- package/commands/init.js +33 -0
- package/commands/name.js +10 -0
- package/commands/plugin.js +21 -0
- package/commands/shared.js +38 -0
- package/commands/validate.js +25 -0
- package/index.d.ts +59 -0
- package/index.js +3 -0
- package/main.d.ts +34 -0
- package/main.js +34 -0
- package/package.json +60 -0
- package/render/config-error.js +31 -0
- package/render/doctor.js +31 -0
- package/tsdoc-metadata.json +11 -0
- package/version.js +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 C. Spencer Beggs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @pluginfinity/cli
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@pluginfinity/cli)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
|
|
8
|
+
The command-line front end of [pluginfinity](https://github.com/spencerbeggs/pluginfinity): the command tree, its flags and its output for people, agents and CI. It declares no bin of its own; the `pluginfinity` package runs it.
|
|
9
|
+
|
|
10
|
+
> **Under development.** This package is part of [pluginfinity](https://www.npmjs.com/package/pluginfinity), which is in early `0.x` development. It installs and runs, but pluginfinity does not build plugins yet, and this package's contents will change without notice between `0.x` releases.
|
|
11
|
+
|
|
12
|
+
## Install pluginfinity instead
|
|
13
|
+
|
|
14
|
+
The `pluginfinity` command comes from the `pluginfinity` package, which runs this front end for you.
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add -D pluginfinity
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
This package is an internal layer of the pluginfinity CLI. It is published so that `pluginfinity` installs, not as an API: nothing it exports is supported for direct import, and only what the `pluginfinity` package exports carries a stability promise.
|
|
21
|
+
|
|
22
|
+
## License
|
|
23
|
+
|
|
24
|
+
[MIT](LICENSE)
|
package/cli/program.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { buildCommand } from "../commands/build.js";
|
|
2
|
+
import { doctorCommand } from "../commands/doctor.js";
|
|
3
|
+
import { initCommand } from "../commands/init.js";
|
|
4
|
+
import { pluginCommand } from "../commands/plugin.js";
|
|
5
|
+
import { validateCommand } from "../commands/validate.js";
|
|
6
|
+
import { CliAudience } from "@effected/cli";
|
|
7
|
+
import { Command } from "effect/cli";
|
|
8
|
+
|
|
9
|
+
//#region src/cli/program.ts
|
|
10
|
+
const root = (launch) => Command.make("pluginfinity").pipe(Command.withDescription("Build one agent-plugin source into per-host plugin outputs (Claude Code, GitHub Copilot)"), Command.withSharedFlags(CliAudience.flags()), Command.withSubcommands([
|
|
11
|
+
initCommand,
|
|
12
|
+
pluginCommand,
|
|
13
|
+
buildCommand(launch),
|
|
14
|
+
validateCommand(launch),
|
|
15
|
+
doctorCommand(launch)
|
|
16
|
+
]));
|
|
17
|
+
/**
|
|
18
|
+
* Parse `args` and run the selected command, with the audience flags
|
|
19
|
+
* resolved before core parses.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* The return type is spelled out because TypeScript cannot name the inferred
|
|
23
|
+
* `Audience` requirement through `@effected/cli` alone (TS2883).
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
const program = (args, deps) => CliAudience.runWith(root(deps), { version: deps.version })(args);
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { program };
|
package/cli/run.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { program } from "./program.js";
|
|
2
|
+
import { CliRuntime } from "@effected/cli";
|
|
3
|
+
import { ToolDiscoveryLive } from "@pluginfinity/engine";
|
|
4
|
+
import { Effect } from "effect";
|
|
5
|
+
import { CurrentDistribution, distributionSuffix } from "@effected/engine";
|
|
6
|
+
|
|
7
|
+
//#region src/cli/run.ts
|
|
8
|
+
/**
|
|
9
|
+
* Run `args` through the program under `CliRuntime.main`.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* Reads `CurrentDistribution`, a reference that defaults to none, so a caller
|
|
13
|
+
* provides it only for a carrier launch.
|
|
14
|
+
*/
|
|
15
|
+
const run = (args, options) => Effect.gen(function* () {
|
|
16
|
+
const distribution = yield* CurrentDistribution;
|
|
17
|
+
const deps = {
|
|
18
|
+
version: options.version,
|
|
19
|
+
cwd: options.cwd,
|
|
20
|
+
nodeVersion: options.nodeVersion
|
|
21
|
+
};
|
|
22
|
+
return yield* CliRuntime.main(program(args, deps).pipe(Effect.provide(options.tools ?? ToolDiscoveryLive)), {
|
|
23
|
+
platform: options.platform,
|
|
24
|
+
helpOnUsageError: "stderr",
|
|
25
|
+
env: {
|
|
26
|
+
audienceEnvVar: "PLUGINFINITY_AUDIENCE",
|
|
27
|
+
...options.stderrIsTerminal === void 0 ? {} : { stderrIsTerminal: options.stderrIsTerminal },
|
|
28
|
+
log: {
|
|
29
|
+
envVar: "PLUGINFINITY_LOG_LEVEL",
|
|
30
|
+
argv: args
|
|
31
|
+
},
|
|
32
|
+
formatter: { formatVersion: (name, version) => `${name} v${version}${distributionSuffix(distribution)}` }
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { run };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { reportConfigError } from "../render/config-error.js";
|
|
2
|
+
import { allFlag, configFlag, pathArgument, targetFlag, toSelection } from "./shared.js";
|
|
3
|
+
import { Command, Flag } from "effect/cli";
|
|
4
|
+
import { build, isConfigError } from "@pluginfinity/engine";
|
|
5
|
+
import { Effect } from "effect";
|
|
6
|
+
|
|
7
|
+
//#region src/commands/build.ts
|
|
8
|
+
/** `pluginfinity build [path]`: regenerate `builds/<id>/` from source. */
|
|
9
|
+
const buildCommand = (launch) => Command.make("build", {
|
|
10
|
+
path: pathArgument,
|
|
11
|
+
target: targetFlag,
|
|
12
|
+
all: allFlag,
|
|
13
|
+
check: Flag.Boolean("check").pipe(Flag.withDefault(false), Flag.withDescription("rebuild in memory, compare with builds/, fail on any difference")),
|
|
14
|
+
config: configFlag
|
|
15
|
+
}, (input) => Effect.gen(function* () {
|
|
16
|
+
const selection = yield* toSelection(launch, input);
|
|
17
|
+
yield* build({
|
|
18
|
+
selection,
|
|
19
|
+
targets: input.target,
|
|
20
|
+
check: input.check
|
|
21
|
+
}).pipe(Effect.catchIf(isConfigError, reportConfigError));
|
|
22
|
+
})).pipe(Command.withDescription("Regenerate builds/<id>/ from source"));
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { buildCommand };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { allFlag, configFlag, pathArgument, toSelection } from "./shared.js";
|
|
2
|
+
import { doctorJson, doctorLines } from "../render/doctor.js";
|
|
3
|
+
import { CliExit } from "@effected/cli";
|
|
4
|
+
import { Command, Flag } from "effect/cli";
|
|
5
|
+
import { runDoctor } from "@pluginfinity/engine";
|
|
6
|
+
import { Console, Effect } from "effect";
|
|
7
|
+
import { Audience } from "@effected/env";
|
|
8
|
+
|
|
9
|
+
//#region src/commands/doctor.ts
|
|
10
|
+
/** `pluginfinity doctor [path]`: report on the environment. */
|
|
11
|
+
const doctorCommand = (launch) => Command.make("doctor", {
|
|
12
|
+
path: pathArgument,
|
|
13
|
+
all: allFlag,
|
|
14
|
+
config: configFlag,
|
|
15
|
+
strict: Flag.Boolean("strict").pipe(Flag.withDefault(false), Flag.withDescription("exit 1 when a required check fails"))
|
|
16
|
+
}, (input) => Effect.gen(function* () {
|
|
17
|
+
const selection = yield* toSelection(launch, input);
|
|
18
|
+
const report = yield* runDoctor({
|
|
19
|
+
selection,
|
|
20
|
+
nodeVersion: launch.nodeVersion
|
|
21
|
+
});
|
|
22
|
+
if ((yield* Audience).kind === "human") for (const line of doctorLines(report)) yield* Console.log(line);
|
|
23
|
+
else yield* Console.log(doctorJson(report));
|
|
24
|
+
if (input.strict && !report.ok) yield* CliExit.set(1);
|
|
25
|
+
})).pipe(Command.withDescription("Report on the environment: runtime, host CLIs, tools and the config"));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { doctorCommand };
|
package/commands/init.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { targetFlag } from "./shared.js";
|
|
2
|
+
import { checkPluginName } from "./name.js";
|
|
3
|
+
import { Argument, Command, Flag } from "effect/cli";
|
|
4
|
+
import { NotImplemented } from "@pluginfinity/engine";
|
|
5
|
+
import { Effect } from "effect";
|
|
6
|
+
|
|
7
|
+
//#region src/commands/init.ts
|
|
8
|
+
/** `pluginfinity init [dir]`: create a plugin repository and its first plugin. A stub. */
|
|
9
|
+
const initCommand = Command.make("init", {
|
|
10
|
+
dir: Argument.String("dir").pipe(Argument.optional, Argument.withDescription("where to create the repository (default: ./<name>/)")),
|
|
11
|
+
layout: Flag.Literals("layout", [
|
|
12
|
+
"root",
|
|
13
|
+
"plugin",
|
|
14
|
+
"plugins"
|
|
15
|
+
]).pipe(Flag.withDefault("root"), Flag.withDescription("where the plugin source lives")),
|
|
16
|
+
name: Flag.String("name").pipe(Flag.optional, Flag.withDescription("the first plugin's name")),
|
|
17
|
+
pm: Flag.Literals("pm", [
|
|
18
|
+
"pnpm",
|
|
19
|
+
"npm",
|
|
20
|
+
"yarn",
|
|
21
|
+
"bun"
|
|
22
|
+
]).pipe(Flag.withDefault("pnpm"), Flag.withDescription("the package manager")),
|
|
23
|
+
target: targetFlag,
|
|
24
|
+
noChangesets: Flag.Boolean("no-changesets").pipe(Flag.withDefault(false), Flag.withDescription("skip the Changesets and versionFiles wiring")),
|
|
25
|
+
noCi: Flag.Boolean("no-ci").pipe(Flag.withDefault(false), Flag.withDescription("skip the CI workflow")),
|
|
26
|
+
yes: Flag.Boolean("yes").pipe(Flag.withDefault(false), Flag.withDescription("accept defaults, no prompts"))
|
|
27
|
+
}, (input) => Effect.gen(function* () {
|
|
28
|
+
if (input.name._tag === "Some") yield* checkPluginName("--name", input.name.value);
|
|
29
|
+
return yield* Effect.fail(new NotImplemented({ operation: "init" }));
|
|
30
|
+
})).pipe(Command.withDescription("Create a plugin repository and its first plugin"));
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { initCommand };
|
package/commands/name.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CliError } from "effect/cli";
|
|
2
|
+
import { Effect, Schema } from "effect";
|
|
3
|
+
import { PluginName } from "@pluginfinity/core";
|
|
4
|
+
|
|
5
|
+
//#region src/commands/name.ts
|
|
6
|
+
/** Check a plugin name from the command line: kebab-case, or a usage error naming the flag. */
|
|
7
|
+
const checkPluginName = (label, name) => Schema.decodeUnknownEffect(PluginName)(name).pipe(Effect.mapError(() => new CliError.UserError({ cause: `${label} "${name}" must be kebab-case: lowercase letters and digits separated by single hyphens` })));
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { checkPluginName };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { targetFlag } from "./shared.js";
|
|
2
|
+
import { checkPluginName } from "./name.js";
|
|
3
|
+
import { Argument, Command, Flag } from "effect/cli";
|
|
4
|
+
import { NotImplemented } from "@pluginfinity/engine";
|
|
5
|
+
import { Effect } from "effect";
|
|
6
|
+
|
|
7
|
+
//#region src/commands/plugin.ts
|
|
8
|
+
/** `pluginfinity plugin add <name>`: add a plugin source. A stub. */
|
|
9
|
+
const addCommand = Command.make("add", {
|
|
10
|
+
name: Argument.String("name").pipe(Argument.withDescription("the new plugin's name")),
|
|
11
|
+
target: targetFlag,
|
|
12
|
+
dir: Flag.String("dir").pipe(Flag.optional, Flag.withDescription("where the plugin goes (default: plugins/<name>)"))
|
|
13
|
+
}, (input) => Effect.gen(function* () {
|
|
14
|
+
yield* checkPluginName("plugin name", input.name);
|
|
15
|
+
return yield* Effect.fail(new NotImplemented({ operation: "plugin add" }));
|
|
16
|
+
})).pipe(Command.withDescription("Add a plugin source"));
|
|
17
|
+
/** `pluginfinity plugin`: the plugin group. A bare invocation prints its help. */
|
|
18
|
+
const pluginCommand = Command.make("plugin").pipe(Command.withDescription("Manage the plugins in this repository"), Command.withSubcommands([addCommand]));
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { pluginCommand };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Argument, CliError, Flag } from "effect/cli";
|
|
2
|
+
import { Effect, FileSystem, Path } from "effect";
|
|
3
|
+
import { KNOWN_TARGET_IDS } from "@pluginfinity/targets";
|
|
4
|
+
|
|
5
|
+
//#region src/commands/shared.ts
|
|
6
|
+
/** `--target <id>`, repeatable. An unknown id is a usage error at parse time. */
|
|
7
|
+
const targetFlag = Flag.Literals("target", KNOWN_TARGET_IDS).pipe(Flag.atLeast(0), Flag.withDescription("a target id; repeatable (default: every enabled target)"));
|
|
8
|
+
/** `--all`: every plugin config below `[path]`. */
|
|
9
|
+
const allFlag = Flag.Boolean("all").pipe(Flag.withDefault(false), Flag.withDescription("every plugin config below path"));
|
|
10
|
+
/** `--config <file>`: an explicit config file, no discovery. */
|
|
11
|
+
const configFlag = Flag.String("config").pipe(Flag.optional, Flag.withDescription("an explicit config file; no discovery"));
|
|
12
|
+
/** `[path]`: where config discovery starts. */
|
|
13
|
+
const pathArgument = Argument.String("path").pipe(Argument.optional, Argument.withDescription("where config discovery starts (default: the current directory)"));
|
|
14
|
+
/**
|
|
15
|
+
* Turn `[path]`, `--all` and `--config` into a selection, resolving relative
|
|
16
|
+
* paths against the launch directory.
|
|
17
|
+
*/
|
|
18
|
+
const toSelection = (launch, input) => Effect.gen(function* () {
|
|
19
|
+
const fs = yield* FileSystem.FileSystem;
|
|
20
|
+
const path = yield* Path.Path;
|
|
21
|
+
if (input.all && input.config._tag === "Some") return yield* Effect.fail(new CliError.UserError({ cause: "--config and --all cannot be used together" }));
|
|
22
|
+
if (input.config._tag === "Some") return {
|
|
23
|
+
_tag: "File",
|
|
24
|
+
path: path.resolve(launch.cwd, input.config.value)
|
|
25
|
+
};
|
|
26
|
+
const start = path.resolve(launch.cwd, input.path._tag === "Some" ? input.path.value : ".");
|
|
27
|
+
if (input.path._tag === "Some" && !(yield* fs.exists(start).pipe(Effect.orElseSucceed(() => false)))) return yield* Effect.fail(new CliError.UserError({ cause: `path "${input.path.value}" does not exist` }));
|
|
28
|
+
return input.all ? {
|
|
29
|
+
_tag: "All",
|
|
30
|
+
start
|
|
31
|
+
} : {
|
|
32
|
+
_tag: "Nearest",
|
|
33
|
+
start
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { allFlag, configFlag, pathArgument, targetFlag, toSelection };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { reportConfigError } from "../render/config-error.js";
|
|
2
|
+
import { allFlag, configFlag, pathArgument, targetFlag, toSelection } from "./shared.js";
|
|
3
|
+
import { Command, Flag } from "effect/cli";
|
|
4
|
+
import { isConfigError, validate } from "@pluginfinity/engine";
|
|
5
|
+
import { Effect } from "effect";
|
|
6
|
+
|
|
7
|
+
//#region src/commands/validate.ts
|
|
8
|
+
/** `pluginfinity validate [path]`: pluginfinity's own checks, then each host's CLI. */
|
|
9
|
+
const validateCommand = (launch) => Command.make("validate", {
|
|
10
|
+
path: pathArgument,
|
|
11
|
+
target: targetFlag,
|
|
12
|
+
all: allFlag,
|
|
13
|
+
config: configFlag,
|
|
14
|
+
noHost: Flag.Boolean("no-host").pipe(Flag.withDefault(false), Flag.withDescription("skip the host CLIs"))
|
|
15
|
+
}, (input) => Effect.gen(function* () {
|
|
16
|
+
const selection = yield* toSelection(launch, input);
|
|
17
|
+
yield* validate({
|
|
18
|
+
selection,
|
|
19
|
+
targets: input.target,
|
|
20
|
+
skipHosts: input.noHost
|
|
21
|
+
}).pipe(Effect.catchIf(isConfigError, reportConfigError));
|
|
22
|
+
})).pipe(Command.withDescription("Run pluginfinity's own checks, then each host's CLI"));
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { validateCommand };
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { CliExit } from "@effected/cli";
|
|
2
|
+
import { ToolDiscovery } from "@effected/commands";
|
|
3
|
+
import { Audience } from "@effected/env";
|
|
4
|
+
import { NotImplemented } from "@pluginfinity/engine";
|
|
5
|
+
import { Effect } from "effect";
|
|
6
|
+
import { CliError, Command } from "effect/cli";
|
|
7
|
+
import { Distribution } from "@effected/engine";
|
|
8
|
+
import "effect/process";
|
|
9
|
+
//#region src/commands/shared.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* The process values a command needs, read once in `main.ts`.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
interface LaunchFacts {
|
|
16
|
+
/** The directory pluginfinity was launched in: where `[path]` resolves from. */
|
|
17
|
+
readonly cwd: string;
|
|
18
|
+
/** The running Node.js version, without a leading `v`. */
|
|
19
|
+
readonly nodeVersion: string;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/cli/program.d.ts
|
|
23
|
+
/**
|
|
24
|
+
* The process values the program runs against, read once in `main.ts`.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
interface ProgramDeps extends LaunchFacts {
|
|
29
|
+
/** The version `--version` prints. */
|
|
30
|
+
readonly version: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Parse `args` and run the selected command, with the audience flags
|
|
34
|
+
* resolved before core parses.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* The return type is spelled out because TypeScript cannot name the inferred
|
|
38
|
+
* `Audience` requirement through `@effected/cli` alone (TS2883).
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export declare const program: (args: ReadonlyArray<string>, deps: ProgramDeps) => Effect.Effect<void, CliError.CliError | NotImplemented, Audience | CliExit | ToolDiscovery | Command.Environment>;
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/cli/run.d.ts
|
|
45
|
+
/**
|
|
46
|
+
* Options for `main`.
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
interface MainOptions {
|
|
51
|
+
/**
|
|
52
|
+
* The package the bin was installed through, passed by a carrier's shim.
|
|
53
|
+
* Absent for a direct run, which prints no `via` suffix.
|
|
54
|
+
*/
|
|
55
|
+
readonly distribution?: Distribution | undefined;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export type { LaunchFacts, MainOptions, ProgramDeps };
|
|
59
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.js
ADDED
package/main.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import "@effected/commands";
|
|
2
|
+
import { Distribution } from "@effected/engine";
|
|
3
|
+
import "effect";
|
|
4
|
+
import "effect/process";
|
|
5
|
+
import "@effected/cli";
|
|
6
|
+
import "@effected/env";
|
|
7
|
+
import "@pluginfinity/engine";
|
|
8
|
+
import "effect/cli";
|
|
9
|
+
//#region src/cli/run.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* Options for `main`.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
interface MainOptions {
|
|
16
|
+
/**
|
|
17
|
+
* The package the bin was installed through, passed by a carrier's shim.
|
|
18
|
+
* Absent for a direct run, which prints no `via` suffix.
|
|
19
|
+
*/
|
|
20
|
+
readonly distribution?: Distribution | undefined;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/main.d.ts
|
|
24
|
+
/**
|
|
25
|
+
* Run pluginfinity against this process's arguments and streams.
|
|
26
|
+
*
|
|
27
|
+
* @param options - the distribution a carrier's shim passes; omitted for a direct run
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export declare const main: (options?: MainOptions) => void;
|
|
32
|
+
//#endregion
|
|
33
|
+
export type { MainOptions };
|
|
34
|
+
//# sourceMappingURL=main.d.ts.map
|
package/main.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { run } from "./cli/run.js";
|
|
2
|
+
import { CLI_VERSION } from "./version.js";
|
|
3
|
+
import { Effect, Option, Runtime } from "effect";
|
|
4
|
+
import { CurrentDistribution } from "@effected/engine";
|
|
5
|
+
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
|
|
6
|
+
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
7
|
+
|
|
8
|
+
//#region src/main.ts
|
|
9
|
+
const exitAfterFlush = (exit, onExit) => Runtime.defaultTeardown(exit, (code) => {
|
|
10
|
+
process.stdout.write("", () => {
|
|
11
|
+
onExit(code);
|
|
12
|
+
process.exit(code);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Run pluginfinity against this process's arguments and streams.
|
|
17
|
+
*
|
|
18
|
+
* @param options - the distribution a carrier's shim passes; omitted for a direct run
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
const main = (options = {}) => {
|
|
23
|
+
const argv = process.argv.slice(2);
|
|
24
|
+
NodeRuntime.runMain(run(argv, {
|
|
25
|
+
version: CLI_VERSION,
|
|
26
|
+
cwd: process.cwd(),
|
|
27
|
+
nodeVersion: process.versions.node,
|
|
28
|
+
platform: NodeServices.layer,
|
|
29
|
+
stderrIsTerminal: Effect.sync(() => process.stderr.isTTY === true)
|
|
30
|
+
}).pipe(Effect.provideService(CurrentDistribution, Option.fromNullishOr(options.distribution))), { teardown: exitAfterFlush });
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { main };
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pluginfinity/cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "The pluginfinity command-line front end. Install the pluginfinity package to get the pluginfinity bin.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"pluginfinity",
|
|
8
|
+
"agent-plugin",
|
|
9
|
+
"cli",
|
|
10
|
+
"effect"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/spencerbeggs/pluginfinity/tree/main/packages/cli#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/spencerbeggs/pluginfinity/issues"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/spencerbeggs/pluginfinity.git",
|
|
19
|
+
"directory": "packages/cli"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": {
|
|
23
|
+
"name": "C. Spencer Beggs",
|
|
24
|
+
"email": "spencer@beggs.codes",
|
|
25
|
+
"url": "https://spencerbeg.gs"
|
|
26
|
+
},
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"type": "module",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./index.d.ts",
|
|
32
|
+
"import": "./index.js",
|
|
33
|
+
"default": "./index.js"
|
|
34
|
+
},
|
|
35
|
+
"./main": {
|
|
36
|
+
"types": "./main.d.ts",
|
|
37
|
+
"import": "./main.js",
|
|
38
|
+
"default": "./main.js"
|
|
39
|
+
},
|
|
40
|
+
"./package.json": "./package.json"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@effect/platform-node": "^4.0.0",
|
|
44
|
+
"@effected/cli": "^0.11.0",
|
|
45
|
+
"@effected/commands": "^0.11.0",
|
|
46
|
+
"@effected/engine": "^0.3.0",
|
|
47
|
+
"@effected/env": "^0.1.0",
|
|
48
|
+
"@effected/glob": "^0.10.0",
|
|
49
|
+
"@effected/semver": "^0.11.0",
|
|
50
|
+
"@effected/walker": "^0.15.0",
|
|
51
|
+
"@pluginfinity/core": "0.0.1",
|
|
52
|
+
"@pluginfinity/engine": "0.0.1",
|
|
53
|
+
"@pluginfinity/targets": "0.0.1",
|
|
54
|
+
"effect": "^4.0.0",
|
|
55
|
+
"jiti": "^2.6.1"
|
|
56
|
+
},
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=24.11.0"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CliExit } from "@effected/cli";
|
|
2
|
+
import { ENGINE_VERSION } from "@pluginfinity/engine";
|
|
3
|
+
import { Console, Effect, Option } from "effect";
|
|
4
|
+
import { CurrentDistribution } from "@effected/engine";
|
|
5
|
+
import { Audience } from "@effected/env";
|
|
6
|
+
|
|
7
|
+
//#region src/render/config-error.ts
|
|
8
|
+
/** Report a config error for the current audience and record exit code 1. */
|
|
9
|
+
const reportConfigError = (error) => Effect.gen(function* () {
|
|
10
|
+
if ((yield* Audience).kind === "human") {
|
|
11
|
+
yield* Console.error(`✗ ${error.message}`);
|
|
12
|
+
yield* Console.error(` ${error.remediation.hint}`);
|
|
13
|
+
} else {
|
|
14
|
+
const distribution = yield* CurrentDistribution;
|
|
15
|
+
yield* Console.log(JSON.stringify({
|
|
16
|
+
engine_version: ENGINE_VERSION,
|
|
17
|
+
distribution: Option.getOrNull(distribution),
|
|
18
|
+
ok: false,
|
|
19
|
+
error: {
|
|
20
|
+
tag: error._tag,
|
|
21
|
+
path: error.path,
|
|
22
|
+
message: error.message,
|
|
23
|
+
remediation: error.remediation
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
yield* CliExit.set(1);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { reportConfigError };
|
package/render/doctor.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/render/doctor.ts
|
|
2
|
+
const GROUP_TITLES = [
|
|
3
|
+
["runtime", "Runtime"],
|
|
4
|
+
["hosts", "Hosts"],
|
|
5
|
+
["tools", "Tools"],
|
|
6
|
+
["config", "Config"]
|
|
7
|
+
];
|
|
8
|
+
const glyph = (check) => check.status === "pass" ? "✓" : check.severity === "required" ? "✗" : "!";
|
|
9
|
+
/** The checklist lines a person reads, one remediation line under each failure. */
|
|
10
|
+
const doctorLines = (report) => GROUP_TITLES.flatMap(([group, title]) => {
|
|
11
|
+
const checks = report.checks.filter((check) => check.group === group);
|
|
12
|
+
if (checks.length === 0) return [];
|
|
13
|
+
return [title, ...checks.flatMap((check) => [` ${glyph(check)} ${check.label}: ${check.detail}`, ...check.status === "fail" && check.remediation !== null ? [` ${check.remediation.hint}`] : []])];
|
|
14
|
+
});
|
|
15
|
+
/** The one JSON object `--agent` and `--ci` read. */
|
|
16
|
+
const doctorJson = (report) => JSON.stringify({
|
|
17
|
+
engine_version: report.engineVersion,
|
|
18
|
+
distribution: report.distribution,
|
|
19
|
+
ok: report.ok,
|
|
20
|
+
checks: report.checks.map((check) => ({
|
|
21
|
+
id: check.id,
|
|
22
|
+
status: check.status,
|
|
23
|
+
severity: check.severity,
|
|
24
|
+
version: check.version,
|
|
25
|
+
path: check.path,
|
|
26
|
+
remediation: check.remediation
|
|
27
|
+
}))
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { doctorJson, doctorLines };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.59.1"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
package/version.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/version.ts
|
|
2
|
+
/**
|
|
3
|
+
* The version of `@pluginfinity/cli` this build was made from: what `--version`
|
|
4
|
+
* prints before any distribution suffix.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* A build-time literal: the bundler replaces `process.env.__PACKAGE_VERSION__`
|
|
8
|
+
* with this package's own version, so this is not a runtime environment read.
|
|
9
|
+
* `"0.0.0"` is the unbuilt-source fallback.
|
|
10
|
+
*/
|
|
11
|
+
const CLI_VERSION = "0.0.1";
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { CLI_VERSION };
|