@ductape/cli 0.6.0 → 0.6.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/dist/index.js CHANGED
@@ -6,7 +6,6 @@ import path from 'node:path';
6
6
  import { runLogin } from './commands/login.js';
7
7
  import { runLogout } from './commands/logout.js';
8
8
  import { runWhoami } from './commands/whoami.js';
9
- import { runTroubleshoot } from './commands/troubleshoot.js';
10
9
  import { runDoctor } from './commands/doctor.js';
11
10
  import { runProfilesList, runProfilesUse } from './commands/profiles.js';
12
11
  import { runLink } from './commands/link.js';
@@ -20,7 +19,6 @@ import { runDb, runDbActions, runDbContext } from './commands/db.js';
20
19
  import { runComponentActions } from './commands/component-actions.js';
21
20
  import { runDbMigrate, runDbMigrateStatus, runDbMigrateRollback, runDbMigrateBaseline } from './commands/db-migrate.js';
22
21
  import { runFeaturesSync, runFeaturesValidate } from './commands/features-sync.js';
23
- import { runUiAdd, runUiCheck, runUiCreate, runUiDeprecate, runUiInspect, runUiInstall, runUiList, runUiPack, runUiPublish, runUiRemove, runUiUndeprecate, runUiUpdate, runUiValidate, runUiVerify } from './commands/ui.js';
24
22
  import { runSessionsValidate } from './commands/sessions-validate.js';
25
23
  import { runRateLimits } from './commands/rate-limits.js';
26
24
  import { runDeploy } from './commands/deploy.js';
@@ -35,10 +33,11 @@ import { runWorkspacesCurrent, runWorkspacesList, runWorkspacesRefresh, runWorks
35
33
  import { runGeneratePayload, runGenerateSnippet } from './commands/generate.js';
36
34
  import { runCompletion } from './commands/completion.js';
37
35
  import { runProducts, runProductApps, runProductAppActions, runProductComponents, runProductEnvironments } from './commands/products.js';
38
- import { runApps, runAppVersionRename, runAppVersions } from './commands/apps.js';
36
+ import { runApps } from './commands/apps.js';
39
37
  import { runAppsImport } from './commands/apps-import.js';
40
38
  import { runAppActions } from './commands/app-actions.js';
41
39
  import { registerAppWebhooks } from './commands/app-webhooks.js';
40
+ import { registerWork } from './commands/work.js';
42
41
  import { runMarketplace } from './commands/marketplace.js';
43
42
  import { runCapabilitySearch } from './commands/capabilities.js';
44
43
  import { runApply } from './commands/apply.js';
@@ -129,13 +128,13 @@ const codeTarget = (c) => c
129
128
  .option('--product <tag>').option('--function <name>').option('--fn-version <version>').option('--env <slug>');
130
129
  remote('step-up', 'start', 'Email yourself a six-digit code for one change (a person only)', codeTarget).action(op('stepup.start'));
131
130
  remote('step-up', 'verify', 'Check the code and print a grant, good for ten minutes and for that one change; put it in an environment variable and pass its name with --grant-env', (c) => codeTarget(c).requiredOption('--code <code>', 'the six-digit code from your email')).action(op('stepup.verify'));
132
- remote('plans', 'create', 'Create a plan from a JSON file; nothing is changed', (c) => c.requiredOption('--file <file>', 'Plan request JSON (Cloud Run, Azure Container Apps, and AWS Lambda services accept runtime.publicAccess: true or false with human approval; static egress uses runtime.vpcEgress on Cloud Run with optional provision: true or runtime.awsVpcEgress on Lambda or ECS Fargate)')).action(op('plans.create'));
131
+ remote('plans', 'create', 'Create a plan from a JSON file; nothing is changed', (c) => c.requiredOption('--file <file>', 'Plan request JSON (static egress uses runtime.vpcEgress on Cloud Run or runtime.awsVpcEgress on Lambda or ECS Fargate)')).action(op('plans.create'));
133
132
  remote('plans', 'approve <planId>', 'Approve a plan (a person only; refused for agents)', grantOption).action(op('plans.approve'));
134
133
  remote('plans', 'list', 'List plans with where each stands: blocked, pending_approval, approved, ready, applied or expired', (c) => c.option('--product <tag>').option('--env <env>').option('--stage <stage>')).action(op('plans.list'));
135
134
  remote('plans', 'get <planId>', 'Show one plan: what it would change, its warnings and the state of the cloud it was made from').action(op('plans.get'));
136
135
  remote('plans', 'apply <planId>', 'Apply an approved or permitted plan').action(op('plans.apply'));
137
136
  remote('deployments', 'list', 'List deployments (functions and services)', (c) => c.option('--product <tag>').option('--env <env>').option('--fn-version <version>').option('--kind <kind>', 'function or service').option('--connection <tag>', 'only what was applied through this cloud connection')).action(op('deployments.list'));
138
- remote('deployments', 'get <deploymentId>', 'Show one deployment, including functions served by each active service revision').action(op('deployments.get'));
137
+ remote('deployments', 'get <deploymentId>', 'Show one deployment').action(op('deployments.get'));
139
138
  remote('deployments', 'journal <deploymentId>', 'Show a deployment\'s journal').action(op('deployments.journal'));
140
139
  const planFromDeployment = (c) => c
141
140
  .option('--runtime-file <file>', 'Runtime settings JSON that replace the deployment\'s own (cpu, memory, minInstances, maxInstances, or Cloud Run vpcEgress with network and subnet names)')
@@ -195,15 +194,6 @@ program
195
194
  skipWorkspaceSelect: Boolean(opts.skipWorkspaceSelect),
196
195
  })));
