biaws 0.4.0 → 0.5.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.
Files changed (57) hide show
  1. package/README.md +7 -6
  2. package/docs/instance-lifecycle.md +25 -8
  3. package/docs/releasing.md +4 -3
  4. package/package.json +1 -1
  5. package/shared/skillPackage.js +9 -22
  6. package/src/admin/commands.js +18 -45
  7. package/src/admin/monitoringCommands.js +3 -12
  8. package/src/apiClient.js +5 -13
  9. package/src/baseCommands.js +7 -31
  10. package/src/commandFactories.js +5 -17
  11. package/src/commands/agent.js +36 -95
  12. package/src/commands/api.js +1 -2
  13. package/src/commands/applications/get.js +1 -3
  14. package/src/commands/applications/list.js +1 -5
  15. package/src/commands/configure/claude.js +2 -7
  16. package/src/commands/configure/codex.js +2 -7
  17. package/src/commands/configure/skills.js +6 -13
  18. package/src/commands/configure.js +1 -2
  19. package/src/commands/demands/get.js +5 -5
  20. package/src/commands/demands/list.js +1 -5
  21. package/src/commands/demands/task-status.js +2 -6
  22. package/src/commands/demands/tasks.js +1 -3
  23. package/src/commands/instance/backup.js +4 -18
  24. package/src/commands/instance/list.js +2 -8
  25. package/src/commands/instance/remove.js +4 -17
  26. package/src/commands/instance/restore.js +14 -32
  27. package/src/commands/instance/setup.js +12 -36
  28. package/src/commands/instance/show.js +2 -12
  29. package/src/commands/instance/start.js +4 -19
  30. package/src/commands/instance/status.js +4 -24
  31. package/src/commands/instance/stop.js +3 -16
  32. package/src/commands/instance/update.js +30 -58
  33. package/src/commands/instance.js +1 -2
  34. package/src/commands/issues/list.js +1 -5
  35. package/src/commands/monitoring/signal.js +1 -4
  36. package/src/commands/monitoring/signals.js +1 -4
  37. package/src/commands/monitoring.js +8 -26
  38. package/src/commands/skills/update.js +1 -4
  39. package/src/commands/skills.js +19 -58
  40. package/src/configuration/commands.js +27 -63
  41. package/src/configure/command.js +4 -9
  42. package/src/core/configuration.js +15 -45
  43. package/src/core/context.js +17 -43
  44. package/src/core/processRunner.js +11 -19
  45. package/src/core/prompts.js +12 -30
  46. package/src/core/redaction.js +2 -5
  47. package/src/core/terminal.js +1 -4
  48. package/src/core/wizard.js +23 -72
  49. package/src/domain/readService.js +5 -16
  50. package/src/domain/writeCommand.js +5 -12
  51. package/src/domain/writeService.js +10 -17
  52. package/src/instance/command.js +1 -2
  53. package/src/instance/release.js +100 -0
  54. package/src/instance/service.js +77 -203
  55. package/src/localSkills.js +9 -38
  56. package/src/skillPackage.js +1 -4
  57. package/src/workspace/commands.js +15 -24
@@ -11,30 +11,23 @@ import { runSkillsCommand } from "./skills.js";
11
11
  const CODEX_BEGIN = "# BEGIN BIAWS MANAGED MCP";
12
12
  const CODEX_END = "# END BIAWS MANAGED MCP";
13
13
  export const MCP_PACKAGE_NAME = "biaws-mcp";
14
- export const MCP_PACKAGE_VERSION = "0.3.0";
14
+ export const MCP_PACKAGE_VERSION = "0.12.2";
15
15
  export const MCP_PACKAGE_SPEC = `${MCP_PACKAGE_NAME}@${MCP_PACKAGE_VERSION}`;
16
16
  const MCP_COMMAND = "npx";
17
17
  const MCP_ARGS = ["--yes", MCP_PACKAGE_SPEC];
18
18
 
19
19
  function skillTarget(client, projectDirectory) {
20
- return path.join(
21
- projectDirectory,
22
- client === "claude" ? ".claude" : ".agents",
23
- "skills",
24
- );
20
+ return path.join(projectDirectory, client === "claude" ? ".claude" : ".agents", "skills");
25
21
  }
26
22
 
