maritime-cli 1.9.0 → 2.0.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 (89) hide show
  1. package/README.md +16 -0
  2. package/archives/checksums.txt +6 -0
  3. package/archives/maritime_2.0.1_darwin_amd64.tar.gz +0 -0
  4. package/archives/maritime_2.0.1_darwin_arm64.tar.gz +0 -0
  5. package/archives/maritime_2.0.1_linux_amd64.tar.gz +0 -0
  6. package/archives/maritime_2.0.1_linux_arm64.tar.gz +0 -0
  7. package/archives/maritime_2.0.1_windows_amd64.zip +0 -0
  8. package/archives/maritime_2.0.1_windows_arm64.zip +0 -0
  9. package/bin/maritime.js +40 -0
  10. package/install.js +131 -0
  11. package/package.json +23 -37
  12. package/AGENTS.md +0 -361
  13. package/SKILL.md +0 -181
  14. package/dist/api.d.ts +0 -30
  15. package/dist/api.js +0 -246
  16. package/dist/bundled.d.ts +0 -11
  17. package/dist/bundled.js +0 -25
  18. package/dist/commands/chat.d.ts +0 -2
  19. package/dist/commands/chat.js +0 -120
  20. package/dist/commands/create.d.ts +0 -2
  21. package/dist/commands/create.js +0 -310
  22. package/dist/commands/delete.d.ts +0 -2
  23. package/dist/commands/delete.js +0 -43
  24. package/dist/commands/deploy.d.ts +0 -2
  25. package/dist/commands/deploy.js +0 -180
  26. package/dist/commands/env.d.ts +0 -2
  27. package/dist/commands/env.js +0 -368
  28. package/dist/commands/exec.d.ts +0 -2
  29. package/dist/commands/exec.js +0 -31
  30. package/dist/commands/guide.d.ts +0 -2
  31. package/dist/commands/guide.js +0 -75
  32. package/dist/commands/history.d.ts +0 -2
  33. package/dist/commands/history.js +0 -56
  34. package/dist/commands/info.d.ts +0 -2
  35. package/dist/commands/info.js +0 -78
  36. package/dist/commands/init.d.ts +0 -2
  37. package/dist/commands/init.js +0 -143
  38. package/dist/commands/keys.d.ts +0 -2
  39. package/dist/commands/keys.js +0 -90
  40. package/dist/commands/link.d.ts +0 -4
  41. package/dist/commands/link.js +0 -65
  42. package/dist/commands/list.d.ts +0 -2
  43. package/dist/commands/list.js +0 -55
  44. package/dist/commands/login.d.ts +0 -2
  45. package/dist/commands/login.js +0 -368
  46. package/dist/commands/logout.d.ts +0 -2
  47. package/dist/commands/logout.js +0 -12
  48. package/dist/commands/logs.d.ts +0 -2
  49. package/dist/commands/logs.js +0 -89
  50. package/dist/commands/message.d.ts +0 -8
  51. package/dist/commands/message.js +0 -75
  52. package/dist/commands/open.d.ts +0 -2
  53. package/dist/commands/open.js +0 -25
  54. package/dist/commands/restart.d.ts +0 -2
  55. package/dist/commands/restart.js +0 -26
  56. package/dist/commands/signup.d.ts +0 -2
  57. package/dist/commands/signup.js +0 -72
  58. package/dist/commands/sleep.d.ts +0 -2
  59. package/dist/commands/sleep.js +0 -22
  60. package/dist/commands/start.d.ts +0 -2
  61. package/dist/commands/start.js +0 -27
  62. package/dist/commands/status.d.ts +0 -2
  63. package/dist/commands/status.js +0 -69
  64. package/dist/commands/stop.d.ts +0 -2
  65. package/dist/commands/stop.js +0 -26
  66. package/dist/commands/templates.d.ts +0 -2
  67. package/dist/commands/templates.js +0 -40
  68. package/dist/commands/triggers.d.ts +0 -2
  69. package/dist/commands/triggers.js +0 -89
  70. package/dist/commands/whoami.d.ts +0 -2
  71. package/dist/commands/whoami.js +0 -76
  72. package/dist/config.d.ts +0 -2
  73. package/dist/config.js +0 -14
  74. package/dist/context.d.ts +0 -39
  75. package/dist/context.js +0 -110
  76. package/dist/index.d.ts +0 -2
  77. package/dist/index.js +0 -186
  78. package/dist/interactive.d.ts +0 -1
  79. package/dist/interactive.js +0 -66
  80. package/dist/output.d.ts +0 -80
  81. package/dist/output.js +0 -176
  82. package/dist/prompt.d.ts +0 -2
  83. package/dist/prompt.js +0 -62
  84. package/dist/resolve.d.ts +0 -16
  85. package/dist/resolve.js +0 -59
  86. package/dist/version-check.d.ts +0 -20
  87. package/dist/version-check.js +0 -81
  88. package/dist/websocket.d.ts +0 -22
  89. package/dist/websocket.js +0 -89