197
196
  program.command('logout').description('Clear local credentials').action(wrap(runLogout));
198
- program
199
- .command('troubleshoot')
200
- .description('Summarize issues from logs, deployment journals and builds in the active workspace')
201
- .option('--product <tag>', 'Only this product')
202
- .option('--since <time>', 'Duration such as 24h or ISO timestamp with timezone', '24h')
203
- .option('--until <time>', 'ISO timestamp with timezone; defaults to now')
204
- .option('--max-logs <count>', 'Maximum workspace log records to inspect, 1 to 10000', '5000')
205
- .option('--json', 'Structured report with evidence and coverage')
206
- .action(wrap(runTroubleshoot));
207
197
  program
208
198
  .command('doctor')
209
199
  .description('Report CLI, SDK, MCP, API/schema, authentication, and project compatibility facts')
@@ -784,20 +774,6 @@ const apps = program
784
774
  throw new Error('Specify a verb: list | get | create | update | delete');
785
775
  return runApps(verb, opts, []);
786
776
  }));
787
- apps.command('versions')
788
- .description('Fetch lightweight version metadata without actions, webhooks or credentials')
789
- .requiredOption('--id <id>', 'App ID')
790
- .option('--profile <name>')
791
- .option('--json', 'JSON output')
792
- .action(wrap((opts) => runAppVersions(opts)));
793
- apps.command('rename-version')
794
- .description('Rename a version label atomically without changing its contents')
795
- .requiredOption('--id <id>', 'App ID')
796
- .requiredOption('--from <label>', 'Existing version label')
797
- .requiredOption('--to <label>', 'New, unused version label')
798
- .option('--profile <name>')
799
- .option('--json', 'JSON output')
800
- .action(wrap((opts) => runAppVersionRename(opts)));
801
777
  apps
802
778
  .command('import <file>')
803
779
  .description('Import Postman v2.1 or OpenAPI 3.0 into a new or existing app')
@@ -820,6 +796,7 @@ apps
820
796
  const appActions = apps.command('actions').description("An app's own actions (endpoints). resource is a path relative to each of the app's " +
821
797
  'environment base_urls (e.g. "/v1/users/{id}"), not a full URL.');
822
798
  registerAppWebhooks(apps, wrap);
799
+ registerWork(program, wrap);
823
800
  appActions
824
801
  .command('list')
825
802
  .requiredOption('--app <tag>', 'App tag')
@@ -1101,95 +1078,6 @@ db
1101
1078
  throw new Error('Specify a verb: connect | query');
1102
1079
  return runDb(verb, { file: opts.file, json: opts.json });
1103
1080
  }));