27
23
  function isExpectedClaudeServer(server) {
28
- if (
29
- server?.command === MCP_COMMAND &&
30
- JSON.stringify(server.args || []) === JSON.stringify(MCP_ARGS)
31
- ) {
24
+ if (server?.command === MCP_COMMAND && JSON.stringify(server.args || []) === JSON.stringify(MCP_ARGS)) {
32
25
  return true;
33
26
  }
34
27
  return (
35
28
  server?.command === "node" &&
36
29
  server.args?.length === 1 &&
37
- /(?:^|[\\/])biaws-mcp[\\/]src[\\/]index\.js$/u.test(server.args[0])
30
+ /(?:^|[\\/])biaws-mcp[\\/](?:(?:dist[\\/])?src[\\/]index\.js|bin[\\/]biaws-mcp\.js)$/u.test(server.args[0])
38
31
  );
39
32
  }
40
33
 
@@ -47,12 +40,7 @@ async function readOptional(filePath, fallback = "") {
47
40
  }
48
41
  }
49
42
 
50
- async function writeCodexConfiguration(
51
- projectDirectory,
52
- envFile,
53
- workspaceId,
54
- force,
55
- ) {
43
+ async function writeCodexConfiguration(projectDirectory, envFile, workspaceId, force) {
56
44
  const configPath = path.join(projectDirectory, ".codex", "config.toml");
57
45
  await mkdir(path.dirname(configPath), { recursive: true });
58
46
  let current = await readOptional(configPath);
@@ -67,10 +55,7 @@ async function writeCodexConfiguration(
67
55
  );
68
56
  }
69
57
  if (force) {
70
- current = current.replace(
71
- /\n?\[mcp_servers\.biaws\]\n(?:[^[\n].*\n?)*/gu,
72
- "",
73
- );
58
+ current = current.replace(/\n?\[mcp_servers\.biaws\]\n(?:[^[\n].*\n?)*/gu, "");
74
59
  }
75
60
  const managed = `${CODEX_BEGIN}
76
61
  [mcp_servers.biaws]
@@ -84,12 +69,7 @@ ${CODEX_END}
84
69
  return configPath;
85
70
  }
86
71
 
87
- async function writeClaudeConfiguration(
88
- projectDirectory,
89
- envFile,
90
- workspaceId,
91
- force,
92
- ) {
72
+ async function writeClaudeConfiguration(projectDirectory, envFile, workspaceId, force) {
93
73
  const configPath = path.join(projectDirectory, ".mcp.json");
94
74
  const raw = await readOptional(configPath, "{}");
95
75
  let config;
@@ -99,11 +79,7 @@ async function writeClaudeConfiguration(
99
79
  throw new Error(`JSON inválido em ${configPath}`);
100
80
  }
101
81
  config.mcpServers ||= {};
102
- if (
103
- config.mcpServers.biaws &&
104
- !force &&
105
- !isExpectedClaudeServer(config.mcpServers.biaws)
106
- ) {
82
+ if (config.mcpServers.biaws && !force && !isExpectedClaudeServer(config.mcpServers.biaws)) {
107
83
  throw new Error(
108
84
  `Já existe uma configuração Claude diferente para o servidor biaws em ${configPath}; use --force para substituí-la`,
109
85
  );
@@ -121,12 +97,7 @@ async function writeClaudeConfiguration(
121
97
  return configPath;
122
98
  }
123
99
 
124
- async function resolveWorkspaceId(
125
- api,
126
- requestedWorkspaceId = "",
127
- interactive = false,
128
- prompts,
129
- ) {
100
+ async function resolveWorkspaceId(api, requestedWorkspaceId = "", interactive = false, prompts) {
130
101
  let identity;
131
102
  try {
132
103
  identity = await api.identity();
@@ -146,9 +117,7 @@ async function resolveWorkspaceId(
146
117
  type: "select",
147
118
  message: "Workspace do projeto",
148
119
  choices: workspaces.map((workspace) => ({
149
- name: workspace.name
150
- ? `${workspace.name} (${workspace.id})`
151
- : workspace.id,
120
+ name: workspace.name ? `${workspace.name} (${workspace.id})` : workspace.id,
152
121
  value: workspace.id,
153
122
  })),
154
123
  ...(workspaceId ? { default: workspaceId } : {}),
@@ -169,17 +138,10 @@ async function resolveWorkspaceId(
169
138
 
170
139
  async function configure(api, client, options, context) {
171
140
  if (!["codex", "claude"].includes(client)) {
172
- throw new Error(
173
- "Informe o cliente: biaws workspace agent configure codex|claude",
174
- );
141
+ throw new Error("Informe o cliente: biaws workspace agent configure codex|claude");
175
142
  }
176
143
  const projectDirectory = path.resolve(options.project || process.cwd());
177
- const { workspaceId } = await resolveWorkspaceId(
178
- api,
179
- context.workspaceId,
180
- options.interactive,
181
- options.prompts,
182
- );
144
+ const { workspaceId } = await resolveWorkspaceId(api, context.workspaceId, options.interactive, options.prompts);
183
145
  if (options.interactive) {
184
146
  const confirmed = await options.prompts.ask({
185
147
  name: "confirmConfiguration",
@@ -188,31 +150,18 @@ async function configure(api, client, options, context) {
188
150
  default: true,
189
151
  });
190
152
  if (!confirmed) {
191
- throw new CliError(
192
- "Configuração cancelada antes de qualquer alteração.",
193
- {
194
- code: "PROMPT_CANCELLED",
195
- exitCode: 130,
196
- },
197
- );
153
+ throw new CliError("Configuração cancelada antes de qualquer alteração.", {
154
+ code: "PROMPT_CANCELLED",
155
+ exitCode: 130,
156
+ });
198
157
  }
199
158
  }
200
159
  const scopedApi = api.withWorkspace ? api.withWorkspace(workspaceId) : api;
201
160
  const target = skillTarget(client, projectDirectory);
202
161
  const configPath =
203
162
  client === "codex"
204
- ? await writeCodexConfiguration(
205
- projectDirectory,
206
- context.envFile,
207
- workspaceId,
208
- options.force,
209
- )
210
- : await writeClaudeConfiguration(
211
- projectDirectory,
212
- context.envFile,
213
- workspaceId,
214
- options.force,
215
- );
163
+ ? await writeCodexConfiguration(projectDirectory, context.envFile, workspaceId, options.force)
164
+ : await writeClaudeConfiguration(projectDirectory, context.envFile, workspaceId, options.force);
216
165
  const installation = await runSkillsCommand(scopedApi, "install-all", [], {
217
166
  target,
218
167
  force: options.force,
@@ -290,6 +239,13 @@ async function mcpStatus(envFile, workspaceId) {
290
239
  if (!line.trim()) continue;
291
240
  try {
292
241
  const message = JSON.parse(line);
242
+ if (message.error) {
243
+ finish({
244
+ ok: false,
245
+ detail: message.error.message || "MCP recusou a chamada",
246
+ });
247
+ return;
248
+ }
293
249
  if (message.id === 1 && message.result && !toolsRequested) {
294
250
  toolsRequested = true;
295
251
  child.stdin.write(
@@ -314,9 +270,7 @@ async function mcpStatus(envFile, workspaceId) {
314
270
  }
315
271
  });
316
272
  child.on("error", (error) => finish({ ok: false, detail: error.message }));
317
- child.stdin.on("error", (error) =>
318
- finish({ ok: false, detail: error.message }),
319
- );
273
+ child.stdin.on("error", (error) => finish({ ok: false, detail: error.message }));
320
274
  child.on("exit", (code) => {
321
275
  if (!settled && code !== null) {
322
276
  finish({
@@ -330,7 +284,11 @@ async function mcpStatus(envFile, workspaceId) {
330
284
  jsonrpc: "2.0",
331
285
  id: 1,
332
286
  method: "initialize",
333
- params: { protocolVersion: "2024-11-05", capabilities: {} },
287
+ params: {
288
+ protocolVersion: "2024-11-05",
289
+ capabilities: {},
290
+ clientInfo: { name: "biaws-agent-doctor", version: "1.0.0" },
291
+ },
334
292
  })}\n`,
335
293
  );
336
294
  });
