@proletariat/cli 0.3.40 → 0.3.42

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.
@@ -6,7 +6,7 @@ import { promptForHQName, promptForHQLocation, initializeHQ, showNextSteps, vali
6
6
  import { promptForAgentsWithTheme } from '../lib/agents/index.js';
7
7
  import { promptForRepositories } from '../lib/repos/index.js';
8
8
  import { promptForPMOSetup, machineOutputFlags } from '../lib/pmo/index.js';
9
- import { shouldOutputJson } from '../lib/prompt-json.js';
9
+ import { shouldOutputJson, outputPromptAsJson, buildPromptConfig, createMetadata, } from '../lib/prompt-json.js';
10
10
  export default class Init extends Command {
11
11
  static description = 'Initialize an HQ (headquarters) for managing repositories, agents, and projects';
12
12
  static examples = [
@@ -19,7 +19,7 @@ export default class Init extends Command {
19
19
  static flags = {
20
20
  ...machineOutputFlags,
21
21
  name: Flags.string({
22
- description: 'HQ name (required in --json mode)',
22
+ description: 'HQ name',
23
23
  char: 'n',
24
24
  }),
25
25
  path: Flags.string({
@@ -85,13 +85,9 @@ export default class Init extends Command {
85
85
  * Agent mode: use flags, output JSON
86
86
  */
87
87
  async runAgentMode(flags) {
88
- // Validate required fields
88
+ // If --name not provided, output a prompt so agents can supply it
89
89
  if (!flags.name) {
90
- this.outputJson({
91
- success: false,
92
- error: 'Missing required flag: --name',
93
- });
94
- this.exit(1);
90
+ outputPromptAsJson(buildPromptConfig('input', 'name', 'Enter a name for your headquarters:', undefined, undefined), createMetadata('init', flags));
95
91
  }
96
92
  const hqName = flags.name;
97
93
  const hqPath = flags.path || path.resolve(`./${hqName}-hq`);
@@ -9,8 +9,9 @@ import { findHQRoot } from '../lib/workspace.js';
9
9
  * - AND they're not currently inside a valid HQ directory
10
10
  */
11
11
  const hook = async function ({ id, argv, config }) {
12
- // Skip for init command to avoid infinite loop
13
- if (id === 'init') {
12
+ // Skip for commands that work without an HQ
13
+ const hqOptionalCommands = ['init', 'commit', 'claude', 'pmo:init'];
14
+ if (id && hqOptionalCommands.some(cmd => id === cmd || id.startsWith(cmd + ':'))) {
14
15
  return;
15
16
  }
16
17
  // Skip when running under oclif tooling (manifest, readme generation)
@@ -18,11 +19,13 @@ const hook = async function ({ id, argv, config }) {
18
19
  if (process.env.OCLIF_COMPILATION || process.argv[1]?.includes('oclif')) {
19
20
  return;
20
21
  }
21
- // Skip when --help flag is present - help should always be available
22
+ // Skip when --help or --version flags are present - these should always be available
22
23
  // Check both process.argv (production CLI) and the oclif-provided argv
23
24
  // (programmatic invocation via @oclif/test runCommand)
24
25
  if (process.argv.includes('--help') || process.argv.includes('-h') ||
25
- argv?.includes('--help') || argv?.includes('-h')) {
26
+ argv?.includes('--help') || argv?.includes('-h') ||
27
+ process.argv.includes('--version') || process.argv.includes('-v') ||
28
+ argv?.includes('--version') || argv?.includes('-v')) {
26
29
  return;
27
30
  }
28
31
  // Skip for help-related commands/flags
@@ -30,10 +33,10 @@ const hook = async function ({ id, argv, config }) {
30
33
  if (!id || id === 'help') {
31
34
  // Check if this is first-time user running bare `prlt`
32
35
  if (!id && isFirstTimeUser()) {
33
- // Run init command
36
+ // Run init command - in TTY it prompts interactively,
37
+ // in non-TTY it outputs a JSON prompt for the HQ name
34
38
  const { run } = await import('@oclif/core');
35
39
  await run(['init'], config);
36
- // Exit after init completes to prevent showing help
37
40
  process.exit(0);
38
41
  }
39
42
  return;
@@ -41,11 +44,11 @@ const hook = async function ({ id, argv, config }) {
41
44
  // For all other commands, check if first-time user
42
45
  if (isFirstTimeUser()) {
43
46
  const chalk = await import('chalk');
44
- console.log(chalk.default.yellow('\n⚠️ No workspace found. Let\'s set one up first.\n'));
45
- // Run init command
47
+ console.log(chalk.default.yellow('\n⚠️ No headquarters found. Let\'s set one up first.\n'));
48
+ // Run init command - in TTY it prompts interactively,
49
+ // in non-TTY it outputs a JSON prompt for the HQ name
46
50
  const { run } = await import('@oclif/core');
47
51
  await run(['init'], config);
48
- // Exit after init - user should re-run their original command
49
52
  console.log(chalk.default.blue(`\n✅ Setup complete! You can now run: prlt ${id}\n`));
50
53
  process.exit(0);
51
54
  }