1104
- const ui = program
1105
- .command('ui')
1106
- .description('Frontend UI pieces written once in ductape/ui/ and added to any application of the workspace, which compiles them with its own bundler');
1107
- ui
1108
- .command('create <name>')
1109
- .description('Write a new UI piece under ductape/ui/<name>: manifest, component, styles and README')
1110
- .option('--framework <framework>', 'react, vue or javascript (plain DOM code any application can use)', 'react')
1111
- .option('--description <text>', 'One line saying what it is for')
1112
- .option('--json', 'JSON output')
1113
- .action(wrap((name, opts) => runUiCreate(name, opts)));
1114
- ui
1115
- .command('validate [name]')
1116
- .description('Check a UI piece (or all of them): manifest, published files, imports, secrets. Offline; changes nothing')
1117
- .option('--typecheck', 'Also type-check it with this project\'s TypeScript, React and Ductape SDK types')
1118
- .option('--json', 'JSON output')
1119
- .action(wrap((name, opts) => runUiValidate(name, { typecheck: Boolean(opts.typecheck), json: Boolean(opts.json) })));
1120
- ui
1121
- .command('pack <name>')
1122
- .description('Validate, then write the publishable artifact with its integrity hash. Offline')
1123
- .option('--out <file>', 'Where to write it (default ductape/.ui-packs/<name>@<version>.json)')
1124
- .option('--json', 'JSON output')
1125
- .action(wrap((name, opts) => runUiPack(name, { out: opts.out, json: Boolean(opts.json) })));
1126
- ui
1127
- .command('publish <name>')
1128
- .description('Validate and pack ductape/ui/<name>, then publish it to this workspace. Published versions never change')
1129
- .option('--typecheck', 'Type-check before publishing')
1130
- .option('--dry-run', 'Validate and pack, and say what would be published, without publishing')
1131
- .option('--json', 'JSON output')
1132
- .action(wrap((name, opts) => runUiPublish(name, { typecheck: Boolean(opts.typecheck), dryRun: Boolean(opts.dryRun), json: Boolean(opts.json) })));
1133
- ui
1134
- .command('list')
1135
- .description('The UI pieces published in this workspace, with their latest release')
1136
- .option('--search <text>', 'Only pieces whose name or description contains this')
1137
- .option('--json', 'JSON output')
1138
- .action(wrap((opts) => runUiList({ search: opts.search, json: Boolean(opts.json) })));
1139
- ui
1140
- .command('inspect <ref>')
1141
- .description('A piece\'s versions (name), or one version\'s manifest, requirements and files (name@version or name@latest)')
1142
- .option('--json', 'JSON output')
1143
- .action(wrap((ref, opts) => runUiInspect(ref, { json: Boolean(opts.json) })));
1144
- ui
1145
- .command('deprecate <ref>')
1146
- .description('Mark name@version deprecated. It stays installable by exact version; latest stops choosing it')
1147
- .requiredOption('--reason <text>', 'Why, shown to anyone who installs it')
1148
- .option('--replacement <version>', 'The version to use instead')
1149
- .option('--json', 'JSON output')
1150
- .action(wrap((ref, opts) => runUiDeprecate(ref, { reason: opts.reason, replacement: opts.replacement, json: Boolean(opts.json) })));
1151
- ui
1152
- .command('undeprecate <ref>')
1153
- .description('Clear the deprecation of name@version')
1154
- .option('--json', 'JSON output')
1155
- .action(wrap((ref, opts) => runUiUndeprecate(ref, { json: Boolean(opts.json) })));
1156
- ui
1157
- .command('add <ref>')
1158
- .description('Add a published piece (name, name@version or name@latest) to this application: its verified source goes in ductape/ui/installed/, pinned in ductape/ui.lock.json, importable as #ui/<name>')
1159
- .option('--ignore-peers', 'Add it even when the packages it needs are missing or the wrong version')
1160
- .option('--json', 'JSON output')
1161
- .action(wrap((ref, opts) => runUiAdd(ref, { ignorePeers: Boolean(opts.ignorePeers), json: Boolean(opts.json) })));
1162
- ui
1163
- .command('install')
1164
- .description('Make ductape/ui/installed/ and package.json match ductape/ui.lock.json, fetching exactly the pinned artifacts where files are missing or changed')
1165
- .option('--offline', 'Fetch nothing; fail if anything would need fetching')
1166
- .option('--json', 'JSON output')
1167
- .action(wrap((opts) => runUiInstall({ offline: Boolean(opts.offline), json: Boolean(opts.json) })));
1168
- ui
1169
- .command('update <name>')
1170
- .description('Move an added piece to its latest release, or to --to <version>')
1171
- .option('--to <version>', 'Exact version to move to')
1172
- .option('--ignore-peers', 'Update even when the packages it needs are missing or the wrong version')
1173
- .option('--json', 'JSON output')
1174
- .action(wrap((name, opts) => runUiUpdate(name, { to: opts.to, ignorePeers: Boolean(opts.ignorePeers), json: Boolean(opts.json) })));
1175
- ui
1176
- .command('remove <name>')
1177
- .description('Remove an added piece, and any piece it used that nothing else uses')
1178
- .option('--json', 'JSON output')
1179
- .action(wrap((name, opts) => runUiRemove(name, { json: Boolean(opts.json) })));
1180
- ui
1181
- .command('verify')
1182
- .description('Offline check for CI: installed pieces are exactly the pinned artifacts, package.json imports them, and the packages they need are installed')
1183
- .option('--skip-peers', 'Do not check the packages the pieces need')
1184
- .option('--json', 'JSON output')
1185
- .action(wrap((opts) => runUiVerify({ skipPeers: Boolean(opts.skipPeers), json: Boolean(opts.json) })));
1186
- ui
1187
- .command('check [name]')
1188
- .description('Online: does the product have the actions, features and sessions the added pieces need? Uses the linked product and environment unless given')
1189
- .option('--product <tag>', 'Product tag')
1190
- .option('--env <slug>', 'Environment slug')
1191
- .option('--json', 'JSON output')
1192
- .action(wrap((name, opts) => runUiCheck(name, { product: opts.product, env: opts.env, json: Boolean(opts.json) })));
1193
1081
  const features = program.command('features').description('Code-first Ductape Features (ductape/features/)');
1194
1082
  const sessions = program.command('sessions').description('Session lifecycle and propagation checks');
1195
1083
  sessions