@@ -349,9 +307,7 @@ function configurationStatus(client, contents, envFile, workspaceId) {
349
307
  contents.includes(`BIAWS_WORKSPACE_ID = ${JSON.stringify(workspaceId)}`);
350
308
  return {
351
309
  ok,
352
- detail: ok
353
- ? null
354
- : "A configuração Codex não aponta para a instância selecionada",
310
+ detail: ok ? null : "A configuração Codex não aponta para a instância selecionada",
355
311
  };
356
312
  }
357
313
  try {
@@ -363,9 +319,7 @@ function configurationStatus(client, contents, envFile, workspaceId) {
363
319
  server.env?.BIAWS_WORKSPACE_ID === workspaceId;
364
320
  return {
365
321
  ok,
366
- detail: ok
367
- ? null
368
- : "A configuração Claude não aponta para a instância selecionada",
322
+ detail: ok ? null : "A configuração Claude não aponta para a instância selecionada",
369
323
  };
370
324
  } catch {
371
325
  return { ok: false, detail: "Configuração Claude contém JSON inválido" };
@@ -374,9 +328,7 @@ function configurationStatus(client, contents, envFile, workspaceId) {
374
328
 
375
329
  async function doctor(api, client, options, context) {
376
330
  if (!["codex", "claude"].includes(client)) {
377
- throw new Error(
378
- "Informe o cliente: biaws workspace agent doctor codex|claude",
379
- );
331
+ throw new Error("Informe o cliente: biaws workspace agent doctor codex|claude");
380
332
  }
381
333
  const projectDirectory = path.resolve(options.project || process.cwd());
382
334
  const target = skillTarget(client, projectDirectory);
@@ -398,12 +350,7 @@ async function doctor(api, client, options, context) {
398
350
  workspace: { ok: true, id: resolved.workspaceId },
399
351
  mcp,
400
352
  configuration: {
401
- ...configurationStatus(
402
- client,
403
- configContents,
404
- context.envFile,
405
- resolved.workspaceId,
406
- ),
353
+ ...configurationStatus(client, configContents, context.envFile, resolved.workspaceId),
407
354
  path: configPath,
408
355
  },
409
356
  skills: {
@@ -425,13 +372,7 @@ async function doctor(api, client, options, context) {
425
372
  return result;
426
373
  }
427
374
 
428
- export async function runAgentCommand(
429
- api,
430
- action,
431
- positional,
432
- options,
433
- context,
434
- ) {
375
+ export async function runAgentCommand(api, action, positional, options, context) {
435
376
  const client = positional[0];
436
377
  if (action === "configure") return configure(api, client, options, context);
437
378
  if (action === "doctor") return doctor(api, client, options, context);
@@ -3,8 +3,7 @@ import { Help } from "@oclif/core";
3
3
  import { AuthenticatedApiCommand } from "../baseCommands.js";
4
4
 
5
5
  export default class Api extends AuthenticatedApiCommand {
6
- static description =
7
- "Executa operações autenticadas nos recursos da API do Bondia Workspaces";
6
+ static description = "Executa operações autenticadas nos recursos da API do Bondia Workspaces";
8
7
  static examples = [
9
8
  "<%= config.bin %> api workspaces list --json",
10
9
  "<%= config.bin %> api demands get <id-ou-código> --json",
@@ -10,8 +10,6 @@ export default class ApplicationGet extends ReadCommand {
10
10
  resource: "application",
11
11
  operation: "get",
12
12
  });
13
- this.emit(flags, result, (p) =>
14
- JSON.stringify(p.application || p, null, 2),
15
- );
13
+ this.emit(flags, result, (p) => JSON.stringify(p.application || p, null, 2));
16
14
  }
17
15
  }
@@ -1,8 +1,4 @@
1
- import {
2
- connectionFlags,
3
- listFlags,
4
- ReadCommand,
5
- } from "../../domain/readCommand.js";
1
+ import { connectionFlags, listFlags, ReadCommand } from "../../domain/readCommand.js";
6
2
  import { table } from "../../domain/readService.js";
7
3
  export default class ApplicationList extends ReadCommand {
8
4
  static description = "lista aplicações do workspace";
@@ -1,14 +1,9 @@
1
1
  import { ProjectCommand } from "../../baseCommands.js";
2
- import {
3
- configureContextFlags,
4
- interactiveConfigureInput,
5
- legacyAgentContext,
6
- } from "../../configure/command.js";
2
+ import { configureContextFlags, interactiveConfigureInput, legacyAgentContext } from "../../configure/command.js";
7
3
  import { runAgentCommand } from "../agent.js";
8
4
 
9
5
  export default class ConfigureClaude extends ProjectCommand {
10
- static description =
11
- "configura MCP e skills do Claude sem persistir credenciais no projeto";
6
+ static description = "configura MCP e skills do Claude sem persistir credenciais no projeto";
12
7
  static flags = configureContextFlags;
13
8
 
14
9
  async run() {
@@ -1,14 +1,9 @@
1
1
  import { ProjectCommand } from "../../baseCommands.js";
2
- import {
3
- configureContextFlags,
4
- interactiveConfigureInput,
5
- legacyAgentContext,
6
- } from "../../configure/command.js";
2
+ import { configureContextFlags, interactiveConfigureInput, legacyAgentContext } from "../../configure/command.js";
7
3
  import { runAgentCommand } from "../agent.js";
8
4
 
9
5
  export default class ConfigureCodex extends ProjectCommand {
10
- static description =
11
- "configura MCP e skills do Codex sem persistir credenciais no projeto";
6
+ static description = "configura MCP e skills do Codex sem persistir credenciais no projeto";
12
7
  static flags = configureContextFlags;
13
8
 
14
9
  async run() {
@@ -3,10 +3,7 @@ import path from "node:path";
3
3
  import { Args, Flags } from "@oclif/core";
4
4
 
5
5
  import { ProjectCommand } from "../../baseCommands.js";
6
- import {
7
- configureContextFlags,
8
- configureContextInput,
9
- } from "../../configure/command.js";
6
+ import { configureContextFlags, configureContextInput } from "../../configure/command.js";
10
7
  import { CliError } from "../../core/errors.js";
11
8
  import { runSkillsCommand } from "../skills.js";
12
9
 
@@ -35,20 +32,16 @@ export default class ConfigureSkills extends ProjectCommand {
35
32
  const context = await this.projectContext(configureContextInput(flags), {
36
33
  requireWorkspace: true,
37
34
  });
38
- const target = path.join(
39
- context.projectDirectory,
40
- flags.client === "claude" ? ".claude" : ".agents",
41
- "skills",
42
- );
35
+ const target = path.join(context.projectDirectory, flags.client === "claude" ? ".claude" : ".agents", "skills");
43
36
  let action = args.action;
44
37
  let positional = args.skill ? [args.skill] : [];
45
38
  if (action === "install" && flags.all) action = "install-all";
46
39
  if (action === "install" && !args.skill) {
47
40
  if (!context.isInteractive) {
48
- throw new CliError(
49
- "Informe o ID da skill ou use --all em modo não interativo.",
50
- { code: "SKILL_SELECTION_REQUIRED", exitCode: 2 },
51
- );
41
+ throw new CliError("Informe o ID da skill ou use --all em modo não interativo.", {
42
+ code: "SKILL_SELECTION_REQUIRED",
43
+ exitCode: 2,
44
+ });
52
45
  }
53
46
  const catalog = await context.api.list();
54
47
  if (!catalog.items.length)
@@ -3,8 +3,7 @@ import { Help } from "@oclif/core";
3
3
  import { ProjectCommand } from "../baseCommands.js";
4
4
 
5
5
  export default class Configure extends ProjectCommand {
6
- static description =
7
- "Configura projetos, clientes de agentes e skills de desenvolvimento";
6
+ static description = "Configura projetos, clientes de agentes e skills de desenvolvimento";
8
7
  static examples = [
9
8
  "<%= config.bin %> configure codex",
10
9
  "<%= config.bin %> configure claude",
@@ -6,11 +6,11 @@ export default class DemandGet extends ReadCommand {
6
6
  static flags = connectionFlags;
7
7
  async run() {
8
8
  const { args, flags } = await this.parse(DemandGet);
9
- const result = await this.read(
10
- flags,
11
- (api, c) => api.demand(args.id, { workspaceId: c.workspaceId }),
12
- { resource: "demand", operation: "get", requireWorkspace: true },
13
- );
9
+ const result = await this.read(flags, (api, c) => api.demand(args.id, { workspaceId: c.workspaceId }), {
10
+ resource: "demand",
11
+ operation: "get",
12
+ requireWorkspace: true,
13
+ });
14
14
  this.emit(flags, result, (p) => JSON.stringify(p.request || p, null, 2));
15
15
  }
16
16
  }
@@ -1,9 +1,5 @@
1
1
  import { Flags } from "@oclif/core";
2
- import {
3
- connectionFlags,
4
- listFlags,
5
- ReadCommand,
6
- } from "../../domain/readCommand.js";
2
+ import { connectionFlags, listFlags, ReadCommand } from "../../domain/readCommand.js";
7
3
  import { table } from "../../domain/readService.js";
8
4
  export default class DemandList extends ReadCommand {
9
5
  static description = "lista melhorias no escopo informado";
@@ -26,10 +26,7 @@ export default class DemandTaskStatus extends WriteCommand {
26
26
  flags,
27
27
  "task",
28
28
  async (service) => {
29
- const { request, task } = findTask(
30
- await service.demand(args.demand),
31
- args.task,
32
- );
29
+ const { request, task } = findTask(await service.demand(args.demand), args.task);
33
30
  return {
34
31
  resource: "task",
35
32
  operation: "status.update",
@@ -42,8 +39,7 @@ export default class DemandTaskStatus extends WriteCommand {
42
39
  entity: task,
43
40
  };
44
41
  },
45
- (service, plan) =>
46
- service.updateTaskStatus(plan.requestId, plan.taskId, plan.status),
42
+ (service, plan) => service.updateTaskStatus(plan.requestId, plan.taskId, plan.status),
47
43
  );
48
44
  }
49
45
  }
@@ -17,9 +17,7 @@ export default class DemandTasks extends ReadCommand {
17
17
  workspaceId: c.workspaceId,
18
18
  });
19
19
  const request = payload.request || payload;
20
- const items = (request.tasks || []).filter(
21
- (x) => !flags.status || x.status === flags.status,
22
- );
20
+ const items = (request.tasks || []).filter((x) => !flags.status || x.status === flags.status);
23
21
  return { items, meta: { total: items.length } };
24
22
  },
25
23
  {
@@ -1,21 +1,11 @@
1
1
  import { Flags } from "@oclif/core";
2
2
 
3
3
  import { LocalInstanceCommand } from "../../baseCommands.js";
4
- import {
5
- contextFlags,
6
- contextInput,
7
- instanceArgument,
8
- } from "../../instance/command.js";
9
- import {
10
- backupArguments,
11
- executeInstanceScript,
12
- getInstance,
13
- withPasswordFile,
14
- } from "../../instance/service.js";
4
+ import { contextFlags, contextInput, instanceArgument } from "../../instance/command.js";
5
+ import { backupArguments, executeInstanceScript, getInstance, withPasswordFile } from "../../instance/service.js";
15
6
 
16
7
  export default class InstanceBackup extends LocalInstanceCommand {
17
- static description =
18
- "cria backup completo, criptografado e verificável de uma instância";
8
+ static description = "cria backup completo, criptografado e verificável de uma instância";
19
9
  static args = { instance: instanceArgument };
20
10
  static flags = {
21
11
  ...contextFlags,
@@ -32,11 +22,7 @@ export default class InstanceBackup extends LocalInstanceCommand {
32
22
  async run() {
33
23
  const { args, flags } = await this.parse(InstanceBackup);
34
24
  const context = await this.localContext(contextInput(flags, args.instance));
35
- const instance = await getInstance(
36
- context,
37
- this.adapters.filesystem,
38
- args.instance,
39
- );
25
+ const instance = await getInstance(context, this.adapters.filesystem, args.instance);
40
26
  let password;
41
27
  if (!flags["password-file"]) {
42
28
  if (!context.isInteractive)
@@ -1,11 +1,7 @@
1
1
  import { Flags } from "@oclif/core";
2
2
 
3
3
  import { LocalInstanceCommand } from "../../baseCommands.js";
4
- import {
5
- contextFlags,
6
- contextInput,
7
- writeResult,
8
- } from "../../instance/command.js";
4
+ import { contextFlags, contextInput, writeResult } from "../../instance/command.js";
9
5
  import { listInstances } from "../../instance/service.js";
10
6
 
11
7
  export default class InstanceList extends LocalInstanceCommand {
@@ -18,9 +14,7 @@ export default class InstanceList extends LocalInstanceCommand {
18
14
  async run() {
19
15
  const { flags } = await this.parse(InstanceList);
20
16
  const context = await this.localContext(contextInput(flags));
21
- const instances = (
22
- await listInstances(context, this.adapters.filesystem)
23
- ).map(({ env, ...item }) => item);
17
+ const instances = (await listInstances(context, this.adapters.filesystem)).map(({ env, ...item }) => item);
24
18
  writeResult(
25
19
  this,
26
20
  instances,
@@ -1,20 +1,11 @@
1
1
  import { Flags } from "@oclif/core";
2
2
 
3
3
  import { LocalInstanceCommand } from "../../baseCommands.js";
4
- import {
5
- contextFlags,
6
- contextInput,
7
- instanceArgument,
8
- } from "../../instance/command.js";
9
- import {
10
- executeInstanceScript,
11
- getInstance,
12
- removeArguments,
13
- } from "../../instance/service.js";
4
+ import { contextFlags, contextInput, instanceArgument } from "../../instance/command.js";
5
+ import { executeInstanceScript, getInstance, removeArguments } from "../../instance/service.js";
14
6
 
15
7
  export default class InstanceRemove extends LocalInstanceCommand {
16
- static description =
17
- "remove uma instância preservando bind mounts externos por padrão";
8
+ static description = "remove uma instância preservando bind mounts externos por padrão";
18
9
  static args = { instance: instanceArgument };
19
10
  static flags = {
20
11
  ...contextFlags,
@@ -28,11 +19,7 @@ export default class InstanceRemove extends LocalInstanceCommand {
28
19
  async run() {
29
20
  const { args, flags } = await this.parse(InstanceRemove);
30
21
  const context = await this.localContext(contextInput(flags, args.instance));
31
- const instance = await getInstance(
32
- context,
33
- this.adapters.filesystem,
34
- args.instance,
35
- );
22
+ const instance = await getInstance(context, this.adapters.filesystem, args.instance);
36
23
  if (!flags.yes) {
37
24
  if (!context.isInteractive)
38
25
  this.error("Remoção exige --yes em modo não interativo.", {
@@ -1,21 +1,11 @@
1
1
  import { Flags } from "@oclif/core";
2
2
 
3
3
  import { LocalInstanceCommand } from "../../baseCommands.js";
4
- import {
5
- contextFlags,
6
- contextInput,
7
- instanceArgument,
8
- } from "../../instance/command.js";
9
- import {
10
- executeInstanceScript,
11
- getInstance,
12
- restoreArguments,
13
- withPasswordFile,
14
- } from "../../instance/service.js";
4
+ import { contextFlags, contextInput, instanceArgument } from "../../instance/command.js";
5
+ import { executeInstanceScript, getInstance, restoreArguments, withPasswordFile } from "../../instance/service.js";
15
6
 
16
7
  export default class InstanceRestore extends LocalInstanceCommand {
17
- static description =
18
- "restaura um backup completo preservando a configuração do host de destino";
8
+ static description = "restaura um backup completo preservando a configuração do host de destino";
19
9
  static args = { instance: instanceArgument };
20
10
  static flags = {
21
11
  ...contextFlags,
@@ -37,11 +27,7 @@ export default class InstanceRestore extends LocalInstanceCommand {
37
27
  async run() {
38
28
  const { args, flags } = await this.parse(InstanceRestore);
39
29
  const context = await this.localContext(contextInput(flags, args.instance));
40
- const instance = await getInstance(
41
- context,
42
- this.adapters.filesystem,
43
- args.instance,
44
- );
30
+ const instance = await getInstance(context, this.adapters.filesystem, args.instance);
45
31
  if (!flags.yes) {
46
32
  if (!context.isInteractive)
47
33
  this.error("Restauração exige --yes em modo não interativo.", {
@@ -72,20 +58,16 @@ export default class InstanceRestore extends LocalInstanceCommand {
72
58
  message: "Senha do backup",
73
59
  });
74
60
  }
75
- const output = await withPasswordFile(
76
- this.adapters.filesystem,
77
- password,
78
- flags["password-file"],
79
- (passwordFile) =>
80
- executeInstanceScript(
81
- restoreArguments(instance, context, {
82
- archive: flags.archive,
83
- passwordFile,
84
- }),
85
- context,
86
- this.adapters.processRunner,
87
- { secrets: password ? [password] : [], silent: flags.json },
88
- ),
61
+ const output = await withPasswordFile(this.adapters.filesystem, password, flags["password-file"], (passwordFile) =>
62
+ executeInstanceScript(
63
+ restoreArguments(instance, context, {
64
+ archive: flags.archive,
65
+ passwordFile,
66
+ }),
67
+ context,
68
+ this.adapters.processRunner,
69
+ { secrets: password ? [password] : [], silent: flags.json },
70
+ ),
89
71
  );
90
72
  if (flags.json)
91
73
  this.output({ json: true }).result({