@bbigbang/cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/cliSupport.d.ts +166 -0
  2. package/dist/cliSupport.js +1306 -0
  3. package/dist/commandCatalog.d.ts +36 -0
  4. package/dist/commandCatalog.js +152 -0
  5. package/dist/commands/actionCommands.d.ts +3 -0
  6. package/dist/commands/actionCommands.js +43 -0
  7. package/dist/commands/authManualCommands.d.ts +3 -0
  8. package/dist/commands/authManualCommands.js +60 -0
  9. package/dist/commands/channelWorkspaceCommands.d.ts +3 -0
  10. package/dist/commands/channelWorkspaceCommands.js +105 -0
  11. package/dist/commands/contextCommands.d.ts +3 -0
  12. package/dist/commands/contextCommands.js +253 -0
  13. package/dist/commands/memoryCommands.d.ts +3 -0
  14. package/dist/commands/memoryCommands.js +154 -0
  15. package/dist/commands/messageCommands.d.ts +3 -0
  16. package/dist/commands/messageCommands.js +241 -0
  17. package/dist/commands/panelCommands.d.ts +3 -0
  18. package/dist/commands/panelCommands.js +218 -0
  19. package/dist/commands/reminderCommands.d.ts +3 -0
  20. package/dist/commands/reminderCommands.js +220 -0
  21. package/dist/commands/skillToolAttachmentCommands.d.ts +3 -0
  22. package/dist/commands/skillToolAttachmentCommands.js +261 -0
  23. package/dist/commands/taskCommands.d.ts +3 -0
  24. package/dist/commands/taskCommands.js +195 -0
  25. package/dist/index.d.ts +2 -0
  26. package/dist/index.js +8 -0
  27. package/dist/manual/generated/command-catalog.json +12452 -0
  28. package/dist/manual/topics/cli-overview.md +116 -0
  29. package/dist/manual/topics/commands.md +706 -0
  30. package/dist/manual/topics/examples.md +194 -0
  31. package/dist/manual/topics/index.md +11 -0
  32. package/dist/program.d.ts +5 -0
  33. package/dist/program.js +52 -0
  34. package/package.json +43 -0