@@ -1264,7 +1152,8 @@ for (const verb of ['create', 'update', 'get', 'list', 'delete', 'execute']) {
1264
1152
  program
1265
1153
  .command('secrets <verb>')
1266
1154
  .description('Workspace secrets CRUD')
1267
- .option('-k, --key <key>')
1155
+ .option('-k, --key <key>', 'The secret\'s key; with create, only the value is asked for')
1156
+ .option('--env <slug>', 'create: limit the secret to this environment (default: every environment)')
1268
1157
  .option('-f, --file <path>')
1269
1158
  .option('-i, --interactive', 'Prompt for fields (default in TTY when -f omitted)')
1270
1159
  .option('--no-interactive', 'Require -f JSON for create/update')
@@ -15,10 +15,8 @@ export class ApiClient {
15
15
  }
16
16
  async request(method, path, body, extraHeaders) {
17
17
  const url = `${this.apiUrl}${path.startsWith('/') ? path : `/${path}`}`;
18
- // Bytes (a Worker bundle) are sent as they are; everything else is JSON.
19
- const raw = body instanceof Uint8Array;
20
18
  const headers = {
21
- 'Content-Type': raw ? 'application/octet-stream' : 'application/json',
19
+ 'Content-Type': 'application/json',
22
20
  ...extraHeaders,
23
21
  };
24
22
  if (this.token) {
@@ -30,7 +28,7 @@ export class ApiClient {
30
28
  method,
31
29
  headers,
32
30
  ...(this.timeoutMs ? { signal: AbortSignal.timeout(this.timeoutMs) } : {}),
33
- body: body === undefined ? undefined : raw ? body : JSON.stringify(body),
31
+ body: body !== undefined ? JSON.stringify(body) : undefined,
34
32
  });
35
33
  }
36
34
  catch (cause) {
@@ -309,9 +309,6 @@ export const GCP_DEPLOY_CREATES = [
309
309
  ];
310
310
  export const GCP_DEPLOY_SAFETY = 'Ductape only adds resources it labels as its own (ductape_managed), never changes or reuses one it did not create, and never deletes anything, including what it created. Removing deployed resources is always your own action. Use a dedicated project if you can, so what Ductape adds is easy to see.';
311
311
  export const GCP_DEPLOY_TROUBLESHOOTING = [
312
- { problem: 'Static egress creation fails with a Compute API or IAM error', fix: 'Enable compute.googleapis.com in the connected project. Grant the connection service account the Compute permissions named in the error, then retry the deployment. The journal records the outbound IPv4 once the network is ready.' },
313
- { problem: 'Cloud Run cannot attach the VPC subnet', fix: 'Check that the subnet belongs to the selected VPC and is in the deployment region and connected project. If Google Cloud reports an IAM denial, check the principal and permission named in the error.' },
314
- { problem: 'Cloud Run starts but Atlas connections time out or fail during TLS setup', fix: 'Check that Cloud NAT serves the selected subnet and uses a reserved IPv4. Verify the actual outbound IP from the revision and allowlist it as a /32 in Atlas. If the Ductape resolver returns 502, check the integrations logs for that request separately.' },
315
312
  { problem: '"<API> has not been used in project <PROJECT_ID> before or it is disabled"', fix: 'Enable that API (step 1), wait a minute or two for it to take effect, and try again.' },
316
313
  { problem: 'Validation lists missing permissions and the roles that grant them', fix: 'Grant exactly those roles to the Ductape service account on the project (step 3) and validate again. Role changes can take a minute to apply.' },
317
314
  { problem: '"caller does not have permission to act as service account ..." when a build or deploy starts', fix: 'Grant roles/iam.serviceAccountUser to the Ductape service account on the project. Cloud Build and Cloud Run run as a service account, and the Ductape account must be allowed to act as it.' },
@@ -1,6 +1,6 @@
1
1
  /** Enum values aligned with @ductape/sdk — used for CLI dropdowns */
2
2
  export declare const STORAGE_PROVIDERS: readonly ["aws", "gcp", "azure"];
3
- export declare const DATABASE_TYPES: readonly ["postgresql", "mongodb", "mysql", "redis"];
3
+ export declare const DATABASE_TYPES: readonly ["postgresql", "mongodb", "mysql"];
4
4
  export declare const GRAPH_TYPES: readonly ["neo4j", "neptune", "arangodb", "memgraph"];
5
5
  export declare const VECTOR_DB_TYPES: readonly ["pinecone", "qdrant", "weaviate", "chroma", "milvus", "pgvector", "memory"];
6
6
  export declare const VECTOR_DISTANCE_METRICS: readonly ["cosine", "euclidean", "dotproduct"];
@@ -1,6 +1,6 @@
1
1
  /** Enum values aligned with @ductape/sdk — used for CLI dropdowns */
2
2
  export const STORAGE_PROVIDERS = ['aws', 'gcp', 'azure'];
3
- export const DATABASE_TYPES = ['postgresql', 'mongodb', 'mysql', 'redis'];
3
+ export const DATABASE_TYPES = ['postgresql', 'mongodb', 'mysql'];
4
4
  export const GRAPH_TYPES = ['neo4j', 'neptune', 'arangodb', 'memgraph'];
5
5
  export const VECTOR_DB_TYPES = [
6
6
  'pinecone',
@@ -6,6 +6,7 @@ export type InteractiveOpts = {
6
6
  export declare function isInteractive(opts?: InteractiveOpts): boolean;
7
7
  export declare function promptForm(schema: FormSchema, opts?: {
8
8
  patch?: boolean;
9
+ preset?: Record<string, unknown>;
9
10
  }): Promise<Record<string, unknown>>;
10
11
  export declare function promptTag(label?: string): Promise<string>;
11
12
  export declare function promptKey(label?: string): Promise<string>;
@@ -1,5 +1,5 @@
1
- import password from '@inquirer/password';
2
1
  import input from '@inquirer/input';
2
+ import password from '@inquirer/password';
3
3
  import select from '@inquirer/select';
4
4
  import { MESSAGE_BROKER_TYPES, STORAGE_PROVIDERS } from './enums.js';
5
5
  export function isInteractive(opts) {
@@ -67,26 +67,7 @@ async function promptEnvs(variant, context) {
67
67
  message: `Environment slug #${envs.length + 1} (3 letters)`,
68
68
  validate: (v) => (v.length >= 1 && v.length <= 3 ? true : 'Use 1–3 characters'),
69
69
  });
70
- if (variant === 'database' && context?.databaseType === 'redis') {
71
- const mode = await select({ message: 'Redis connection', choices: [
72
- { name: 'Redis URL', value: 'url' }, { name: 'Import cloud instance', value: 'import' }, { name: 'Provision cloud instance', value: 'provision' },
73
- ] });
74
- if (mode === 'url')
75
- envs.push({ slug, connection_url: await password({ message: 'Redis URL (redis:// or rediss://)' }) });
76
- else {
77
- const row = { slug, cloud: await input({ message: 'Cloud connection tag' }),
78
- instance: await input({ message: 'Redis instance name or resource ID' }), region: await input({ message: 'Cloud region' }), importExisting: mode === 'import' };
79
- if (mode === 'import') {
80
- const token = await password({ message: 'AWS Redis AUTH token (leave empty for GCP/Azure or stored credentials)' });
81
- if (token)
82
- row.masterPassword = token;
83
- }
84
- else
85
- row.redis = await promptJsonObject('Redis provider settings (GCP: authorizedNetwork, memorySizeGb; AWS: cacheSubnetGroupName, securityGroupIds, nodeType; Azure: resourceGroup, sku)');
86
- envs.push(row);
87
- }
88
- }
89
- else if (variant === 'database' || variant === 'graph') {
70
+ if (variant === 'database' || variant === 'graph') {
90
71
  const connection_url = await input({
91
72
  message: 'Connection URL',
92
73
  });
@@ -165,6 +146,15 @@ async function promptField(field, patch) {
165
146
  throw new Error('envs field missing envsVariant');
166
147
  return promptEnvs(field.envsVariant);
167
148
  }
149
+ if (field.kind === 'secret') {
150
+ // Masked and never trimmed: a secret is stored exactly as typed or pasted, apart from a trailing line break.
151
+ const value = (await password({ message: field.label, mask: '*' })).replace(/\r?\n$/, '');
152
+ if (!value && !required)
153
+ return undefined;
154
+ if (!value && required)
155
+ throw new Error(`${field.label} is required`);
156
+ return value;
157
+ }
168
158
  const value = await input({
169
159
  message: field.label,
170
160
  default: field.default !== undefined ? String(field.default) : undefined,
@@ -178,9 +168,14 @@ async function promptField(field, patch) {
178
168
  export async function promptForm(schema, opts) {
179
169
  const patch = Boolean(opts?.patch);
180
170
  const body = {};
171
+ const preset = opts?.preset ?? {};
181
172
  let vectorType;
182
- let databaseType;
183
173
  for (const field of schema.fields) {
174
+ // A value already given on the command line (such as -k) is used, not asked for again.
175
+ if (preset[field.key] !== undefined && preset[field.key] !== '') {
176
+ body[field.key] = preset[field.key];
177
+ continue;
178
+ }
184
179
  if (patch && !field.required) {
185
180
  const set = await askYesNo(`Set ${field.label}?`, false);
186
181
  if (!set)
@@ -191,14 +186,9 @@ export async function promptForm(schema, opts) {
191
186
  if (value !== undefined) {
192
187
  body.type = value;
193
188
  vectorType = String(value);
194
- databaseType = String(value);
195
189
  }
196
190
  continue;
197
191
  }
198
- if (field.kind === 'envs' && field.envsVariant === 'database' && databaseType === 'redis') {
199
- body[field.key] = await promptEnvs('database', { databaseType });
200
- continue;
201
- }
202
192
  if (field.kind === 'envs' && field.envsVariant === 'vector') {
203
193
  const envs = await promptEnvs('vector', { vectorType });
204
194
  if (envs.length)
@@ -198,13 +198,13 @@ const SCHEMAS = {
198
198
  'secrets:create': {
199
199
  fields: [
200
200
  { key: 'key', label: 'Secret key', kind: 'text', required: true },
201
- { key: 'value', label: 'Secret value', kind: 'text', required: true },
201
+ { key: 'value', label: 'Secret value (hidden as you type)', kind: 'secret', required: true },
202
202
  DESC,
203
203
  ],
204
204
  },
205
205
  'secrets:update': {
206
206
  fields: optional([
207
- { key: 'value', label: 'Secret value', kind: 'text' },
207
+ { key: 'value', label: 'Secret value (hidden as you type)', kind: 'secret' },
208
208
  DESC,
209
209
  ]),
210
210
  },
@@ -1,4 +1,5 @@
1
- export type FieldKind = 'text' | 'number' | 'enum' | 'envs';
1
+ /** `secret` is typed without being shown on screen. */
2
+ export type FieldKind = 'text' | 'secret' | 'number' | 'enum' | 'envs';
2
3
  export type EnvsVariant = 'database' | 'graph' | 'storage' | 'broker' | 'vector' | 'simple';
3
4
  export interface FormField {
4
5
  key: string;
@@ -24,7 +24,6 @@ export declare function getApp(ctx: WorkspaceContext, opts: {
24
24
  tag?: string;
25
25
  }): Promise<unknown>;
26
26
  export declare function createApp(ctx: WorkspaceContext, body: Record<string, unknown>): Promise<unknown>;
27
- export declare function getAppVersions(ctx: WorkspaceContext, appId: string): Promise<unknown>;
28
27
  export declare function updateApp(ctx: WorkspaceContext, appId: string, body: Record<string, unknown>): Promise<unknown>;
29
28
  export declare function updateAppViaProxy(ctx: WorkspaceContext, tag: string, body: Record<string, unknown>): Promise<unknown>;
30
29
  export declare function deleteApp(ctx: WorkspaceContext, appId: string): Promise<unknown>;
@@ -428,19 +428,22 @@ export async function createApp(ctx, body) {
428
428
  const result = await client(ctx).post('/apps/v1/create', payload);
429
429
  return unwrapOne(result);
430
430
  }
431
- export async function getAppVersions(ctx, appId) {
432
- return unwrapOne(await client(ctx).getPath(`/apps/v1/${appId}/versions/metadata`, workspaceAuthQuery(ctx)));
433
- }
434
431
  export async function updateApp(ctx, appId, body) {
435
- const q = workspaceAuthQuery(ctx);
436
- const result = await client(ctx).put(`/apps/v1/${appId}?${new URLSearchParams(q).toString()}`, { component: 'app', ...body });
432
+ const q = {
433
+ user_id: ctx.credentials.user_id,
434
+ public_key: ctx.credentials.public_key,
435
+ };
436
+ const result = await client(ctx).put(`/apps/v1/${appId}?${new URLSearchParams(q).toString()}`, body);
437
437
  return unwrapOne(result);
438
438
  }
439
439
  export async function updateAppViaProxy(ctx, tag, body) {
440
440
  return proxy(ctx).execute('app', 'update', [tag, body]);
441
441
  }
442
442
  export async function deleteApp(ctx, appId) {
443
- const q = workspaceAuthQuery(ctx);
443
+ const q = {
444
+ user_id: ctx.credentials.user_id,
445
+ public_key: ctx.credentials.public_key,
446
+ };
444
447
  return client(ctx).delete(`/apps/v1/${appId}?${new URLSearchParams(q).toString()}`);
445
448
  }
446
449
  // —— App actions (sdk-proxy — admin op, requires access key) ——
@@ -7,5 +7,7 @@ export declare function resolveBody(opts: InteractiveOpts & {
7
7
  schema?: FormSchema;
8
8
  patch?: boolean;
9
9
  requireBody?: boolean;
10
+ /** Fields already given as flags; the form does not ask for them. */
11
+ preset?: Record<string, unknown>;
10
12
  }): Promise<Record<string, unknown> | undefined>;
11
13
  export declare function bodyRequiredHint(schemaKey?: string): string;
@@ -20,7 +20,7 @@ export async function resolveBody(opts) {
20
20
  }
21
21
  const schema = opts.schema ?? (opts.schemaKey ? getFormSchema(opts.schemaKey) : undefined);
22
22
  if (schema && isInteractive(opts)) {
23
- return promptForm(schema, { patch: opts.patch ?? opts.schemaKey?.endsWith(':update') });
23
+ return promptForm(schema, { patch: opts.patch ?? opts.schemaKey?.endsWith(':update'), preset: opts.preset });
24
24
  }
25
25
  if (opts.requireBody && isInteractive(opts) === false) {
26
26
  return undefined;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Reads the pass and fail counts from a test run's output, for the runners people use most. Only the summary lines
3
+ * are read, last one wins (a runner can print progress before its final tally). Nothing found means the counts are
4
+ * unknown; the exit code still says whether the run passed.
5
+ */
6
+ export interface ITestCounts {
7
+ passed?: number;
8
+ failed?: number;
9
+ skipped?: number;
10
+ runner?: string;
11
+ }
12
+ export declare function readTestCounts(output: string): ITestCounts;
@@ -0,0 +1,50 @@
1
+ // eslint-disable-next-line no-control-regex
2
+ const ANSI = /\u001b\[[0-9;]*[A-Za-z]/g;
3
+ const num = (s) => (s === undefined ? undefined : Number(s));
4
+ const RULES = [
5
+ // Jest: "Tests: 1 failed, 2 skipped, 40 passed, 43 total"
6
+ {
7
+ runner: 'jest',
8
+ re: /^Tests:\s+(.*\btotal)\s*$/m,
9
+ read: (m) => ({ failed: num(/(\d+) failed/.exec(m[1])?.[1]) ?? 0, skipped: num(/(\d+) skipped/.exec(m[1])?.[1]), passed: num(/(\d+) passed/.exec(m[1])?.[1]) ?? 0 }),
10
+ },
11
+ // Vitest: " Tests 2 failed | 40 passed (42)"
12
+ {
13
+ runner: 'vitest',
14
+ re: /^\s*Tests\s+(.*\(\d+\))\s*$/m,
15
+ read: (m) => ({ failed: num(/(\d+) failed/.exec(m[1])?.[1]) ?? 0, skipped: num(/(\d+) skipped/.exec(m[1])?.[1]), passed: num(/(\d+) passed/.exec(m[1])?.[1]) ?? 0 }),
16
+ },
17
+ // node:test and TAP: "# pass 48" / "# fail 0" (node:test also prints "ℹ pass 48")
18
+ {
19
+ runner: 'node-test',
20
+ re: /^(?:#|ℹ) pass (\d+)\s*$[\s\S]*?^(?:#|ℹ) fail (\d+)\s*$/m,
21
+ read: (m) => ({ passed: Number(m[1]), failed: Number(m[2]) }),
22
+ },
23
+ // Mocha: " 40 passing (2s)" then optionally " 2 failing"
24
+ {
25
+ runner: 'mocha',
26
+ re: /^\s*(\d+) passing \([^)]*\)\s*$(?:\s*^\s*(\d+) pending\s*$)?(?:\s*^\s*(\d+) failing\s*$)?/m,
27
+ read: (m) => ({ passed: Number(m[1]), skipped: num(m[2]), failed: num(m[3]) ?? 0 }),
28
+ },
29
+ // pytest: "==== 2 failed, 40 passed, 1 skipped in 3.2s ===="
30
+ {
31
+ runner: 'pytest',
32
+ re: /^=+ (.*\b(?:passed|failed)\b.*) in [\d.]+s(?: \([^)]*\))? =+\s*$/m,
33
+ read: (m) => ({ failed: num(/(\d+) failed/.exec(m[1])?.[1]) ?? 0, skipped: num(/(\d+) skipped/.exec(m[1])?.[1]), passed: num(/(\d+) passed/.exec(m[1])?.[1]) ?? 0 }),
34
+ },
35
+ ];
36
+ export function readTestCounts(output) {
37
+ const text = output.replace(ANSI, '');
38
+ let best;
39
+ for (const rule of RULES) {
40
+ const re = new RegExp(rule.re.source, rule.re.flags.includes('g') ? rule.re.flags : `${rule.re.flags}g`);
41
+ let m;
42
+ while ((m = re.exec(text))) {
43
+ if (!best || m.index >= best.at) {
44
+ const counts = Object.fromEntries(Object.entries(rule.read(m)).filter(([, v]) => v !== undefined && !Number.isNaN(v)));
45
+ best = { at: m.index, counts: { ...counts, runner: rule.runner } };
46
+ }
47
+ }
48
+ }
49
+ return best?.counts ?? {};
50
+ }
@@ -0,0 +1,37 @@
1
+ import { type AgentClient } from './work.js';
2
+ /**
3
+ * Records what Ductape made or ran on the work it was made for: a Deploy release, deployment or build, or a test run
4
+ * through `ductape work test`. The work tracker finds the item (the one the agent session, or the person in this repo,
5
+ * holds) and checks releases, deployments and builds against Deploy's own records, so nothing here is taken on trust.
6
+ *
7
+ * It never fails the command it follows: the deploy or test has already happened, and a work tracker that cannot be
8
+ * reached is no reason to report it as failed. Set DUCTAPE_WORK_RECORD=off to skip it, or DUCTAPE_WORK_ITEM=W-12 to
9
+ * name the item.
10
+ */
11
+ export interface IDeliveredArtifact {
12
+ kind: 'release' | 'deployment' | 'build' | 'test_report';
13
+ ref: string;
14
+ url?: string;
15
+ title?: string;
16
+ meta?: Record<string, string | number | boolean>;
17
+ source?: 'ductape_cli';
18
+ }
19
+ export interface IDeliveryResult {
20
+ recorded: string[];
21
+ candidates: string[];
22
+ reason?: string;
23
+ artifact?: {
24
+ kind: string;
25
+ ref: string;
26
+ title: string | null;
27
+ source: string;
28
+ };
29
+ }
30
+ /** What to tell the person after recording. Silent when there was no work to record on. */
31
+ export declare function describeDelivery(result: IDeliveryResult, artifact: IDeliveredArtifact): string | undefined;
32
+ export declare function recordOnWork(artifact: IDeliveredArtifact, opts?: {
33
+ item?: string;
34
+ quiet?: boolean;
35
+ client?: AgentClient;
36
+ session?: string;
37
+ }): Promise<IDeliveryResult | undefined>;
@@ -0,0 +1,61 @@
1
+ import { WorkClient, resolveClient } from './work.js';
2
+ const FLAG = { release: '--release', deployment: '--deployment', build: '--build', test_report: '--test-report' };
3
+ const note = (message) => process.stderr.write(`${message}\n`);
4
+ /** The agent client this command runs under, when it can tell: DUCTAPE_AGENT_CLIENT, or Claude Code's own marker. */
5
+ function agentClient(env = process.env) {
6
+ try {
7
+ const flagged = resolveClient();
8
+ if (flagged)
9
+ return flagged;
10
+ }
11
+ catch {
12
+ return undefined;
13
+ }
14
+ return env.CLAUDECODE === '1' ? 'claude-code' : undefined;
15
+ }
16
+ /** What to tell the person after recording. Silent when there was no work to record on. */
17
+ export function describeDelivery(result, artifact) {
18
+ const what = `${artifact.kind.replace('_', ' ')} ${result.artifact?.title ?? artifact.ref}`;
19
+ if (result.recorded.length) {
20
+ const how = result.artifact?.source === 'ductape' ? ', checked against Ductape Deploy' : result.artifact?.source === 'ductape_cli' ? ', run by the Ductape CLI' : '';
21
+ return `Recorded ${what} on ${result.recorded.join(', ')}${how}.`;
22
+ }
23
+ if (result.reason === 'ambiguous') {
24
+ const fix = artifact.kind === 'test_report' ? 'Run it again with --item <ref>' : `Record it on one with: ductape work update <ref> ${FLAG[artifact.kind]} ${artifact.ref}`;
25
+ return `Not recorded on any work item: you hold ${result.candidates.join(', ')}. ${fix}`;
26
+ }
27
+ return undefined;
28
+ }
29
+ export async function recordOnWork(artifact, opts = {}) {
30
+ if ((process.env.DUCTAPE_WORK_RECORD ?? '').toLowerCase() === 'off')
31
+ return undefined;
32
+ let work;
33
+ try {
34
+ work = new WorkClient({ client: opts.client ?? agentClient(), session: opts.session });
35
+ }
36
+ catch {
37
+ return undefined; // not signed in, or no workspace: nothing to record on
38
+ }
39
+ const body = { artifact, repo: work.repo.repo || undefined, item: opts.item ?? process.env.DUCTAPE_WORK_ITEM ?? undefined };
40
+ try {
41
+ let result;
42
+ try {
43
+ result = await work.send('POST', '/deliveries', body);
44
+ }
45
+ catch (error) {
46
+ // A remembered session that has ended or lapsed: fall back to the repo, as a person would.
47
+ if (!/SESSION_/.test(error instanceof Error ? error.message : String(error)))
48
+ throw error;
49
+ result = await work.send('POST', '/deliveries', body, false);
50
+ }
51
+ const message = describeDelivery(result, artifact);
52
+ if (message && !opts.quiet)
53
+ note(message);
54
+ return result;
55
+ }
56
+ catch (error) {
57
+ if (!opts.quiet)
58
+ note(`Could not record the ${artifact.kind.replace('_', ' ')} on work: ${error instanceof Error ? error.message : String(error)}`);
59
+ return undefined;
60
+ }
61
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Whether two path patterns can name the same file: the same conservative rule the work tracker service uses. Two
3
+ * patterns overlap when one fixed prefix (the part before any glob character) starts with the other.
4
+ */
5
+ export declare function fixedPrefix(pattern: string): string;
6
+ export declare function pathsOverlap(a: string, b: string): boolean;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Whether two path patterns can name the same file: the same conservative rule the work tracker service uses. Two
3
+ * patterns overlap when one fixed prefix (the part before any glob character) starts with the other.
4
+ */
5
+ export function fixedPrefix(pattern) {
6
+ const clean = pattern.trim().replace(/^\.\//, '').replace(/\\/g, '/');
7
+ const star = clean.search(/[*?[{]/);
8
+ return star === -1 ? clean : clean.slice(0, star);
9
+ }
10
+ export function pathsOverlap(a, b) {
11
+ const pa = fixedPrefix(a);
12
+ const pb = fixedPrefix(b);
13
+ if (!pa || !pb)
14
+ return true;
15
+ return pa.startsWith(pb) || pb.startsWith(pa);
16
+ }