@promptdriven/pds 0.1.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/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # pds CLI
2
+
3
+ `pds` is the scriptable Prompt Driven Studio control plane for local operators,
4
+ CI jobs, and AI agents. It talks to the webapp agent API; it does not run
5
+ generation, upload, or provider code directly.
6
+
7
+ ## Install From npm
8
+
9
+ ```bash
10
+ npm install -g @promptdriven/pds
11
+ pds --version
12
+ ```
13
+
14
+ Node.js 20 or newer is required.
15
+
16
+ ## Local Development Pack
17
+
18
+ ```bash
19
+ cd cli/pds
20
+ npm run pack:check
21
+ packed_tarball="$(npm pack --json | node -e "const fs = require('node:fs'); const pack = JSON.parse(fs.readFileSync(0, 'utf8')); process.stdout.write(pack[0].filename);")"
22
+ npm install -g "./${packed_tarball}"
23
+ pds --version
24
+ ```
25
+
26
+ Use the local pack path only when testing unpublished changes from a checkout.
27
+
28
+ ## Auth Setup
29
+
30
+ Use a profile for day-to-day local use:
31
+
32
+ ```bash
33
+ pds --api-url http://localhost:3000 --profile local auth login
34
+ pds --profile local auth status --json
35
+ ```
36
+
37
+ For CI, create a least-privilege scoped token from an owner account.
38
+ Include `project:create` if the token must bootstrap new projects
39
+ (e.g. for `pds release-video create` or `pds projects create`):
40
+
41
+ ```bash
42
+ pds auth token create \
43
+ --label release-bot \
44
+ --project release-project-id \
45
+ --scopes project:create,project:read,project:write,pipeline:run,artifact:read,distribution:package,distribution:publish \
46
+ --expires-in 30d \
47
+ --json
48
+ pds auth token list --json
49
+ ```
50
+
51
+ A token with `project:create` can create new projects that were not listed at
52
+ mint time. Store only the one-time `rawToken` in the CI secret store, then pass
53
+ it as `PDS_TOKEN`. YouTube OAuth credentials stay server-side and must not be
54
+ stored in CLI config.
55
+
56
+ ## Release Video
57
+
58
+ ```bash
59
+ PDS_API_URL=https://studio.example.com \
60
+ PDS_TOKEN="$PDS_RELEASE_TOKEN" \
61
+ pds release-video create \
62
+ --project-name release-v1.8.0 \
63
+ --script release_video_script.md \
64
+ --release-notes CHANGELOG.md \
65
+ --changelog CHANGELOG.full.md \
66
+ --repo-url https://github.com/promptdriven/studio \
67
+ --repo-name promptdriven/studio \
68
+ --git-sha "$GITHUB_SHA" \
69
+ --release-tag v1.8.0 \
70
+ --preset release-notes \
71
+ --target publish \
72
+ --platform youtube \
73
+ --privacy unlisted \
74
+ --idempotency-key "release:v1.8.0:$GITHUB_SHA" \
75
+ --wait \
76
+ --json
77
+ ```
78
+
79
+ Add `--dry-run` to inspect the release workflow without starting server-side
80
+ generation or publish work.
81
+
82
+ ## Scripts
83
+
84
+ ```bash
85
+ pds script set --project release-v1.8.0 --file release_video_script.md --idempotency-key release:v1.8.0:script --json
86
+ pds script set --project release-v1.8.0 --file tts_script.md --target tts --idempotency-key release:v1.8.0:tts-script --json
87
+ ```
88
+
89
+ `script set` writes the main script by default. The only alternate target is
90
+ `tts`; unsupported targets fail locally before the API request.
91
+
92
+ For direct uploads,
93
+ `pds distribution publish --privacy unlisted --idempotency-key <key> --wait`
94
+ refreshes the Stage 13 package before upload. Add `--no-generate` to require an
95
+ existing ready package, or `--dry-run` to plan without packaging or uploading.
96
+
97
+ Server-side idempotency is atomic and non-dry-run mutating release commands
98
+ require `--idempotency-key`. Agent token records are durable on the service.
99
+
100
+ Use `--json` for one final JSON object and `jobs watch --jsonl` for one event
101
+ object per line.
102
+
103
+ ## Checks
104
+
105
+ ```bash
106
+ npm --prefix cli/pds test
107
+ npm --prefix cli/pds run smoke:pack
108
+ ```
109
+
110
+ The root shortcut is `npm run test:pds-cli`.
package/bin/pds ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { runFromProcess } = require("../dist/main.js");
5
+
6
+ void runFromProcess();
@@ -0,0 +1,19 @@
1
+ export type GlobalOptions = {
2
+ apiUrl?: string;
3
+ token?: string;
4
+ profile?: string;
5
+ projectId?: string;
6
+ json?: boolean;
7
+ jsonl?: boolean;
8
+ noColor?: boolean;
9
+ timeout?: string;
10
+ verbose?: boolean;
11
+ version?: boolean;
12
+ help?: boolean;
13
+ };
14
+ export type ParsedInvocation = {
15
+ globalOptions: GlobalOptions;
16
+ commandPath: string[];
17
+ commandArgs: string[];
18
+ };
19
+ export declare function parseInvocation(argv: string[]): ParsedInvocation;
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseInvocation = parseInvocation;
4
+ const errors_1 = require("../errors/errors");
5
+ const stringGlobals = {
6
+ "api-url": "apiUrl",
7
+ token: "token",
8
+ profile: "profile",
9
+ project: "projectId",
10
+ timeout: "timeout"
11
+ };
12
+ const booleanGlobals = {
13
+ json: "json",
14
+ jsonl: "jsonl",
15
+ "no-color": "noColor",
16
+ verbose: "verbose",
17
+ version: "version",
18
+ help: "help"
19
+ };
20
+ const knownCommandPaths = [
21
+ ["auth", "login"],
22
+ ["auth", "status"],
23
+ ["auth", "logout"],
24
+ ["auth", "token", "create"],
25
+ ["auth", "token", "list"],
26
+ ["auth", "token", "revoke"],
27
+ ["projects", "create"],
28
+ ["project", "get"],
29
+ ["project", "reset-pipeline"],
30
+ ["script", "get"],
31
+ ["script", "set"],
32
+ ["artifacts", "list"],
33
+ ["pipeline", "plan"],
34
+ ["pipeline", "run"],
35
+ ["pipeline", "status"],
36
+ ["jobs", "watch"],
37
+ ["jobs", "cancel"],
38
+ ["distribution", "generate"],
39
+ ["distribution", "status"],
40
+ ["distribution", "publish"],
41
+ ["distribution", "connections", "list"],
42
+ ["distribution", "connection", "select"],
43
+ ["release-video", "create"],
44
+ ["release-video", "status"]
45
+ ];
46
+ function parseInvocation(argv) {
47
+ const globalOptions = {};
48
+ const commandTokens = [];
49
+ for (let index = 0; index < argv.length; index += 1) {
50
+ const token = argv[index];
51
+ if (token === "--") {
52
+ commandTokens.push(...argv.slice(index + 1));
53
+ break;
54
+ }
55
+ if (!token.startsWith("--") || token === "--") {
56
+ commandTokens.push(token);
57
+ continue;
58
+ }
59
+ const optionText = token.slice(2);
60
+ const equalsIndex = optionText.indexOf("=");
61
+ const optionName = equalsIndex === -1 ? optionText : optionText.slice(0, equalsIndex);
62
+ const inlineValue = equalsIndex === -1 ? undefined : optionText.slice(equalsIndex + 1);
63
+ const stringKey = stringGlobals[optionName];
64
+ if (stringKey) {
65
+ const value = inlineValue ?? argv[index + 1];
66
+ if (!value || value.startsWith("--")) {
67
+ throw new errors_1.CliError(`Missing value for --${optionName}`, { code: "missing_option_value", exitCode: errors_1.EXIT_CODES.usage });
68
+ }
69
+ globalOptions[stringKey] = value;
70
+ if (inlineValue === undefined) {
71
+ index += 1;
72
+ }
73
+ continue;
74
+ }
75
+ const booleanKey = booleanGlobals[optionName];
76
+ if (booleanKey) {
77
+ globalOptions[booleanKey] = true;
78
+ continue;
79
+ }
80
+ commandTokens.push(token);
81
+ }
82
+ if (globalOptions.json && globalOptions.jsonl) {
83
+ throw new errors_1.CliError("Use only one of --json or --jsonl", {
84
+ code: "conflicting_output_modes",
85
+ exitCode: errors_1.EXIT_CODES.usage
86
+ });
87
+ }
88
+ const commandPath = findCommandPath(commandTokens);
89
+ return {
90
+ globalOptions,
91
+ commandPath,
92
+ commandArgs: commandTokens.slice(commandPath.length)
93
+ };
94
+ }
95
+ function findCommandPath(tokens) {
96
+ const prefix = [];
97
+ for (const token of tokens) {
98
+ if (token.startsWith("-")) {
99
+ break;
100
+ }
101
+ prefix.push(token);
102
+ }
103
+ let bestMatch = [];
104
+ for (const commandPath of knownCommandPaths) {
105
+ if (commandPath.length > prefix.length) {
106
+ continue;
107
+ }
108
+ if (commandPath.every((part, index) => prefix[index] === part) && commandPath.length > bestMatch.length) {
109
+ bestMatch = commandPath;
110
+ }
111
+ }
112
+ return bestMatch.length > 0 ? bestMatch : prefix;
113
+ }
114
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources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,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM;QACR,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IAED,IAAI,SAAS,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,WAAW,IAAI,iBAAiB,EAAE,CAAC;QAC5C,IAAI,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;YACvC,SAAS;QACX,CAAC;QACD,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,IAAI,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;YACxG,SAAS,GAAG,WAAW,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;AACnD,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { PDS_API_VERSION } from "../version";
2
+ import type { CreateProjectRequest, CreateTokenRequest, DeviceLoginCompleteRequest, DeviceLoginStartRequest, DistributionRequest, DistributionConnectionListRequest, DistributionConnectionSelectRequest, JobRequest, PdsClient, PipelineRequest, ResetPipelineRequest, PipelineStatusRequest, ReleaseVideoRequest, RevokeTokenRequest, ScriptGetRequest, ScriptSetRequest } from "./types";
3
+ export { PDS_API_VERSION };
4
+ type FetchImpl = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
5
+ export type PdsApiClientOptions = {
6
+ apiUrl: string;
7
+ token?: string;
8
+ timeoutMs: number;
9
+ fetchImpl?: FetchImpl;
10
+ clientVersion?: string;
11
+ sleepImpl?: (ms: number) => Promise<void>;
12
+ maxWatchReconnects?: number;
13
+ };
14
+ export declare class PdsApiClient implements PdsClient {
15
+ private readonly apiUrl;
16
+ private readonly token;
17
+ private readonly timeoutMs;
18
+ private readonly fetchImpl;
19
+ private readonly clientVersion;
20
+ private readonly sleepImpl;
21
+ private readonly maxWatchReconnects;
22
+ constructor(options: PdsApiClientOptions);
23
+ getVersion(): Promise<unknown>;
24
+ getAuthStatus(): Promise<unknown>;
25
+ createProject(request: CreateProjectRequest): Promise<unknown>;
26
+ getProject(projectId: string): Promise<unknown>;
27
+ getScript(request: ScriptGetRequest): Promise<unknown>;
28
+ setScript(request: ScriptSetRequest): Promise<unknown>;
29
+ listArtifacts(projectId: string): Promise<unknown>;
30
+ planPipeline(request: PipelineRequest): Promise<unknown>;
31
+ runPipeline(request: PipelineRequest): Promise<unknown>;
32
+ resetPipeline(request: ResetPipelineRequest): Promise<unknown>;
33
+ getPipelineStatus(request: PipelineStatusRequest): Promise<unknown>;
34
+ watchJob(request: JobRequest): Promise<unknown>;
35
+ getJob(request: JobRequest): Promise<unknown>;
36
+ cancelJob(request: JobRequest): Promise<unknown>;
37
+ startDeviceLogin(request: DeviceLoginStartRequest): Promise<unknown>;
38
+ completeDeviceLogin(request: DeviceLoginCompleteRequest): Promise<unknown>;
39
+ createToken(request: CreateTokenRequest): Promise<unknown>;
40
+ listTokens(): Promise<unknown>;
41
+ revokeToken(request: RevokeTokenRequest): Promise<unknown>;
42
+ generateDistribution(request: DistributionRequest): Promise<unknown>;
43
+ getDistributionStatus(request: DistributionRequest): Promise<unknown>;
44
+ publishDistribution(request: DistributionRequest): Promise<unknown>;
45
+ listDistributionConnections(request: DistributionConnectionListRequest): Promise<unknown>;
46
+ selectDistributionConnection(request: DistributionConnectionSelectRequest): Promise<unknown>;
47
+ createReleaseVideo(request: ReleaseVideoRequest): Promise<unknown>;
48
+ private request;
49
+ private requestOnce;
50
+ private requestText;
51
+ private requestNdjson;
52
+ private fetchResponse;
53
+ }