@@ -0,0 +1,36 @@
1
+ import type { Command } from 'commander';
2
+ export interface BigbangCatalogArgument {
3
+ name: string;
4
+ required: boolean;
5
+ variadic: boolean;
6
+ description: string;
7
+ }
8
+ export interface BigbangCatalogOption {
9
+ flags: string;
10
+ short?: string;
11
+ long?: string;
12
+ required: boolean;
13
+ optional: boolean;
14
+ variadic: boolean;
15
+ mandatory: boolean;
16
+ description: string;
17
+ defaultValue?: string | number | boolean | string[] | null;
18
+ }
19
+ export interface BigbangCatalogCommand {
20
+ path: string[];
21
+ name: string;
22
+ description: string;
23
+ arguments: BigbangCatalogArgument[];
24
+ options: BigbangCatalogOption[];
25
+ children: BigbangCatalogCommand[];
26
+ }
27
+ export interface BigbangCommandCatalog {
28
+ schemaVersion: 1;
29
+ generatedBy: 'bigbang-command-catalog';
30
+ root: BigbangCatalogCommand;
31
+ commands: BigbangCatalogCommand[];
32
+ }
33
+ export declare function collectBigbangCommandCatalog(program: Command): BigbangCommandCatalog;
34
+ export declare function renderBigbangCommandManual(catalog: BigbangCommandCatalog): string;
35
+ export declare function renderBigbangCommandSummary(catalog: BigbangCommandCatalog): string[];
36
+ export declare function renderBigbangSharedCatalogModule(catalog: BigbangCommandCatalog): string;
@@ -0,0 +1,152 @@
1
+ export function collectBigbangCommandCatalog(program) {
2
+ const root = collectCommand(program, [], true);
3
+ const commands = flattenCommands(root);
4
+ return {
5
+ schemaVersion: 1,
6
+ generatedBy: 'bigbang-command-catalog',
7
+ root,
8
+ commands,
9
+ };
10
+ }
11
+ export function renderBigbangCommandManual(catalog) {
12
+ const lines = [
13
+ '# Bigbang Command Reference',
14
+ '',
15
+ '<!-- Generated by `pnpm --filter @bbigbang/cli generate:catalog`. Do not edit by hand. -->',
16
+ '',
17
+ 'This reference is generated from the assembled Commander program. For workflow guidance, read `bigbang manual get cli-overview` and `bigbang manual get examples`.',
18
+ '',
19
+ '## Command Summary',
20
+ '',
21
+ ...renderSummaryLines(catalog).map((line) => `- \`${line}\``),
22
+ '',
23
+ '## Commands',
24
+ '',
25
+ ];
26
+ for (const command of catalog.commands) {
27
+ if (command.path.length === 0 || command.children.length > 0)
28
+ continue;
29
+ lines.push(`### \`bigbang ${command.path.join(' ')}\``);
30
+ lines.push('');
31
+ if (command.description) {
32
+ lines.push(command.description);
33
+ lines.push('');
34
+ }
35
+ if (command.arguments.length > 0) {
36
+ lines.push('Arguments:');
37
+ for (const argument of command.arguments) {
38
+ lines.push(`- \`${argument.required ? `<${argument.name}>` : `[${argument.name}]`}\`${argument.description ? ` — ${argument.description}` : ''}`);
39
+ }
40
+ lines.push('');
41
+ }
42
+ if (command.options.length > 0) {
43
+ lines.push('Options:');
44
+ for (const option of command.options) {
45
+ const defaultSuffix = option.defaultValue === undefined ? '' : ` Default: \`${String(option.defaultValue)}\`.`;
46
+ lines.push(`- \`${option.flags}\`${option.description ? ` — ${option.description}` : ''}${option.mandatory ? ' Required.' : ''}${defaultSuffix}`);
47
+ }
48
+ lines.push('');
49
+ }
50
+ }
51
+ return `${lines.join('\n').replace(/\n{3,}/g, '\n\n').trimEnd()}\n`;
52
+ }
53
+ export function renderBigbangCommandSummary(catalog) {
54
+ return renderSummaryLines(catalog);
55
+ }
56
+ export function renderBigbangSharedCatalogModule(catalog) {
57
+ return [
58
+ '/* Generated by `pnpm --filter @bbigbang/cli generate:catalog`. Do not edit by hand. */',
59
+ '',
60
+ `export const BIGBANG_COMMAND_CATALOG = ${JSON.stringify(catalog, null, 2)} as const;`,
61
+ '',
62
+ `export const BIGBANG_COMMAND_SUMMARY_LINES = ${JSON.stringify(renderBigbangCommandSummary(catalog), null, 2)} as const;`,
63
+ '',
64
+ ].join('\n');
65
+ }
66
+ function collectCommand(command, path, isRoot = false) {
67
+ const name = command.name();
68
+ const nextPath = isRoot ? [] : [...path, name];
69
+ const children = command.commands
70
+ .filter((child) => !isHiddenCommand(child))
71
+ .map((child) => collectCommand(child, nextPath));
72
+ return {
73
+ path: nextPath,
74
+ name,
75
+ description: command.description() || '',
76
+ arguments: command.registeredArguments.map((argument) => ({
77
+ name: argument.name(),
78
+ required: argument.required,
79
+ variadic: argument.variadic,
80
+ description: argument.description || '',
81
+ })),
82
+ options: command.options
83
+ .filter((option) => !option.hidden)
84
+ .map((option) => ({
85
+ flags: option.flags,
86
+ ...(option.short ? { short: option.short } : {}),
87
+ ...(option.long ? { long: option.long } : {}),
88
+ required: option.required,
89
+ optional: option.optional,
90
+ variadic: option.variadic,
91
+ mandatory: option.mandatory,
92
+ description: option.description || '',
93
+ ...(option.defaultValue === undefined ? {} : { defaultValue: normalizeDefaultValue(option.defaultValue) }),
94
+ })),
95
+ children,
96
+ };
97
+ }
98
+ function flattenCommands(root) {
99
+ const result = [];
100
+ const visit = (command) => {
101
+ result.push(command);
102
+ for (const child of command.children)
103
+ visit(child);
104
+ };
105
+ visit(root);
106
+ return result;
107
+ }
108
+ function isHiddenCommand(command) {
109
+ return Boolean(command._hidden);
110
+ }
111
+ function normalizeDefaultValue(value) {
112
+ if (value === null || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean')
113
+ return value;
114
+ if (Array.isArray(value) && value.every((item) => typeof item === 'string'))
115
+ return value;
116
+ return undefined;
117
+ }
118
+ function renderSummaryLines(catalog) {
119
+ const byGroup = new Map();
120
+ for (const command of catalog.commands) {
121
+ if (command.path.length === 0 || command.children.length > 0)
122
+ continue;
123
+ const [group, ...rest] = command.path;
124
+ if (!group || rest.length === 0)
125
+ continue;
126
+ const existing = byGroup.get(group) ?? [];
127
+ existing.push(rest.join(' '));
128
+ byGroup.set(group, existing);
129
+ }
130
+ const lines = [];
131
+ for (const [group, leaves] of byGroup) {
132
+ const simple = [];
133
+ const nested = new Map();
134
+ for (const leaf of leaves) {
135
+ const parts = leaf.split(' ');
136
+ if (parts.length === 1) {
137
+ simple.push(parts[0] ?? leaf);
138
+ continue;
139
+ }
140
+ const [head, ...tail] = parts;
141
+ const bucket = nested.get(head) ?? [];
142
+ bucket.push(tail.join(' '));
143
+ nested.set(head, bucket);
144
+ }
145
+ const pieces = [...simple.sort()];
146
+ for (const [head, subLeaves] of [...nested.entries()].sort(([a], [b]) => a.localeCompare(b))) {
147
+ pieces.push(`${head} ${subLeaves.sort().join('|')}`);
148
+ }
149
+ lines.push(`bigbang ${group} ${pieces.join('|')}`);
150
+ }
151
+ return lines;
152
+ }
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ import { type BuildBigbangProgramOptions } from '../cliSupport.js';
3
+ export declare function registerActionCommands(program: Command, options: BuildBigbangProgramOptions): void;
@@ -0,0 +1,43 @@
1
+ import { AGENT_COMMAND_ERROR_CODES, AgentCommandError, MUTATION_HINTS, appendCommonBody, createRuntime, parseJsonStdinOrThrow, parsePositiveInteger, requireString, responseError, summarizeActionPrepare, withHint, writeOutput, } from '../cliSupport.js';
2
+ export function registerActionCommands(program, options) {
3
+ const action = program.command('action').description('Prepare core-authoritative human-confirmed platform actions');
4
+ action.command('prepare')
5
+ .description('Prepare an action card from stdin JSON for human confirmation')
6
+ .option('--conversation-id <id>', 'Origin conversation id; defaults to managed runtime context')
7
+ .option('--expires-in-minutes <n>', 'Pending card lifetime in minutes; defaults to 1440')
8
+ .option('--reason <text>', 'Human-readable audit reason for the proposed action')
9
+ .action(async (opts) => {
10
+ const runtime = createRuntime(program, options);
11
+ const input = await parseJsonStdinOrThrow(runtime, 'action prepare JSON payload');
12
+ const actionType = typeof input.actionType === 'string'
13
+ ? input.actionType.trim()
14
+ : typeof input.action_type === 'string'
15
+ ? input.action_type.trim()
16
+ : '';
17
+ if (!actionType) {
18
+ throw new AgentCommandError(AGENT_COMMAND_ERROR_CODES.INVALID_ARG, 'action prepare JSON requires actionType.', { suggestedNextAction: 'Use {"actionType":"channel:create","payload":{...}}.' });
19
+ }
20
+ const conversationId = typeof opts.conversationId === 'string' && opts.conversationId.trim()
21
+ ? requireString(opts.conversationId, '--conversation-id')
22
+ : runtime.context.conversationId;
23
+ if (!conversationId) {
24
+ throw new AgentCommandError(AGENT_COMMAND_ERROR_CODES.MISSING_CONVERSATION_ID, 'action prepare requires BIGBANG_CONVERSATION_ID or --conversation-id.', { suggestedNextAction: 'Run from a managed Bigbang runtime or pass --conversation-id.' });
25
+ }
26
+ const expiresInMinutes = parsePositiveInteger('expires-in-minutes', opts.expiresInMinutes);
27
+ const expiresAt = expiresInMinutes ? Date.now() + expiresInMinutes * 60 * 1000 : undefined;
28
+ const reason = typeof opts.reason === 'string' && opts.reason.trim()
29
+ ? requireString(opts.reason, '--reason')
30
+ : undefined;
31
+ const body = appendCommonBody(runtime, {
32
+ actionType,
33
+ payload: input.payload ?? input.action,
34
+ ...(expiresAt ? { expiresAt } : {}),
35
+ ...(reason ? { reason } : {}),
36
+ });
37
+ body.conversationId = conversationId;
38
+ const response = await runtime.client.request('POST', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/actions/prepare`, body);
39
+ if (!response.ok)
40
+ throw responseError(response, 'action prepare failed');
41
+ writeOutput(runtime, withHint(summarizeActionPrepare(response.data), MUTATION_HINTS.actionPrepare), response.data);
42
+ });
43
+ }
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ import type { BuildBigbangProgramOptions } from '../cliSupport.js';
3
+ export declare function registerAuthManualCommands(program: Command, options: BuildBigbangProgramOptions): void;
@@ -0,0 +1,60 @@
1
+ import { AGENT_COMMAND_ERROR_CODES, AgentCommandError, MANUAL_TOPICS, createRuntime, isManualTopic, readManualTopic, readCommandCatalog, writeJson } from '../cliSupport.js';
2
+ export function registerAuthManualCommands(program, options) {
3
+ const auth = program.command('auth').description('Authentication and runtime context helpers');
4
+ auth.command('whoami')
5
+ .description('Print the agent command context with secrets redacted')
6
+ .action(() => {
7
+ const runtime = createRuntime(program, options);
8
+ writeJson(runtime, {
9
+ ok: true,
10
+ data: {
11
+ agentId: runtime.context.agentId,
12
+ serverUrl: runtime.context.serverUrl,
13
+ conversationId: runtime.context.conversationId ?? null,
14
+ runId: runtime.runId ?? null,
15
+ turnId: runtime.turnId ?? null,
16
+ traceId: runtime.traceId ?? null,
17
+ runContextPath: runtime.context.runContextPath ?? null,
18
+ tokenSource: runtime.context.tokenSource,
19
+ },
20
+ });
21
+ });
22
+ const manual = program.command('manual').description('Built-in command reference');
23
+ manual.command('get')
24
+ .description('Read a manual topic')
25
+ .argument('<topic>', 'Manual topic: index, cli-overview, examples, or commands')
26
+ .action(async (topic) => {
27
+ const runtime = createRuntime(program, options);
28
+ if (!isManualTopic(topic)) {
29
+ if (runtime.outputFormat === 'text') {
30
+ let indexContent;
31
+ try {
32
+ indexContent = readManualTopic(runtime, 'index');
33
+ }
34
+ catch {
35
+ indexContent = MANUAL_TOPICS.map((t) => `- ${t}`).join('\n');
36
+ }
37
+ runtime.io.stdout.write(`Unknown topic '${topic}'. Available topics:\n${indexContent}\n\nNext action: Run \`bigbang manual get index\` to list available topics.\n`);
38
+ return;
39
+ }
40
+ throw new AgentCommandError(AGENT_COMMAND_ERROR_CODES.NOT_FOUND, `Unknown manual topic: ${topic}`, { suggestedNextAction: 'Run bigbang manual get index to list available topics.' });
41
+ }
42
+ const content = readManualTopic(runtime, topic);
43
+ if (runtime.outputFormat === 'json') {
44
+ if (topic === 'index') {
45
+ writeJson(runtime, [...MANUAL_TOPICS]);
46
+ }
47
+ else {
48
+ writeJson(runtime, { topic, content });
49
+ }
50
+ return;
51
+ }
52
+ runtime.io.stdout.write(content);
53
+ });
54
+ manual.command('catalog')
55
+ .description('Print the generated machine-readable command catalog')
56
+ .action(() => {
57
+ const runtime = createRuntime(program, options);
58
+ writeJson(runtime, readCommandCatalog(runtime));
59
+ });
60
+ }
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ import type { BuildBigbangProgramOptions } from '../cliSupport.js';
3
+ export declare function registerChannelWorkspaceCommands(program: Command, options: BuildBigbangProgramOptions): void;
@@ -0,0 +1,105 @@
1
+ import { AGENT_COMMAND_ERROR_CODES, AgentCommandError, appendRunContextParams, createRuntime, requireString, responseError, summarizeChannelMembers, summarizeChannelMutation, summarizeServerDirectory, summarizeThreadUnfollow, summarizeWorkspaceFile, summarizeWorkspaceInspect, summarizeWorkspaceTree, writeOutput } from '../cliSupport.js';
2
+ export function registerChannelWorkspaceCommands(program, options) {
3
+ const channel = program.command('channel').description('Channel discovery and membership helpers');
4
+ channel.command('list')
5
+ .description('List channels, agents, and known humans')
6
+ .action(async () => {
7
+ const runtime = createRuntime(program, options);
8
+ const response = await runtime.client.request('GET', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/server`);
9
+ if (!response.ok)
10
+ throw responseError(response, 'server directory failed');
11
+ writeOutput(runtime, summarizeServerDirectory(response.data), response.data);
12
+ });
13
+ channel.command('members')
14
+ .description('List agent members in a joined channel')
15
+ .requiredOption('--channel <target>', 'Channel target such as #general or a raw channel id')
16
+ .action(async (opts) => {
17
+ const runtime = createRuntime(program, options);
18
+ const params = new URLSearchParams();
19
+ params.set('channel', requireString(opts.channel, '--channel'));
20
+ const response = await runtime.client.request('GET', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/channel-members?${params.toString()}`);
21
+ if (!response.ok)
22
+ throw responseError(response, 'channel members failed');
23
+ writeOutput(runtime, summarizeChannelMembers(response.data), response.data);
24
+ });
25
+ channel.command('join')
26
+ .description('Join the current agent to a channel')
27
+ .requiredOption('--channel <target>', 'Channel target such as #general or a raw channel id')
28
+ .action(async (opts) => {
29
+ const runtime = createRuntime(program, options);
30
+ const response = await runtime.client.request('POST', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/channels/join`, { channel: requireString(opts.channel, '--channel') });
31
+ if (!response.ok)
32
+ throw responseError(response, 'channel join failed');
33
+ writeOutput(runtime, summarizeChannelMutation(response.data, 'joined'), response.data);
34
+ });
35
+ channel.command('leave')
36
+ .description('Leave a channel and clear current agent channel-local participant state')
37
+ .requiredOption('--channel <target>', 'Channel target such as #general or a raw channel id')
38
+ .action(async (opts) => {
39
+ const runtime = createRuntime(program, options);
40
+ const response = await runtime.client.request('POST', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/channels/leave`, { channel: requireString(opts.channel, '--channel') });
41
+ if (!response.ok)
42
+ throw responseError(response, 'channel leave failed');
43
+ writeOutput(runtime, summarizeChannelMutation(response.data, 'left'), response.data);
44
+ });
45
+ const thread = program.command('thread').description('Thread participation helpers');
46
+ thread.command('unfollow')
47
+ .description('Unfollow a channel thread for the current agent')
48
+ .option('--target <target>', 'Thread target such as #general:abc12345')
49
+ .option('--channel <target>', 'Channel target used with --thread-root')
50
+ .option('--thread-root <id>', 'Thread root id or short id used with --channel')
51
+ .action(async (opts) => {
52
+ const runtime = createRuntime(program, options);
53
+ const target = typeof opts.target === 'string' ? opts.target.trim() : '';
54
+ const channelTarget = typeof opts.channel === 'string' ? opts.channel.trim() : '';
55
+ const threadRootId = typeof opts.threadRoot === 'string' ? opts.threadRoot.trim() : '';
56
+ if (!target && (!channelTarget || !threadRootId)) {
57
+ throw new AgentCommandError(AGENT_COMMAND_ERROR_CODES.INVALID_ARG, 'thread unfollow requires --target or both --channel and --thread-root.', { suggestedNextAction: 'Pass a full thread target such as --target #general:abc12345.' });
58
+ }
59
+ const response = await runtime.client.request('POST', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/threads/unfollow`, {
60
+ ...(target ? { target } : {}),
61
+ ...(channelTarget ? { channel: channelTarget } : {}),
62
+ ...(threadRootId ? { threadRootId } : {}),
63
+ });
64
+ if (!response.ok)
65
+ throw responseError(response, 'thread unfollow failed');
66
+ writeOutput(runtime, summarizeThreadUnfollow(response.data), response.data);
67
+ });
68
+ const workspace = program.command('workspace').description('Read-only current agent workspace helpers');
69
+ workspace.command('inspect')
70
+ .description('Inspect current agent workspace git/directory facts')
71
+ .action(async () => {
72
+ const runtime = createRuntime(program, options);
73
+ const response = await runtime.client.request('GET', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/workspace-inspect`);
74
+ if (!response.ok)
75
+ throw responseError(response, 'workspace inspect failed');
76
+ writeOutput(runtime, summarizeWorkspaceInspect(response.data), response.data);
77
+ });
78
+ workspace.command('tree')
79
+ .description('List current agent workspace directory entries')
80
+ .option('--path <path>', 'Relative directory path inside the current workspace')
81
+ .action(async (opts) => {
82
+ const runtime = createRuntime(program, options);
83
+ const params = appendRunContextParams(runtime, new URLSearchParams());
84
+ const workspacePath = typeof opts.path === 'string' ? opts.path.trim() : '';
85
+ if (workspacePath)
86
+ params.set('path', workspacePath);
87
+ const qs = params.toString();
88
+ const response = await runtime.client.request('GET', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/workspace-tree${qs ? `?${qs}` : ''}`);
89
+ if (!response.ok)
90
+ throw responseError(response, 'workspace tree failed');
91
+ writeOutput(runtime, summarizeWorkspaceTree(response.data), response.data);
92
+ });
93
+ workspace.command('file')
94
+ .description('Read a text file from the current agent workspace')
95
+ .requiredOption('--path <path>', 'Relative file path inside the current workspace')
96
+ .action(async (opts) => {
97
+ const runtime = createRuntime(program, options);
98
+ const params = appendRunContextParams(runtime, new URLSearchParams());
99
+ params.set('path', requireString(opts.path, '--path'));
100
+ const response = await runtime.client.request('GET', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/workspace-file?${params.toString()}`);
101
+ if (!response.ok)
102
+ throw responseError(response, 'workspace file failed');
103
+ writeOutput(runtime, summarizeWorkspaceFile(response.data), response.data);
104
+ });
105
+ }
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ import type { BuildBigbangProgramOptions } from '../cliSupport.js';
3
+ export declare function registerContextCommands(program: Command, options: BuildBigbangProgramOptions): void;