maritime-cli 1.9.0 → 2.0.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.
Files changed (82) hide show
  1. package/README.md +17 -0
  2. package/bin/maritime.js +40 -0
  3. package/install.js +118 -0
  4. package/package.json +22 -37
  5. package/AGENTS.md +0 -361
  6. package/SKILL.md +0 -181
  7. package/dist/api.d.ts +0 -30
  8. package/dist/api.js +0 -246
  9. package/dist/bundled.d.ts +0 -11
  10. package/dist/bundled.js +0 -25
  11. package/dist/commands/chat.d.ts +0 -2
  12. package/dist/commands/chat.js +0 -120
  13. package/dist/commands/create.d.ts +0 -2
  14. package/dist/commands/create.js +0 -310
  15. package/dist/commands/delete.d.ts +0 -2
  16. package/dist/commands/delete.js +0 -43
  17. package/dist/commands/deploy.d.ts +0 -2
  18. package/dist/commands/deploy.js +0 -180
  19. package/dist/commands/env.d.ts +0 -2
  20. package/dist/commands/env.js +0 -368
  21. package/dist/commands/exec.d.ts +0 -2
  22. package/dist/commands/exec.js +0 -31
  23. package/dist/commands/guide.d.ts +0 -2
  24. package/dist/commands/guide.js +0 -75
  25. package/dist/commands/history.d.ts +0 -2
  26. package/dist/commands/history.js +0 -56
  27. package/dist/commands/info.d.ts +0 -2
  28. package/dist/commands/info.js +0 -78
  29. package/dist/commands/init.d.ts +0 -2
  30. package/dist/commands/init.js +0 -143
  31. package/dist/commands/keys.d.ts +0 -2
  32. package/dist/commands/keys.js +0 -90
  33. package/dist/commands/link.d.ts +0 -4
  34. package/dist/commands/link.js +0 -65
  35. package/dist/commands/list.d.ts +0 -2
  36. package/dist/commands/list.js +0 -55
  37. package/dist/commands/login.d.ts +0 -2
  38. package/dist/commands/login.js +0 -368
  39. package/dist/commands/logout.d.ts +0 -2
  40. package/dist/commands/logout.js +0 -12
  41. package/dist/commands/logs.d.ts +0 -2
  42. package/dist/commands/logs.js +0 -89
  43. package/dist/commands/message.d.ts +0 -8
  44. package/dist/commands/message.js +0 -75
  45. package/dist/commands/open.d.ts +0 -2
  46. package/dist/commands/open.js +0 -25
  47. package/dist/commands/restart.d.ts +0 -2
  48. package/dist/commands/restart.js +0 -26
  49. package/dist/commands/signup.d.ts +0 -2
  50. package/dist/commands/signup.js +0 -72
  51. package/dist/commands/sleep.d.ts +0 -2
  52. package/dist/commands/sleep.js +0 -22
  53. package/dist/commands/start.d.ts +0 -2
  54. package/dist/commands/start.js +0 -27
  55. package/dist/commands/status.d.ts +0 -2
  56. package/dist/commands/status.js +0 -69
  57. package/dist/commands/stop.d.ts +0 -2
  58. package/dist/commands/stop.js +0 -26
  59. package/dist/commands/templates.d.ts +0 -2
  60. package/dist/commands/templates.js +0 -40
  61. package/dist/commands/triggers.d.ts +0 -2
  62. package/dist/commands/triggers.js +0 -89
  63. package/dist/commands/whoami.d.ts +0 -2
  64. package/dist/commands/whoami.js +0 -76
  65. package/dist/config.d.ts +0 -2
  66. package/dist/config.js +0 -14
  67. package/dist/context.d.ts +0 -39
  68. package/dist/context.js +0 -110
  69. package/dist/index.d.ts +0 -2
  70. package/dist/index.js +0 -186
  71. package/dist/interactive.d.ts +0 -1
  72. package/dist/interactive.js +0 -66
  73. package/dist/output.d.ts +0 -80
  74. package/dist/output.js +0 -176
  75. package/dist/prompt.d.ts +0 -2
  76. package/dist/prompt.js +0 -62
  77. package/dist/resolve.d.ts +0 -16
  78. package/dist/resolve.js +0 -59
  79. package/dist/version-check.d.ts +0 -20
  80. package/dist/version-check.js +0 -81
  81. package/dist/websocket.d.ts +0 -22
  82. package/dist/websocket.js +0 -89
