@tomflow/proflow-platform-cli 0.1.0 → 0.1.2
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/CHANGELOG.md +13 -0
- package/README.md +24 -3
- package/dist/deployment/adapter.d.ts +5 -5
- package/dist/deployment/descriptor.d.ts +1 -1
- package/dist/deployment/descriptor.js +1 -1
- package/dist/src/apply/driver.d.ts +1 -0
- package/dist/src/apply/driver.js +51 -39
- package/dist/src/binding/global-binding.d.ts +69 -0
- package/dist/src/binding/global-binding.js +349 -0
- package/dist/src/binding/production-bindings.d.ts +1 -1
- package/dist/src/binding/production-bindings.js +5 -3
- package/dist/src/cli.d.ts +12 -1
- package/dist/src/cli.js +453 -31
- package/dist/src/errors.d.ts +1 -1
- package/dist/src/errors.js +12 -0
- package/dist/src/install/environment.d.ts +2 -1
- package/dist/src/install/environment.js +33 -29
- package/dist/src/install/package-manager.d.ts +4 -2
- package/dist/src/install/package-manager.js +73 -17
- package/dist/src/planner/plan.d.ts +1 -0
- package/dist/src/planner/plan.js +1 -1
- package/package.json +4 -4
- package/proflow.module.json +1 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @tomflow/proflow-platform-cli
|
|
2
|
+
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Close the Real-1 global Platform control-plane contract across every published ProFlow package. Platform CLI now owns one durable global Workspace binding with canonical identity, cross-process operation locking, cwd/`--workspace` install targeting, cross-directory instance commands, whole-instance uninstall/rebind, and deterministic npm/yarn/pnpm Workspace package-manager selection. Every package-owned install entry, including newly generated Module Template packages, delegates to the Shell-global `platform` command and fails closed when that global CLI is unavailable; Deployment Conformance and the formal test plans mechanically enforce the same rule across all 24 packages.
|
|
8
|
+
|
|
9
|
+
## 0.1.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Read installed package versions directly from the Workspace `node_modules` package manifest so postcondition checks cannot reuse stale Node module-resolution cache entries after an in-process package upgrade.
|
package/README.md
CHANGED
|
@@ -8,10 +8,20 @@ Business Fact Owner: none
|
|
|
8
8
|
|
|
9
9
|
## Purpose
|
|
10
10
|
|
|
11
|
-
The single platform-level deterministic Deployment planner/executor. It understands only the Module Contract and public lifecycle/verification contracts; it does not import other domains' business internals.
|
|
11
|
+
The single platform-level deterministic Deployment planner/executor and v1 global `platform` control plane. It understands only the Module Contract and public lifecycle/verification contracts; it does not import other domains' business internals. The global CLI binary is distinct from the single bound Platform Instance.
|
|
12
12
|
|
|
13
13
|
For the v1 Custom GPT carrier it may plan/verify Web-only setup, role-scoped Action auth/schema, File Bridge/Code Interpreter/Web Search requirements, `x-openai-isConsequential:false` + Always Allow target configuration, Chrome/runtime prerequisites and current verification freshness. It never creates/guesses Task `workerRef/c-id`, never uses exact ChatGPT model id as READY truth, and never accepts System Observer assessment as Deployment READY truth.
|
|
14
14
|
|
|
15
|
+
## Global CLI bootstrap
|
|
16
|
+
|
|
17
|
+
The v1 `platform` command is a Shell-global control plane. A straightforward bootstrap is:
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
npm install --global @tomflow/proflow-platform-cli
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This choice installs the global CLI only. It does **not** force the managed Workspace to use npm: a bound Workspace may independently use `npm`, `yarn`, or `pnpm`, selected from its own package-manager facts.
|
|
24
|
+
|
|
15
25
|
## Commands
|
|
16
26
|
|
|
17
27
|
```
|
|
@@ -20,8 +30,8 @@ platform modules [module|package]
|
|
|
20
30
|
platform docs [module|package] [documentId]
|
|
21
31
|
platform preflight [module]
|
|
22
32
|
platform preflight --intent install
|
|
23
|
-
platform install [package]
|
|
24
|
-
platform uninstall
|
|
33
|
+
platform install [package] [--workspace <path>]
|
|
34
|
+
platform uninstall [module|package]
|
|
25
35
|
platform upgrade [module|package]
|
|
26
36
|
platform plan --intent install|configure|upgrade|uninstall|repair [options]
|
|
27
37
|
platform apply <planRef>
|
|
@@ -35,3 +45,14 @@ platform manifest [module]
|
|
|
35
45
|
```
|
|
36
46
|
|
|
37
47
|
`install` / `upgrade` / `uninstall` are AI-friendly high-level commands that reuse the same frozen Plan -> Apply engine. `search` reads the npm Registry installable world; `modules` reads the current Workspace managed world; `docs` mechanically aggregates package-owned Descriptor, npm `bin/exports`, and declared documentation without maintaining a second package-knowledge catalog. Package mutation is real Workspace package-manager mutation and is never satisfied by the historical no-op driver seam.
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## v1 global workspace semantics
|
|
51
|
+
|
|
52
|
+
- The `platform` binary is installed globally and can be invoked from any shell directory.
|
|
53
|
+
- At most one ProFlow Workspace may be bound globally at a time.
|
|
54
|
+
- `platform install` targets the current working directory by default; `platform install --workspace <path>` explicitly selects the requested Workspace for Agent/automation use.
|
|
55
|
+
- Requested Workspace paths are canonicalized before binding comparison. A second distinct Workspace is rejected with `WORKSPACE_ALREADY_BOUND` until the current Platform Instance is uninstalled.
|
|
56
|
+
- `status/start/stop/restart/modules/docs/verify/doctor/upgrade/uninstall` resolve the durable global binding rather than the caller's cwd. `platform status` exposes the bound Workspace path.
|
|
57
|
+
- `platform uninstall` without a module/package removes the current Platform Instance and clears its binding; it does not uninstall the global CLI package.
|
|
58
|
+
- Workspace package mutation is package-manager agnostic for v1: `npm`, `yarn`, and `pnpm` are supported. The CLI installation manager and the bound Workspace manager are independent facts.
|
|
@@ -5,7 +5,7 @@ export declare const behaviorAdapter: {
|
|
|
5
5
|
ok: boolean;
|
|
6
6
|
status: "SUCCEEDED";
|
|
7
7
|
moduleRef: "platform-cli";
|
|
8
|
-
moduleVersion: "0.1.
|
|
8
|
+
moduleVersion: "0.1.2";
|
|
9
9
|
data?: {} | null;
|
|
10
10
|
};
|
|
11
11
|
observedEffects: never[];
|
|
@@ -16,7 +16,7 @@ export declare const behaviorAdapter: {
|
|
|
16
16
|
ok: boolean;
|
|
17
17
|
status: "SUCCEEDED";
|
|
18
18
|
moduleRef: "platform-cli";
|
|
19
|
-
moduleVersion: "0.1.
|
|
19
|
+
moduleVersion: "0.1.2";
|
|
20
20
|
data?: {} | null;
|
|
21
21
|
};
|
|
22
22
|
observedEffects: never[];
|
|
@@ -27,7 +27,7 @@ export declare const behaviorAdapter: {
|
|
|
27
27
|
ok: boolean;
|
|
28
28
|
status: "SUCCEEDED";
|
|
29
29
|
moduleRef: "platform-cli";
|
|
30
|
-
moduleVersion: "0.1.
|
|
30
|
+
moduleVersion: "0.1.2";
|
|
31
31
|
data?: {} | null;
|
|
32
32
|
};
|
|
33
33
|
observedEffects: never[];
|
|
@@ -38,7 +38,7 @@ export declare const behaviorAdapter: {
|
|
|
38
38
|
ok: boolean;
|
|
39
39
|
status: "SUCCEEDED";
|
|
40
40
|
moduleRef: "platform-cli";
|
|
41
|
-
moduleVersion: "0.1.
|
|
41
|
+
moduleVersion: "0.1.2";
|
|
42
42
|
data?: {} | null;
|
|
43
43
|
};
|
|
44
44
|
observedEffects: never[];
|
|
@@ -49,7 +49,7 @@ export declare const behaviorAdapter: {
|
|
|
49
49
|
ok: boolean;
|
|
50
50
|
status: "SUCCEEDED";
|
|
51
51
|
moduleRef: "platform-cli";
|
|
52
|
-
moduleVersion: "0.1.
|
|
52
|
+
moduleVersion: "0.1.2";
|
|
53
53
|
data?: {} | null;
|
|
54
54
|
};
|
|
55
55
|
observedEffects: never[];
|
|
@@ -3,7 +3,7 @@ export declare const descriptor: {
|
|
|
3
3
|
readonly contractVersion: "1.0.0";
|
|
4
4
|
readonly moduleRef: "platform-cli";
|
|
5
5
|
readonly packageName: "@tomflow/proflow-platform-cli";
|
|
6
|
-
readonly moduleVersion: "0.1.
|
|
6
|
+
readonly moduleVersion: "0.1.2";
|
|
7
7
|
readonly kind: "cli";
|
|
8
8
|
readonly templateVersion: "1.0.0";
|
|
9
9
|
readonly platformCompatibility: ">=1.0.0 <2.0.0";
|
|
@@ -3,7 +3,7 @@ export const descriptor = {
|
|
|
3
3
|
contractVersion: "1.0.0",
|
|
4
4
|
moduleRef: "platform-cli",
|
|
5
5
|
packageName: "@tomflow/proflow-platform-cli",
|
|
6
|
-
moduleVersion: "0.1.
|
|
6
|
+
moduleVersion: "0.1.2",
|
|
7
7
|
kind: "cli",
|
|
8
8
|
templateVersion: "1.0.0",
|
|
9
9
|
platformCompatibility: ">=1.0.0 <2.0.0",
|
|
@@ -20,4 +20,5 @@ export declare function workspaceResidentDriver(): PackageManagerDriver;
|
|
|
20
20
|
export declare function createWorkspacePackageManagerDriver(options: {
|
|
21
21
|
workspaceRoot: string;
|
|
22
22
|
runner?: PackageCommandRunner;
|
|
23
|
+
executableAvailable?: (command: string) => boolean;
|
|
23
24
|
}): PackageManagerDriver;
|
package/dist/src/apply/driver.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
-
import {
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
4
|
-
import { pathToFileURL } from "node:url";
|
|
2
|
+
import { join } from "node:path";
|
|
5
3
|
import { PlatformError } from "../errors.js";
|
|
6
|
-
import { readWorkspacePackageManagerSelection, systemPackageCommandRunner, } from "../install/package-manager.js";
|
|
4
|
+
import { findExecutable, readWorkspacePackageManagerSelection, systemPackageCommandRunner, } from "../install/package-manager.js";
|
|
7
5
|
import { atomicWrite } from "../paths.js";
|
|
8
6
|
/**
|
|
9
7
|
* Monorepo/test seam retained for source-resident planning. Production CLI must
|
|
@@ -22,26 +20,27 @@ export function workspaceResidentDriver() {
|
|
|
22
20
|
}
|
|
23
21
|
export function createWorkspacePackageManagerDriver(options) {
|
|
24
22
|
const runner = options.runner ?? systemPackageCommandRunner();
|
|
23
|
+
const executableAvailable = options.executableAvailable ?? findExecutable;
|
|
25
24
|
return {
|
|
26
25
|
observeInstalledVersion: (module) => observeInstalledVersion(options.workspaceRoot, module.packageName),
|
|
27
26
|
install: async (module) => {
|
|
28
27
|
await ensureWorkspacePackageJson(options.workspaceRoot);
|
|
29
|
-
const manager = await requirePackageManager(options.workspaceRoot);
|
|
28
|
+
const manager = await requirePackageManager(options.workspaceRoot, executableAvailable);
|
|
30
29
|
await mutatePackage(runner, manager, options.workspaceRoot, "install", `${module.packageName}@${module.moduleVersion}`);
|
|
31
30
|
},
|
|
32
31
|
upgrade: async (module) => {
|
|
33
32
|
await ensureWorkspacePackageJson(options.workspaceRoot);
|
|
34
|
-
const manager = await requirePackageManager(options.workspaceRoot);
|
|
33
|
+
const manager = await requirePackageManager(options.workspaceRoot, executableAvailable);
|
|
35
34
|
await mutatePackage(runner, manager, options.workspaceRoot, "upgrade", `${module.packageName}@${module.moduleVersion}`);
|
|
36
35
|
},
|
|
37
36
|
remove: async (module) => {
|
|
38
|
-
const manager = await requirePackageManager(options.workspaceRoot);
|
|
37
|
+
const manager = await requirePackageManager(options.workspaceRoot, executableAvailable);
|
|
39
38
|
await mutatePackage(runner, manager, options.workspaceRoot, "remove", module.packageName);
|
|
40
39
|
},
|
|
41
40
|
};
|
|
42
41
|
}
|
|
43
42
|
async function mutatePackage(runner, manager, workspaceRoot, operation, packageSpec) {
|
|
44
|
-
const args = packageManagerArgs(manager
|
|
43
|
+
const args = await packageManagerArgs(runner, manager, workspaceRoot, operation, packageSpec);
|
|
45
44
|
try {
|
|
46
45
|
await runner.run(manager.name, args, workspaceRoot);
|
|
47
46
|
}
|
|
@@ -49,20 +48,47 @@ async function mutatePackage(runner, manager, workspaceRoot, operation, packageS
|
|
|
49
48
|
throw new PlatformError(operation === "upgrade" ? "UPGRADE_FAILED" : "APPLY_FAILED", `${manager.name} ${operation} failed for ${packageSpec}: ${errorMessage(error)}`);
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
|
-
function packageManagerArgs(manager, operation, packageSpec) {
|
|
53
|
-
if (manager === "pnpm") {
|
|
51
|
+
async function packageManagerArgs(runner, manager, workspaceRoot, operation, packageSpec) {
|
|
52
|
+
if (manager.name === "pnpm") {
|
|
54
53
|
return operation === "remove"
|
|
55
54
|
? ["remove", "--ignore-scripts", packageSpec]
|
|
56
55
|
: ["add", "--save-exact", "--ignore-scripts", packageSpec];
|
|
57
56
|
}
|
|
57
|
+
if (manager.name === "npm") {
|
|
58
|
+
return operation === "remove"
|
|
59
|
+
? ["uninstall", "--ignore-scripts", packageSpec]
|
|
60
|
+
: ["install", "--save-exact", "--ignore-scripts", packageSpec];
|
|
61
|
+
}
|
|
62
|
+
const major = await yarnMajorVersion(runner, manager, workspaceRoot);
|
|
63
|
+
if (major <= 1) {
|
|
64
|
+
return operation === "remove"
|
|
65
|
+
? ["remove", "--ignore-scripts", packageSpec]
|
|
66
|
+
: ["add", "--exact", "--ignore-scripts", packageSpec];
|
|
67
|
+
}
|
|
58
68
|
return operation === "remove"
|
|
59
|
-
? ["
|
|
60
|
-
: ["
|
|
69
|
+
? ["remove", "--mode=skip-build", packageSpec]
|
|
70
|
+
: ["add", "--exact", "--mode=skip-build", packageSpec];
|
|
71
|
+
}
|
|
72
|
+
async function yarnMajorVersion(runner, manager, workspaceRoot) {
|
|
73
|
+
const declaredVersion = declaredPackageManagerVersion(manager.declared);
|
|
74
|
+
const value = declaredVersion ??
|
|
75
|
+
(await runner.run("yarn", ["--version"], workspaceRoot)).trim();
|
|
76
|
+
const major = Number.parseInt(value.split(".")[0] ?? "", 10);
|
|
77
|
+
if (!Number.isInteger(major) || major < 1) {
|
|
78
|
+
throw new PlatformError("PACKAGE_MANAGER_UNAVAILABLE", `cannot determine a supported Yarn major version from ${value || "<empty>"}`);
|
|
79
|
+
}
|
|
80
|
+
return major;
|
|
81
|
+
}
|
|
82
|
+
function declaredPackageManagerVersion(declared) {
|
|
83
|
+
if (declared === undefined)
|
|
84
|
+
return undefined;
|
|
85
|
+
const separator = declared.lastIndexOf("@");
|
|
86
|
+
return separator > 0 ? declared.slice(separator + 1) : undefined;
|
|
61
87
|
}
|
|
62
|
-
async function requirePackageManager(workspaceRoot) {
|
|
88
|
+
async function requirePackageManager(workspaceRoot, executableAvailable) {
|
|
63
89
|
const manager = await readWorkspacePackageManagerSelection(workspaceRoot);
|
|
64
|
-
if (manager
|
|
65
|
-
throw new PlatformError("
|
|
90
|
+
if (!executableAvailable(manager.name)) {
|
|
91
|
+
throw new PlatformError("PACKAGE_MANAGER_UNAVAILABLE", `workspace package manager ${manager.name} is not available on PATH`);
|
|
66
92
|
}
|
|
67
93
|
return manager;
|
|
68
94
|
}
|
|
@@ -92,35 +118,21 @@ async function observeInstalledVersion(workspaceRoot, packageName) {
|
|
|
92
118
|
!hasOwn(manifest.devDependencies, packageName))) {
|
|
93
119
|
return undefined;
|
|
94
120
|
}
|
|
95
|
-
const require = createRequire(pathToFileURL(join(workspaceRoot, "package.json")));
|
|
96
|
-
let entry;
|
|
97
121
|
try {
|
|
98
|
-
|
|
122
|
+
const raw = await readFile(join(workspaceRoot, "node_modules", ...packageName.split("/"), "package.json"), "utf8");
|
|
123
|
+
const parsed = JSON.parse(raw);
|
|
124
|
+
if (typeof parsed === "object" &&
|
|
125
|
+
parsed !== null &&
|
|
126
|
+
!Array.isArray(parsed) &&
|
|
127
|
+
Reflect.get(parsed, "name") === packageName &&
|
|
128
|
+
typeof Reflect.get(parsed, "version") === "string") {
|
|
129
|
+
return Reflect.get(parsed, "version");
|
|
130
|
+
}
|
|
131
|
+
return undefined;
|
|
99
132
|
}
|
|
100
133
|
catch {
|
|
101
134
|
return undefined;
|
|
102
135
|
}
|
|
103
|
-
let current = dirname(entry);
|
|
104
|
-
for (;;) {
|
|
105
|
-
try {
|
|
106
|
-
const raw = await readFile(join(current, "package.json"), "utf8");
|
|
107
|
-
const parsed = JSON.parse(raw);
|
|
108
|
-
if (typeof parsed === "object" &&
|
|
109
|
-
parsed !== null &&
|
|
110
|
-
!Array.isArray(parsed) &&
|
|
111
|
-
Reflect.get(parsed, "name") === packageName &&
|
|
112
|
-
typeof Reflect.get(parsed, "version") === "string") {
|
|
113
|
-
return Reflect.get(parsed, "version");
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
catch {
|
|
117
|
-
// keep walking to the package root
|
|
118
|
-
}
|
|
119
|
-
const parent = dirname(current);
|
|
120
|
-
if (parent === current)
|
|
121
|
-
return undefined;
|
|
122
|
-
current = parent;
|
|
123
|
-
}
|
|
124
136
|
}
|
|
125
137
|
async function readWorkspaceManifest(workspaceRoot) {
|
|
126
138
|
try {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export declare const GLOBAL_BINDING_CONTRACT: "deployment.global-binding.v1";
|
|
2
|
+
export declare const WORKSPACE_INSTANCE_CONTRACT: "deployment.workspace-instance.v1";
|
|
3
|
+
export type GlobalBindingState = "INSTALLING" | "INSTALLED" | "UNINSTALLING" | "BROKEN";
|
|
4
|
+
export interface GlobalWorkspaceBinding {
|
|
5
|
+
contract: typeof GLOBAL_BINDING_CONTRACT;
|
|
6
|
+
state: GlobalBindingState;
|
|
7
|
+
workspacePath: string;
|
|
8
|
+
workspaceRealPath: string;
|
|
9
|
+
workspaceInstanceId: string;
|
|
10
|
+
createdAt: string;
|
|
11
|
+
updatedAt: string;
|
|
12
|
+
failure?: {
|
|
13
|
+
code: string;
|
|
14
|
+
message: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface WorkspaceInstanceMarker {
|
|
18
|
+
contract: typeof WORKSPACE_INSTANCE_CONTRACT;
|
|
19
|
+
workspaceInstanceId: string;
|
|
20
|
+
workspaceRealPath: string;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
}
|
|
23
|
+
export interface GlobalPlatformPaths {
|
|
24
|
+
root: string;
|
|
25
|
+
bindingJson: string;
|
|
26
|
+
bindingLock: string;
|
|
27
|
+
operationLock: string;
|
|
28
|
+
}
|
|
29
|
+
export interface BoundWorkspaceObservation {
|
|
30
|
+
binding: GlobalWorkspaceBinding;
|
|
31
|
+
workspaceExists: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface GlobalBindingLockHandle {
|
|
34
|
+
release(): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
export declare function globalPlatformPaths(globalRoot?: string): GlobalPlatformPaths;
|
|
37
|
+
export declare function canonicalizeWorkspace(workspace: string): Promise<{
|
|
38
|
+
workspacePath: string;
|
|
39
|
+
workspaceRealPath: string;
|
|
40
|
+
}>;
|
|
41
|
+
export declare function loadGlobalBinding(globalRoot?: string): Promise<GlobalWorkspaceBinding | undefined>;
|
|
42
|
+
export declare function observeBoundWorkspace(globalRoot?: string): Promise<BoundWorkspaceObservation | undefined>;
|
|
43
|
+
export declare function requireBoundWorkspace(globalRoot?: string): Promise<GlobalWorkspaceBinding>;
|
|
44
|
+
export declare function claimWorkspaceBinding(options: {
|
|
45
|
+
workspace: string;
|
|
46
|
+
globalRoot?: string | undefined;
|
|
47
|
+
}): Promise<{
|
|
48
|
+
binding: GlobalWorkspaceBinding;
|
|
49
|
+
alreadyBound: boolean;
|
|
50
|
+
}>;
|
|
51
|
+
export declare function updateGlobalBindingState(options: {
|
|
52
|
+
workspaceInstanceId: string;
|
|
53
|
+
state: GlobalBindingState;
|
|
54
|
+
globalRoot?: string | undefined;
|
|
55
|
+
failure?: {
|
|
56
|
+
code: string;
|
|
57
|
+
message: string;
|
|
58
|
+
};
|
|
59
|
+
}): Promise<GlobalWorkspaceBinding>;
|
|
60
|
+
export declare function clearGlobalBinding(options: {
|
|
61
|
+
workspaceInstanceId: string;
|
|
62
|
+
globalRoot?: string | undefined;
|
|
63
|
+
removeWorkspaceMarker?: boolean;
|
|
64
|
+
}): Promise<void>;
|
|
65
|
+
export declare function forgetMissingWorkspaceBinding(options: {
|
|
66
|
+
globalRoot?: string | undefined;
|
|
67
|
+
}): Promise<GlobalWorkspaceBinding>;
|
|
68
|
+
export declare function acquireGlobalBindingLock(paths: GlobalPlatformPaths): Promise<GlobalBindingLockHandle>;
|
|
69
|
+
export declare function acquireGlobalOperationLock(globalRoot?: string): Promise<GlobalBindingLockHandle>;
|