@@ -1,72 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { config } from '../config.js';
4
- import { CliHttpError, getApiUrl, postJson } from '../api.js';
5
- import { EXIT, fail, handleError, isJsonMode, makeSpinner, outputResult } from '../output.js';
6
- import { promptForPassword, promptForValue } from '../prompt.js';
7
- /** Statuses from this value up are server faults, not a refused signup. */
8
- const SERVER_ERROR_STATUS = 500;
9
- /**
10
- * Returns the sentence that tells a new account what to do about email
11
- * verification. Deploys and API keys are refused until the link is clicked.
12
- */
13
- function verificationNext(email) {
14
- return (`Verify your email: we sent a link to ${email}. ` +
15
- 'Deploys and API keys are refused until the link is clicked. ' +
16
- 'Run `maritime login --resend` to send it again.');
17
- }
18
- export const signupCommand = new Command('signup')
19
- .description('Create a Maritime account with email and password')
20
- .option('-e, --email <email>', 'Email address')
21
- .option('-p, --password <password>', 'Password')
22
- .option('-n, --name <name>', 'Display name')
23
- .action(async (opts) => {
24
- const interactive = !isJsonMode() && Boolean(process.stdin.isTTY);
25
- if (!interactive && (!opts.email || !opts.password)) {
26
- fail('Email and password are required: pass -e <email> -p <password>.', {
27
- code: 'usage',
28
- exitCode: EXIT.USAGE,
29
- });
30
- }
31
- const email = await promptForValue('Email', opts.email);
32
- const password = await promptForPassword(opts.password);
33
- const name = interactive ? await promptForValue('Name (optional)', opts.name) : opts.name;
34
- if (!email || !password) {
35
- fail('Email and password are required.', { code: 'usage', exitCode: EXIT.USAGE });
36
- }
37
- const spinner = await makeSpinner('Creating account...');
38
- let auth;
39
- try {
40
- auth = await postJson('/api/auth/cli-signup', {
41
- email,
42
- password,
43
- name: name || undefined,
44
- });
45
- }
46
- catch (error) {
47
- spinner.fail('Signup failed');
48
- if (error instanceof CliHttpError) {
49
- fail(error.detail, {
50
- code: error.code ?? 'signup_failed',
51
- status: error.status,
52
- exitCode: error.status >= SERVER_ERROR_STATUS ? EXIT.ERROR : EXIT.AUTH,
53
- });
54
- }
55
- handleError(error);
56
- }
57
- config.set('token', auth.token);
58
- config.set('user', auth.user.email);
59
- config.set('userId', auth.user.id);
60
- config.set('apiUrl', getApiUrl());
61
- spinner.succeed(chalk.green('Authenticated as ') + chalk.bold(auth.user.email));
62
- outputResult({
63
- ok: true,
64
- action: 'signup',
65
- user: auth.user.email,
66
- emailVerified: false,
67
- next: verificationNext(auth.user.email),
68
- }, () => {
69
- console.log(chalk.dim('\nToken saved.'));
70
- console.log(verificationNext(auth.user.email));
71
- });
72
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const sleepCommand: Command;
@@ -1,22 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { authPost } from '../api.js';
4
- import { resolveAgent } from '../resolve.js';
5
- import { isJsonMode, outputJson, handleError, makeSpinner } from '../output.js';
6
- export const sleepCommand = new Command('sleep')
7
- .description('Put an agent to sleep')
8
- .argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
9
- .action(async (agentArg) => {
10
- try {
11
- const agent = await resolveAgent(agentArg);
12
- const spinner = await makeSpinner(`Sleeping ${chalk.bold(agent.name)}...`);
13
- const result = await authPost(`/api/agents/${agent.id}/sleep`);
14
- spinner.succeed(chalk.green('Agent is now sleeping: ') + chalk.bold(agent.name));
15
- if (isJsonMode()) {
16
- outputJson(result);
17
- }
18
- }
19
- catch (error) {
20
- handleError(error);
21
- }
22
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const startCommand: Command;
@@ -1,27 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { authPost } from '../api.js';
4
- import { resolveAgent } from '../resolve.js';
5
- import { outputResult, handleError, makeSpinner } from '../output.js';
6
- export const startCommand = new Command('start')
7
- .description('Start an agent')
8
- .argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
9
- .action(async (agentArg) => {
10
- try {
11
- const agent = await resolveAgent(agentArg);
12
- const spinner = await makeSpinner(`Starting ${chalk.bold(agent.name)}...`);
13
- try {
14
- await authPost(`/api/agents/${agent.id}/start`);
15
- }
16
- catch (error) {
17
- spinner.fail('Failed to start agent');
18
- throw error;
19
- }
20
- spinner.succeed(chalk.green('Started ') + chalk.bold(agent.name));
21
- // Spinner already printed the human line; only --json needs output here.
22
- outputResult({ ok: true, action: 'start', agentId: agent.id, name: agent.name }, () => { });
23
- }
24
- catch (error) {
25
- handleError(error);
26
- }
27
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const statusCommand: Command;
@@ -1,69 +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 { isJsonMode, outputJson, handleError } from '../output.js';
6
- export const statusCommand = new Command('status')
7
- .description('Show detailed status for an agent')
8
- .argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
9
- .action(async (agentArg) => {
10
- try {
11
- const summary = await resolveAgent(agentArg);
12
- const agent = await authGet(`/api/agents/${summary.id}`);
13
- if (isJsonMode()) {
14
- outputJson(agent);
15
- return;
16
- }
17
- console.log();
18
- console.log(chalk.bold(agent.name));
19
- console.log(chalk.dim('─'.repeat(40)));
20
- console.log(` ${'Status:'.padEnd(16)} ${statusColor(agent.status)}`);
21
- console.log(` ${'Framework:'.padEnd(16)} ${agent.framework}`);
22
- const resParts = [];
23
- if (agent.memMb)
24
- resParts.push(`${agent.memMb}MB`);
25
- if (agent.vcpus)
26
- resParts.push(`${agent.vcpus} vCPU`);
27
- if (agent.diskMb)
28
- resParts.push(`${(agent.diskMb / 1024).toFixed(1)}GB disk`);
29
- if (resParts.length)
30
- console.log(` ${'Resources:'.padEnd(16)} ${resParts.join(' / ')} ${chalk.dim('(override)')}`);
31
- if (agent.idleTtlSeconds != null) {
32
- const idle = agent.idleTtlSeconds <= 0 ? 'always-on' : `${agent.idleTtlSeconds}s after request`;
33
- console.log(` ${'Idle:'.padEnd(16)} ${idle}`);
34
- }
35
- console.log(` ${'ID:'.padEnd(16)} ${chalk.dim(agent.id)}`);
36
- if (agent.invocationCount !== undefined) {
37
- console.log(` ${'Invocations:'.padEnd(16)} ${agent.invocationCount}`);
38
- }
39
- if (agent.createdAt) {
40
- console.log(` ${'Created:'.padEnd(16)} ${new Date(agent.createdAt).toLocaleString()}`);
41
- }
42
- if (agent.updatedAt) {
43
- console.log(` ${'Updated:'.padEnd(16)} ${new Date(agent.updatedAt).toLocaleString()}`);
44
- }
45
- if (agent.containerId) {
46
- console.log(` ${'Container:'.padEnd(16)} ${chalk.dim(agent.containerId.slice(0, 12))}`);
47
- }
48
- console.log();
49
- }
50
- catch (error) {
51
- handleError(error);
52
- }
53
- });
54
- function statusColor(status) {
55
- switch (status) {
56
- case 'active':
57
- return chalk.green(status);
58
- case 'sleeping':
59
- return chalk.blue(status);
60
- case 'deploying':
61
- return chalk.yellow(status);
62
- case 'error':
63
- return chalk.red(status);
64
- case 'stopped':
65
- return chalk.gray(status);
66
- default:
67
- return status;
68
- }
69
- }
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const stopCommand: Command;
@@ -1,26 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { authPost } from '../api.js';
4
- import { resolveAgent } from '../resolve.js';
5
- import { outputResult, handleError, makeSpinner } from '../output.js';
6
- export const stopCommand = new Command('stop')
7
- .description('Stop an agent')
8
- .argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
9
- .action(async (agentArg) => {
10
- try {
11
- const agent = await resolveAgent(agentArg);
12
- const spinner = await makeSpinner(`Stopping ${chalk.bold(agent.name)}...`);
13
- try {
14
- await authPost(`/api/agents/${agent.id}/stop`);
15
- }
16
- catch (error) {
17
- spinner.fail('Failed to stop agent');
18
- throw error;
19
- }
20
- spinner.succeed(chalk.green('Stopped ') + chalk.bold(agent.name));
21
- outputResult({ ok: true, action: 'stop', agentId: agent.id, name: agent.name }, () => { });
22
- }
23
- catch (error) {
24
- handleError(error);
25
- }
26
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const templatesCommand: Command;
@@ -1,40 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { publicGet } from '../api.js';
4
- import { isJsonMode, outputJson, handleError } from '../output.js';
5
- export const templatesCommand = new Command('templates')
6
- .description('List available agent templates')
7
- .action(async () => {
8
- try {
9
- const templates = await publicGet('/api/templates');
10
- if (isJsonMode()) {
11
- outputJson(templates);
12
- return;
13
- }
14
- if (templates.length === 0) {
15
- console.log(chalk.dim('No templates available.'));
16
- return;
17
- }
18
- console.log('\n ' +
19
- chalk.dim('NAME'.padEnd(20)) +
20
- chalk.dim('FRAMEWORK'.padEnd(20)) +
21
- chalk.dim('DESCRIPTION'));
22
- console.log(chalk.dim(' ' + '\u2500'.repeat(66)));
23
- for (const t of templates) {
24
- const fw = t.framework.length > 18 ? t.framework.slice(0, 17) + '\u2026' : t.framework;
25
- console.log(' ' +
26
- chalk.bold(t.name.padEnd(20)) +
27
- fw.padEnd(20) +
28
- chalk.dim(t.description || ''));
29
- // Surface the demo recording so the CLI links the same clip the
30
- // dashboard template card does.
31
- if (t.videoUrl) {
32
- console.log(' ' + ' '.repeat(20) + chalk.cyan('\u25b6 demo: ') + chalk.underline(t.videoUrl));
33
- }
34
- }
35
- console.log();
36
- }
37
- catch (error) {
38
- handleError(error);
39
- }
40
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const triggersCommand: Command;
@@ -1,89 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { authGet, authPost, authDelete } from '../api.js';
4
- import { resolveAgent } from '../resolve.js';
5
- import { isJsonMode, outputJson, handleError } from '../output.js';
6
- const triggerListCmd = new Command('list')
7
- .description('List triggers for an agent')
8
- .argument('<agent>', 'Agent name or ID')
9
- .action(async (agentArg) => {
10
- try {
11
- const agent = await resolveAgent(agentArg);
12
- const triggers = await authGet(`/api/agents/${agent.id}/triggers`);
13
- if (isJsonMode()) {
14
- outputJson(triggers);
15
- return;
16
- }
17
- if (triggers.length === 0) {
18
- console.log(chalk.dim('No triggers configured.'));
19
- return;
20
- }
21
- console.log('\n ' +
22
- chalk.dim('ID'.padEnd(14)) +
23
- chalk.dim('TYPE'.padEnd(14)) +
24
- chalk.dim('CONFIG'));
25
- console.log(chalk.dim(' ' + '\u2500'.repeat(50)));
26
- for (const t of triggers) {
27
- const configStr = t.config ? JSON.stringify(t.config) : '';
28
- console.log(' ' +
29
- chalk.dim(t.id.slice(0, 12).padEnd(14)) +
30
- t.type.padEnd(14) +
31
- chalk.dim(configStr.length > 40 ? configStr.slice(0, 39) + '\u2026' : configStr));
32
- }
33
- console.log();
34
- }
35
- catch (error) {
36
- handleError(error);
37
- }
38
- });
39
- const triggerCreateCmd = new Command('create')
40
- .description('Create a trigger for an agent')
41
- .argument('<agent>', 'Agent name or ID')
42
- .requiredOption('--type <type>', 'Trigger type (webhook, cron, telegram, discord)')
43
- .option('--cron <expression>', 'Cron expression (for cron triggers)')
44
- .option('--prompt <text>', 'Message delivered to the agent on each fire (cron triggers only, max 2000 chars)')
45
- .action(async (agentArg, opts) => {
46
- try {
47
- if (opts.prompt !== undefined && opts.type !== 'cron') {
48
- handleError(new Error('--prompt applies to cron triggers only'));
49
- return;
50
- }
51
- const agent = await resolveAgent(agentArg);
52
- const body = { type: opts.type };
53
- const config = {};
54
- if (opts.cron)
55
- config.cron = opts.cron;
56
- if (opts.prompt)
57
- config.prompt = opts.prompt;
58
- if (Object.keys(config).length > 0)
59
- body.config = config;
60
- const trigger = await authPost(`/api/agents/${agent.id}/triggers`, body);
61
- if (isJsonMode()) {
62
- outputJson(trigger);
63
- return;
64
- }
65
- console.log(chalk.green('Trigger created:') + ` ${trigger.id} (${trigger.type})`);
66
- }
67
- catch (error) {
68
- handleError(error);
69
- }
70
- });
71
- const triggerDeleteCmd = new Command('delete')
72
- .description('Delete a trigger')
73
- .argument('<agent>', 'Agent name or ID')
74
- .argument('<trigger-id>', 'Trigger ID')
75
- .action(async (agentArg, triggerId) => {
76
- try {
77
- const agent = await resolveAgent(agentArg);
78
- await authDelete(`/api/agents/${agent.id}/triggers/${triggerId}`);
79
- console.log(chalk.green('Trigger deleted.'));
80
- }
81
- catch (error) {
82
- handleError(error);
83
- }
84
- });
85
- export const triggersCommand = new Command('triggers')
86
- .description('Manage agent triggers')
87
- .addCommand(triggerListCmd)
88
- .addCommand(triggerCreateCmd)
89
- .addCommand(triggerDeleteCmd);
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const whoamiCommand: Command;
@@ -1,76 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { config } from '../config.js';
4
- import { isJsonMode, outputResult, fail, EXIT } from '../output.js';
5
- function decodeJwt(token) {
6
- try {
7
- const parts = token.split('.');
8
- if (parts.length !== 3)
9
- return null;
10
- return JSON.parse(Buffer.from(parts[1], 'base64url').toString());
11
- }
12
- catch {
13
- return null;
14
- }
15
- }
16
- export const whoamiCommand = new Command('whoami')
17
- .description('Show the current authentication (token source, user, expiry)')
18
- .action(() => {
19
- // Env var wins (how an AI agent / CI authenticates), then stored login.
20
- const envToken = process.env.MARITIME_TOKEN;
21
- const token = envToken || config.get('token');
22
- if (!token) {
23
- if (isJsonMode()) {
24
- // Not an error per se, but exit non-zero so scripts can branch.
25
- process.stdout.write(JSON.stringify({ authenticated: false }, null, 2) + '\n');
26
- process.exitCode = EXIT.AUTH;
27
- return;
28
- }
29
- fail('Not logged in. Run `maritime login`, or set MARITIME_TOKEN.', {
30
- code: 'not_authenticated',
31
- exitCode: EXIT.AUTH,
32
- });
33
- }
34
- const source = envToken ? 'env:MARITIME_TOKEN' : 'login';
35
- // API keys (mk_…) aren't JWTs — report them as a long-lived key.
36
- if (token.startsWith('mk_')) {
37
- outputResult({ authenticated: true, method: 'api_key', source, expires: null }, () => {
38
- console.log(chalk.bold('Method: ') + 'API key (mk_…)');
39
- console.log(chalk.bold('Source: ') + source);
40
- console.log(chalk.bold('Token: ') + chalk.green('valid') + chalk.dim(' (does not expire)'));
41
- });
42
- return;
43
- }
44
- const payload = decodeJwt(token);
45
- if (!payload) {
46
- fail('Could not decode token. Re-run `maritime login` or check MARITIME_TOKEN.', {
47
- code: 'bad_token',
48
- exitCode: EXIT.AUTH,
49
- });
50
- }
51
- const email = payload.email || null;
52
- const name = payload.name || null;
53
- const expMs = typeof payload.exp === 'number' ? payload.exp * 1000 : null;
54
- const expired = expMs !== null && Date.now() >= expMs;
55
- outputResult({
56
- authenticated: !expired,
57
- method: 'jwt',
58
- source,
59
- email,
60
- name,
61
- expiresAt: expMs ? new Date(expMs).toISOString() : null,
62
- expired,
63
- }, () => {
64
- if (email)
65
- console.log(chalk.bold('Email: ') + email);
66
- if (name)
67
- console.log(chalk.bold('Name: ') + name);
68
- console.log(chalk.bold('Source: ') + source);
69
- if (expMs) {
70
- console.log(chalk.bold('Token: ') +
71
- (expired ? chalk.red('expired') : chalk.green('valid') + chalk.dim(` (expires ${new Date(expMs).toLocaleDateString()})`)));
72
- }
73
- });
74
- if (expired)
75
- process.exitCode = EXIT.AUTH;
76
- });
package/dist/config.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import Conf from 'conf';
2
- export declare const config: Conf<Record<string, unknown>>;
package/dist/config.js DELETED
@@ -1,14 +0,0 @@
1
- import { chmodSync } from 'node:fs';
2
- import Conf from 'conf';
3
- const configDir = process.env.MARITIME_CONFIG_DIR;
4
- export const config = new Conf({
5
- projectName: 'maritime',
6
- ...(configDir ? { cwd: configDir } : {}),
7
- });
8
- // Restrict config file permissions to owner-only (ignored on Windows)
9
- try {
10
- chmodSync(config.path, 0o600);
11
- }
12
- catch {
13
- // chmodSync may fail on Windows or read-only filesystems
14
- }
package/dist/context.d.ts DELETED
@@ -1,39 +0,0 @@
1
- /**
2
- * Project context — the Vercel/Railway "link a directory to a project" model,
3
- * applied to agents.
4
- *
5
- * .maritime/project.json the LINK: which agent this directory operates on.
6
- * Machine-local, git-ignored. Written by `link`/`init`.
7
- * maritime.json the CONFIG: the source-of-truth description of the
8
- * agent (name, template/framework, persona, env
9
- * keys). Committed to the repo; `deploy` reconciles
10
- * the remote agent to it.
11
- *
12
- * Both are discovered by walking up from the cwd, so commands work from any
13
- * subdirectory of a linked project — just like `git`.
14
- */
15
- export interface ProjectLink {
16
- agentId: string;
17
- name?: string;
18
- }
19
- export interface MaritimeConfig {
20
- name?: string;
21
- /** A curated template id (e.g. "openclaw"). Mutually exclusive with framework. */
22
- template?: string;
23
- /** Framework for bring-your-own-code agents (default "custom"). */
24
- framework?: string;
25
- /** Plain-English persona; becomes the agent's workspace AGENTS.md at boot. */
26
- instructions?: string;
27
- /** Env var KEYS this agent expects. Values are set via `env`, never committed. */
28
- env?: string[];
29
- }
30
- export declare function findLinkPath(start?: string): string | null;
31
- export declare function getLink(): ProjectLink | null;
32
- export declare function getLinkedAgentId(): string | null;
33
- /** Persist the link for `dir`, and git-ignore `.maritime/` so it stays local. */
34
- export declare function writeLink(link: ProjectLink, dir?: string): string;
35
- export declare function findConfigPath(start?: string): string | null;
36
- export declare function getConfig(): MaritimeConfig | null;
37
- export declare function configExists(dir?: string): boolean;
38
- export declare function writeConfig(cfg: MaritimeConfig, dir?: string): string;
39
- export declare const CONFIG_FILENAME = "maritime.json";
package/dist/context.js DELETED
@@ -1,110 +0,0 @@
1
- /**
2
- * Project context — the Vercel/Railway "link a directory to a project" model,
3
- * applied to agents.
4
- *
5
- * .maritime/project.json the LINK: which agent this directory operates on.
6
- * Machine-local, git-ignored. Written by `link`/`init`.
7
- * maritime.json the CONFIG: the source-of-truth description of the
8
- * agent (name, template/framework, persona, env
9
- * keys). Committed to the repo; `deploy` reconciles
10
- * the remote agent to it.
11
- *
12
- * Both are discovered by walking up from the cwd, so commands work from any
13
- * subdirectory of a linked project — just like `git`.
14
- */
15
- import { existsSync, readFileSync, writeFileSync, mkdirSync, appendFileSync, } from 'node:fs';
16
- import { dirname, join, resolve } from 'node:path';
17
- const LINK_DIR = '.maritime';
18
- const LINK_FILE = 'project.json';
19
- const CONFIG_FILE = 'maritime.json';
20
- // ---------------------------------------------------------------------------
21
- // Generic upward-walk lookup
22
- // ---------------------------------------------------------------------------
23
- function findUp(relPath, start = process.cwd()) {
24
- let dir = resolve(start);
25
- // eslint-disable-next-line no-constant-condition
26
- while (true) {
27
- const candidate = join(dir, relPath);
28
- if (existsSync(candidate))
29
- return candidate;
30
- const parent = dirname(dir);
31
- if (parent === dir)
32
- return null;
33
- dir = parent;
34
- }
35
- }
36
- // ---------------------------------------------------------------------------
37
- // Link (.maritime/project.json)
38
- // ---------------------------------------------------------------------------
39
- export function findLinkPath(start = process.cwd()) {
40
- return findUp(join(LINK_DIR, LINK_FILE), start);
41
- }
42
- export function getLink() {
43
- const p = findLinkPath();
44
- if (!p)
45
- return null;
46
- try {
47
- const parsed = JSON.parse(readFileSync(p, 'utf-8'));
48
- return parsed.agentId ? parsed : null;
49
- }
50
- catch {
51
- return null;
52
- }
53
- }
54
- export function getLinkedAgentId() {
55
- return getLink()?.agentId ?? null;
56
- }
57
- /** Persist the link for `dir`, and git-ignore `.maritime/` so it stays local. */
58
- export function writeLink(link, dir = process.cwd()) {
59
- const linkDir = join(dir, LINK_DIR);
60
- mkdirSync(linkDir, { recursive: true });
61
- const p = join(linkDir, LINK_FILE);
62
- writeFileSync(p, JSON.stringify(link, null, 2) + '\n');
63
- ensureGitignored(LINK_DIR, dir);
64
- return p;
65
- }
66
- // ---------------------------------------------------------------------------
67
- // Config (maritime.json)
68
- // ---------------------------------------------------------------------------
69
- export function findConfigPath(start = process.cwd()) {
70
- return findUp(CONFIG_FILE, start);
71
- }
72
- export function getConfig() {
73
- const p = findConfigPath();
74
- if (!p)
75
- return null;
76
- try {
77
- return JSON.parse(readFileSync(p, 'utf-8'));
78
- }
79
- catch {
80
- return null;
81
- }
82
- }
83
- export function configExists(dir = process.cwd()) {
84
- return existsSync(join(dir, CONFIG_FILE));
85
- }
86
- export function writeConfig(cfg, dir = process.cwd()) {
87
- const p = join(dir, CONFIG_FILE);
88
- writeFileSync(p, JSON.stringify(cfg, null, 2) + '\n');
89
- return p;
90
- }
91
- export const CONFIG_FILENAME = CONFIG_FILE;
92
- // ---------------------------------------------------------------------------
93
- // Helpers
94
- // ---------------------------------------------------------------------------
95
- function ensureGitignored(entry, dir) {
96
- const gi = join(dir, '.gitignore');
97
- try {
98
- const current = existsSync(gi) ? readFileSync(gi, 'utf-8') : '';
99
- const present = current
100
- .split('\n')
101
- .some((l) => l.trim() === entry || l.trim() === `${entry}/`);
102
- if (!present) {
103
- const prefix = current && !current.endsWith('\n') ? '\n' : '';
104
- appendFileSync(gi, `${prefix}${entry}\n`);
105
- }
106
- }
107
- catch {
108
- // Best-effort; never block on .gitignore.
109
- }
110
- }
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};