@@ -1,143 +0,0 @@
1
- import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
2
- import { basename, dirname, join } from 'node:path';
3
- import { Command } from 'commander';
4
- import chalk from 'chalk';
5
- import { authPost } from '../api.js';
6
- import { getConfig, writeConfig, writeLink, configExists, CONFIG_FILENAME, } from '../context.js';
7
- import { readBundledFile } from '../bundled.js';
8
- import { promptForValue } from '../prompt.js';
9
- import { isJsonMode, outputResult, fail, handleError, makeSpinner, EXIT } from '../output.js';
10
- /** Where the bundled Claude Code skill is written, relative to the cwd. */
11
- const SKILL_PATH = join('.claude', 'skills', 'maritime', 'SKILL.md');
12
- const SKILL_BUNDLED_NAME = 'SKILL.md';
13
- /**
14
- * Writes the bundled Maritime skill to `.claude/skills/maritime/SKILL.md`
15
- * under `cwd` when that file does not exist yet.
16
- *
17
- * Returns true when the file was written. Returns false when it already
18
- * existed or the CLI build did not ship SKILL.md (skipped silently).
19
- */
20
- function writeSkillFile(cwd) {
21
- const target = join(cwd, SKILL_PATH);
22
- if (existsSync(target))
23
- return false;
24
- const content = readBundledFile(SKILL_BUNDLED_NAME);
25
- if (content === null)
26
- return false;
27
- mkdirSync(dirname(target), { recursive: true });
28
- writeFileSync(target, content);
29
- return true;
30
- }
31
- const AGENTS_MD = (name, instructions) => `# ${name}
32
-
33
- ${instructions || 'Describe what this agent does and how it should behave. This file is the agent\'s persona. It is loaded into the agent\'s workspace at boot.'}
34
-
35
- ## Guidelines
36
- - Be concise and helpful.
37
- - Ask for missing information instead of guessing.
38
- `;
39
- export const initCommand = new Command('init')
40
- .description(`Scaffold ${CONFIG_FILENAME}, create the agent, and link this directory to it`)
41
- .argument('[name]', 'Agent name (defaults to the folder name)')
42
- .option('-t, --template <id>', 'Template to base the agent on (default: openclaw)')
43
- .option('--framework <framework>', 'Framework for bring-your-own-code agents (instead of a template)')
44
- .option('--instructions <text>', 'Plain-English persona for the agent')
45
- .option('--no-create', 'Only write the config files; do not create the agent yet')
46
- .option('--no-skill', `Do not write the Claude Code skill file (${SKILL_PATH})`)
47
- .addHelpText('after', `
48
- Examples:
49
- maritime init # scaffold + create, named after the folder
50
- maritime init support-bot # explicit name
51
- maritime init bot --no-create # just write ${CONFIG_FILENAME} + AGENTS.md
52
- After init, run \`maritime deploy\` to push changes, or \`maritime chat "…"\`.`)
53
- .action(async (nameArg, opts) => {
54
- try {
55
- const interactive = !isJsonMode() && process.stdin.isTTY;
56
- const existing = getConfig() ?? {};
57
- // Name: arg → existing config → folder name (prompted if interactive).
58
- let name = nameArg || existing.name || basename(process.cwd());
59
- if (interactive && !nameArg && !existing.name) {
60
- name = (await promptForValue('Agent name', undefined)) || name;
61
- }
62
- if (!name) {
63
- fail('Agent name is required.', { code: 'usage', exitCode: EXIT.USAGE });
64
- }
65
- // Template/framework: explicit flags win; else keep existing; else default
66
- // to the openclaw template so a bare `init` yields a *working* agent.
67
- const framework = opts.framework || existing.framework;
68
- const template = framework
69
- ? undefined
70
- : opts.template || existing.template || 'openclaw';
71
- const instructions = opts.instructions ?? existing.instructions ?? '';
72
- const config = {
73
- name,
74
- ...(template ? { template } : {}),
75
- ...(framework ? { framework } : {}),
76
- ...(instructions ? { instructions } : {}),
77
- env: existing.env ?? [],
78
- };
79
- const wroteConfig = !configExists();
80
- const configPath = writeConfig(config);
81
- // Scaffold an AGENTS.md persona file if there isn't one already.
82
- const agentsMdPath = join(process.cwd(), 'AGENTS.md');
83
- let wroteAgentsMd = false;
84
- if (!existsSync(agentsMdPath)) {
85
- writeFileSync(agentsMdPath, AGENTS_MD(name, instructions));
86
- wroteAgentsMd = true;
87
- }
88
- // Teach Claude Code (and any agent that reads .claude/skills) how to
89
- // drive this CLI from inside the project.
90
- const wroteSkill = opts.skill !== false && writeSkillFile(process.cwd());
91
- // Create + link unless --no-create.
92
- let agent = null;
93
- let linkPath = null;
94
- if (opts.create !== false) {
95
- const spinner = await makeSpinner(`Creating ${chalk.bold(name)}...`);
96
- try {
97
- const body = { name };
98
- if (template)
99
- body.templateId = template;
100
- if (framework)
101
- body.framework = framework;
102
- if (instructions)
103
- body.instructions = instructions;
104
- agent = await authPost('/api/agents', body);
105
- }
106
- catch (error) {
107
- spinner.fail('Failed to create agent');
108
- throw error;
109
- }
110
- spinner.succeed(chalk.green('Created ') + chalk.bold(agent.name) + chalk.dim(` (${agent.id})`));
111
- linkPath = writeLink({ agentId: agent.id, name: agent.name });
112
- }
113
- outputResult({
114
- ok: true,
115
- action: 'init',
116
- config: configPath,
117
- wroteConfig,
118
- wroteAgentsMd,
119
- wroteSkill,
120
- agentId: agent?.id ?? null,
121
- agentName: agent?.name ?? name,
122
- linked: Boolean(linkPath),
123
- }, () => {
124
- console.log(chalk.dim(` ${wroteConfig ? 'wrote' : 'updated'} ${CONFIG_FILENAME}`));
125
- if (wroteAgentsMd)
126
- console.log(chalk.dim(' wrote AGENTS.md'));
127
- if (wroteSkill)
128
- console.log(chalk.dim(` wrote ${SKILL_PATH}`));
129
- if (agent) {
130
- console.log(chalk.dim(' linked this directory → ') + chalk.bold(agent.name));
131
- console.log();
132
- console.log('Next: ' + chalk.bold('maritime chat "hello"') + chalk.dim(' · ') + chalk.bold('maritime deploy') + chalk.dim(' to push edits'));
133
- }
134
- else {
135
- console.log();
136
- console.log('Next: ' + chalk.bold('maritime deploy') + chalk.dim(' to create + link the agent'));
137
- }
138
- });
139
- }
140
- catch (error) {
141
- handleError(error);
142
- }
143
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const keysCommand: Command;
@@ -1,90 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { authGet, authPost, authDelete } from '../api.js';
4
- import { isJsonMode, outputJson, outputResult, handleError } from '../output.js';
5
- const VALID_SCOPES = ['provision', 'deploy', 'secrets', 'manage'];
6
- export const keysCommand = new Command('keys')
7
- .description('Manage long-lived API keys (mk_…) for non-interactive / AI-agent access');
8
- keysCommand
9
- .command('create')
10
- .description('Mint a new API key. Shown once, so save it as MARITIME_TOKEN.')
11
- .option('-n, --name <name>', 'Label for the key', 'cli-agent')
12
- .option('-s, --scopes <scopes>', `Comma-separated scopes (${VALID_SCOPES.join(', ')}); "manage" = all. Defaults to full access. Pass a narrower set to restrict the key.`, 'provision,deploy,secrets,manage')
13
- .action(async (opts) => {
14
- try {
15
- const scopes = String(opts.scopes)
16
- .split(',')
17
- .map((s) => s.trim())
18
- .filter(Boolean);
19
- const bad = scopes.filter((s) => !VALID_SCOPES.includes(s));
20
- if (bad.length) {
21
- handleError(new Error(`Unknown scope(s): ${bad.join(', ')}. Valid: ${VALID_SCOPES.join(', ')}`));
22
- return;
23
- }
24
- const created = await authPost('/api/v1/keys', { name: opts.name, scopes });
25
- outputResult(created, () => {
26
- console.log(chalk.green('Created API key ') + chalk.bold(created.name) + chalk.dim(` [${created.scopes.join(', ')}]`));
27
- console.log();
28
- console.log(' ' + chalk.bold(created.raw_key));
29
- console.log();
30
- console.log(chalk.yellow(' Save this now. It will not be shown again.'));
31
- console.log(chalk.dim(' Use it non-interactively with:'));
32
- console.log(chalk.dim(` export MARITIME_TOKEN=${created.raw_key}`));
33
- });
34
- }
35
- catch (error) {
36
- handleError(error);
37
- }
38
- });
39
- keysCommand
40
- .command('list')
41
- .alias('ls')
42
- .description('List your API keys (values are never shown again)')
43
- .action(async () => {
44
- try {
45
- const keys = await authGet('/api/v1/keys');
46
- if (isJsonMode()) {
47
- outputJson(keys);
48
- return;
49
- }
50
- if (keys.length === 0) {
51
- console.log(chalk.dim('No API keys. Run `maritime keys create` to mint one.'));
52
- return;
53
- }
54
- console.log('\n ' +
55
- chalk.dim('ID'.padEnd(14)) +
56
- chalk.dim('NAME'.padEnd(20)) +
57
- chalk.dim('PREFIX'.padEnd(15)) +
58
- chalk.dim('SCOPES'.padEnd(28)) +
59
- chalk.dim('LAST USED'));
60
- console.log(chalk.dim(' ' + '─'.repeat(86)));
61
- for (const k of keys) {
62
- const last = k.last_used_at;
63
- const lastStr = last ? new Date(last).toLocaleString() : chalk.dim('never');
64
- console.log(' ' +
65
- chalk.dim(String(k.id).slice(0, 12).padEnd(14)) +
66
- chalk.bold(String(k.name).slice(0, 18).padEnd(20)) +
67
- ((k.key_prefix || '') + '…').padEnd(15) +
68
- String((k.scopes || []).join(',')).slice(0, 26).padEnd(28) +
69
- lastStr);
70
- }
71
- console.log();
72
- }
73
- catch (error) {
74
- handleError(error);
75
- }
76
- });
77
- keysCommand
78
- .command('revoke')
79
- .alias('delete')
80
- .description('Revoke an API key by ID')
81
- .argument('<id>', 'API key ID (from `maritime keys list`)')
82
- .action(async (id) => {
83
- try {
84
- await authDelete(`/api/v1/keys/${id}`);
85
- outputResult({ ok: true, action: 'revoke', id }, () => console.log(chalk.green('Revoked key ') + chalk.bold(id)));
86
- }
87
- catch (error) {
88
- handleError(error);
89
- }
90
- });
@@ -1,4 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const linkCommand: Command;
3
- /** Read the current link for display (used by whoami/status helpers if needed). */
4
- export declare function currentLink(): import("../context.js").ProjectLink | null;
@@ -1,65 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { authGet } from '../api.js';
4
- import { resolveAgent } from '../resolve.js';
5
- import { writeLink, getLink } from '../context.js';
6
- import { promptForValue } from '../prompt.js';
7
- import { isJsonMode, outputResult, fail, handleError, EXIT } from '../output.js';
8
- export const linkCommand = new Command('link')
9
- .description('Link this directory to an agent, so commands target it without naming it')
10
- .argument('[agent]', 'Agent name or ID (interactive picker if omitted)')
11
- .addHelpText('after', `
12
- Once linked, the agent argument is optional everywhere:
13
- maritime link support-bot
14
- maritime chat "what's open?" # talks to support-bot
15
- maritime logs # support-bot's logs
16
- The link lives in .maritime/ (git-ignored). Re-run to change it.`)
17
- .action(async (agentArg, _opts, command) => {
18
- try {
19
- let agent;
20
- if (agentArg) {
21
- agent = await resolveAgent(agentArg);
22
- }
23
- else {
24
- // Interactive: pick from the caller's agents.
25
- const interactive = !isJsonMode() && process.stdin.isTTY;
26
- if (!interactive) {
27
- fail('Pass an agent name to link to (non-interactive).', {
28
- code: 'usage',
29
- exitCode: EXIT.USAGE,
30
- });
31
- }
32
- const agents = await authGet('/api/agents');
33
- if (agents.length === 0) {
34
- fail('You have no agents yet. Create one with `maritime create <name>` or `maritime init`.', {
35
- code: 'not_found',
36
- exitCode: EXIT.NOT_FOUND,
37
- });
38
- }
39
- console.log(chalk.dim('\nYour agents:'));
40
- agents.forEach((a, i) => {
41
- console.log(` ${chalk.bold(String(i + 1))}. ${a.name} ${chalk.dim(`(${a.status})`)}`);
42
- });
43
- console.log();
44
- const choice = await promptForValue('Link to which? (number or name)');
45
- const idx = parseInt(choice, 10);
46
- agent =
47
- idx >= 1 && idx <= agents.length
48
- ? agents[idx - 1]
49
- : await resolveAgent(choice);
50
- }
51
- const path = writeLink({ agentId: agent.id, name: agent.name });
52
- outputResult({ ok: true, action: 'link', agentId: agent.id, agentName: agent.name, path }, () => {
53
- console.log(chalk.green('Linked ') + chalk.dim('this directory → ') + chalk.bold(agent.name));
54
- console.log(chalk.dim(` ${path}`));
55
- console.log(chalk.dim(' The agent argument is now optional here: try `maritime status`.'));
56
- });
57
- }
58
- catch (error) {
59
- handleError(error);
60
- }
61
- });
62
- /** Read the current link for display (used by whoami/status helpers if needed). */
63
- export function currentLink() {
64
- return getLink();
65
- }
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const listCommand: Command;
@@ -1,55 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { authGet } from '../api.js';
4
- import { isJsonMode, outputJson, handleError } from '../output.js';
5
- function sleepPolicyOf(a) {
6
- if (a.sleepPolicy)
7
- return a.sleepPolicy;
8
- return a.idleTtlSeconds != null && a.idleTtlSeconds <= 0 ? 'always-on' : 'auto-sleep';
9
- }
10
- const statusColors = {
11
- active: chalk.green,
12
- sleeping: chalk.blue,
13
- deploying: chalk.yellow,
14
- error: chalk.red,
15
- stopped: chalk.gray,
16
- };
17
- export const listCommand = new Command('list')
18
- .alias('ls')
19
- .description('List your agents')
20
- .action(async () => {
21
- try {
22
- const agents = await authGet('/api/agents');
23
- if (isJsonMode()) {
24
- outputJson(agents);
25
- return;
26
- }
27
- if (agents.length === 0) {
28
- console.log(chalk.yellow('No agents found.') + ' Run `maritime create` to create one.');
29
- return;
30
- }
31
- console.log('\n ' +
32
- chalk.dim('NAME'.padEnd(24)) +
33
- chalk.dim('STATUS'.padEnd(12)) +
34
- chalk.dim('SLEEP'.padEnd(12)) +
35
- chalk.dim('FRAMEWORK'.padEnd(20)) +
36
- chalk.dim('CREATED'));
37
- console.log(chalk.dim(' ' + '\u2500'.repeat(88)));
38
- for (const a of agents) {
39
- const colorFn = statusColors[a.status] || chalk.white;
40
- const created = a.createdAt ? new Date(a.createdAt).toLocaleDateString() : '';
41
- const name = a.name.length > 22 ? a.name.slice(0, 21) + '\u2026' : a.name;
42
- const fw = a.framework.length > 18 ? a.framework.slice(0, 17) + '\u2026' : a.framework;
43
- console.log(' ' +
44
- chalk.bold(name.padEnd(24)) +
45
- colorFn(a.status.padEnd(12)) +
46
- sleepPolicyOf(a).padEnd(12) +
47
- fw.padEnd(20) +
48
- chalk.dim(created));
49
- }
50
- console.log();
51
- }
52
- catch (error) {
53
- handleError(error);
54
- }
55
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const loginCommand: Command;