@karmaniverous/jeeves 0.4.4 → 0.4.6

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.
@@ -261,14 +261,14 @@ const PLATFORM_COMPONENTS = [
261
261
  * Core library version, inlined at build time.
262
262
  *
263
263
  * @remarks
264
- * The `0.4.3` placeholder is replaced by
264
+ * The `0.4.5` placeholder is replaced by
265
265
  * `@rollup/plugin-replace` during the build with the actual version
266
266
  * from `package.json`. This ensures the correct version survives
267
267
  * when consumers bundle core into their own dist (where runtime
268
268
  * `import.meta.url`-based resolution would find the wrong package.json).
269
269
  */
270
270
  /** The core library version from package.json (inlined at build time). */
271
- const CORE_VERSION = '0.4.3';
271
+ const CORE_VERSION = '0.4.5';
272
272
 
273
273
  /**
274
274
  * Dynamic discovery of installed Jeeves component CLIs.
@@ -119,14 +119,14 @@ const COMPONENT_VERSIONS_FILE = 'component-versions.json';
119
119
  * Core library version, inlined at build time.
120
120
  *
121
121
  * @remarks
122
- * The `0.4.3` placeholder is replaced by
122
+ * The `0.4.5` placeholder is replaced by
123
123
  * `@rollup/plugin-replace` during the build with the actual version
124
124
  * from `package.json`. This ensures the correct version survives
125
125
  * when consumers bundle core into their own dist (where runtime
126
126
  * `import.meta.url`-based resolution would find the wrong package.json).
127
127
  */
128
128
  /** The core library version from package.json (inlined at build time). */
129
- const CORE_VERSION = '0.4.3';
129
+ const CORE_VERSION = '0.4.5';
130
130
 
131
131
  /**
132
132
  * Shared file I/O helpers for managed section operations.
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { execSync, spawn } from 'node:child_process';
3
2
  import { existsSync, unlinkSync, mkdirSync, writeFileSync, readFileSync } from 'node:fs';
4
3
  import { join } from 'node:path';
5
4
  import * as commander from 'commander';
6
5
  import { z } from 'zod';
6
+ import { execSync } from 'node:child_process';
7
7
  import { homedir } from 'node:os';
8
8
 
9
9
  function getDefaultExportFromCjs (x) {
@@ -185,12 +185,17 @@ z.object({
185
185
  .optional(),
186
186
  /**
187
187
  * Returns command + args for launching the service process.
188
- * Consumed by `start` CLI command and `service install`.
188
+ * Consumed by `service install`.
189
189
  */
190
190
  startCommand: z.function({
191
191
  input: [z.string()],
192
192
  output: z.array(z.string()),
193
193
  }),
194
+ /** In-process service entry point for the CLI `start` command. */
195
+ run: z.function({
196
+ input: [z.string()],
197
+ output: z.promise(z.void()),
198
+ }),
194
199
  /** TOOLS.md section name (e.g., 'Watcher'). */
195
200
  sectionId: z.string().min(1, 'sectionId must be a non-empty string'),
196
201
  /** Refresh interval in seconds (must be a prime number). */
@@ -227,6 +232,14 @@ function getEffectiveServiceName(descriptor) {
227
232
  return descriptor.serviceName ?? `jeeves-${descriptor.name}`;
228
233
  }
229
234
 
235
+ /**
236
+ * Directory and file path conventions for the Jeeves platform.
237
+ */
238
+ /** Core config directory name within the config root. */
239
+ const CORE_CONFIG_DIR = 'jeeves-core';
240
+ /** Prefix for component config directories: `jeeves-{name}`. */
241
+ const COMPONENT_CONFIG_PREFIX = 'jeeves-';
242
+
230
243
  /**
231
244
  * Workspace and config root initialization.
232
245
  *
@@ -237,6 +250,19 @@ function getEffectiveServiceName(descriptor) {
237
250
  * - `{configRoot}/jeeves-core/` for core config
238
251
  * - `{configRoot}/jeeves-{name}/` for each component
239
252
  */
253
+ let state;
254
+ /**
255
+ * Initialize the core library with workspace and config root paths.
256
+ *
257
+ * @param options - Workspace and config root paths.
258
+ */
259
+ function init(options) {
260
+ state = {
261
+ workspacePath: options.workspacePath,
262
+ configRoot: options.configRoot,
263
+ coreConfigDir: join(options.configRoot, CORE_CONFIG_DIR),
264
+ };
265
+ }
240
266
  /**
241
267
  * Derive the component config directory from the component name.
242
268
  *
@@ -245,7 +271,9 @@ function getEffectiveServiceName(descriptor) {
245
271
  * @throws Error if `init()` has not been called.
246
272
  */
247
273
  function getComponentConfigDir(componentName) {
248
- throw new Error('jeeves-core: init() must be called first');
274
+ if (!state)
275
+ throw new Error('jeeves-core: init() must be called first');
276
+ return join(state.configRoot, `${COMPONENT_CONFIG_PREFIX}${componentName}`);
249
277
  }
250
278
 
251
279
  /**
@@ -668,6 +696,19 @@ function createServiceManager(descriptor) {
668
696
  }
669
697
  }
670
698
 
699
+ /**
700
+ * Shared CLI defaults and option registration for Jeeves CLI commands.
701
+ *
702
+ * @remarks
703
+ * All three CLI commands (install, uninstall, status) share the same
704
+ * `--workspace` and `--config-root` options with the same defaults.
705
+ * This module centralizes them to eliminate duplication.
706
+ */
707
+ /** Default workspace path (current directory). */
708
+ const DEFAULT_WORKSPACE = '.';
709
+ /** Default config root path. */
710
+ const DEFAULT_CONFIG_ROOT = './config';
711
+
671
712
  /**
672
713
  * Factory for the standard Jeeves service CLI.
673
714
  *
@@ -710,14 +751,11 @@ function createServiceCli(descriptor) {
710
751
  .command('start')
711
752
  .description('Launch the service process (foreground)')
712
753
  .requiredOption('-c, --config <path>', 'Config file path')
713
- .action((opts) => {
714
- const cmdArgs = descriptor.startCommand(opts.config);
715
- const proc = spawn(cmdArgs[0], cmdArgs.slice(1), {
716
- stdio: 'inherit',
717
- });
718
- proc.on('exit', (code) => {
719
- process.exit(code ?? 1);
720
- });
754
+ .option('-w, --workspace <path>', 'Workspace root path', DEFAULT_WORKSPACE)
755
+ .option('--config-root <path>', 'Platform config root path', DEFAULT_CONFIG_ROOT)
756
+ .action(async (opts) => {
757
+ init({ workspacePath: opts.workspace, configRoot: opts.configRoot });
758
+ await descriptor.run(opts.config);
721
759
  });
722
760
  // --- status ---
723
761
  program
package/dist/index.d.ts CHANGED
@@ -118,6 +118,7 @@ declare const jeevesComponentDescriptorSchema: z.ZodObject<{
118
118
  onConfigApply: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>], null>, z.ZodPromise<z.ZodVoid>>>;
119
119
  customMerge: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>], null>, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
120
120
  startCommand: z.ZodFunction<z.ZodTuple<readonly [z.ZodString], null>, z.ZodArray<z.ZodString>>;
121
+ run: z.ZodFunction<z.ZodTuple<readonly [z.ZodString], null>, z.ZodPromise<z.ZodVoid>>;
121
122
  sectionId: z.ZodString;
122
123
  refreshIntervalSeconds: z.ZodNumber;
123
124
  generateToolsContent: z.ZodFunction<z.ZodTuple<readonly [], null>, z.ZodString>;
package/dist/index.js CHANGED
@@ -5,8 +5,8 @@ import { JSONPath } from 'jsonpath-plus';
5
5
  import * as commander from 'commander';
6
6
  import { valid, gte, gt } from 'semver';
7
7
  import { homedir } from 'node:os';
8
- import { execSync, spawn } from 'node:child_process';
9
8
  import { z } from 'zod';
9
+ import { execSync } from 'node:child_process';
10
10
  import { fileURLToPath } from 'node:url';
11
11
  import { packageDirectorySync } from 'package-directory';
12
12
 
@@ -176,14 +176,14 @@ const PLATFORM_COMPONENTS = [
176
176
  * Core library version, inlined at build time.
177
177
  *
178
178
  * @remarks
179
- * The `0.4.3` placeholder is replaced by
179
+ * The `0.4.5` placeholder is replaced by
180
180
  * `@rollup/plugin-replace` during the build with the actual version
181
181
  * from `package.json`. This ensures the correct version survives
182
182
  * when consumers bundle core into their own dist (where runtime
183
183
  * `import.meta.url`-based resolution would find the wrong package.json).
184
184
  */
185
185
  /** The core library version from package.json (inlined at build time). */
186
- const CORE_VERSION = '0.4.3';
186
+ const CORE_VERSION = '0.4.5';
187
187
 
188
188
  /**
189
189
  * Workspace and config root initialization.
@@ -1537,12 +1537,17 @@ const jeevesComponentDescriptorSchema = z.object({
1537
1537
  .optional(),
1538
1538
  /**
1539
1539
  * Returns command + args for launching the service process.
1540
- * Consumed by `start` CLI command and `service install`.
1540
+ * Consumed by `service install`.
1541
1541
  */
1542
1542
  startCommand: z.function({
1543
1543
  input: [z.string()],
1544
1544
  output: z.array(z.string()),
1545
1545
  }),
1546
+ /** In-process service entry point for the CLI `start` command. */
1547
+ run: z.function({
1548
+ input: [z.string()],
1549
+ output: z.promise(z.void()),
1550
+ }),
1546
1551
  /** TOOLS.md section name (e.g., 'Watcher'). */
1547
1552
  sectionId: z.string().min(1, 'sectionId must be a non-empty string'),
1548
1553
  /** Refresh interval in seconds (must be a prime number). */
@@ -2011,6 +2016,19 @@ function createServiceManager(descriptor) {
2011
2016
  }
2012
2017
  }
2013
2018
 
2019
+ /**
2020
+ * Shared CLI defaults and option registration for Jeeves CLI commands.
2021
+ *
2022
+ * @remarks
2023
+ * All three CLI commands (install, uninstall, status) share the same
2024
+ * `--workspace` and `--config-root` options with the same defaults.
2025
+ * This module centralizes them to eliminate duplication.
2026
+ */
2027
+ /** Default workspace path (current directory). */
2028
+ const DEFAULT_WORKSPACE = '.';
2029
+ /** Default config root path. */
2030
+ const DEFAULT_CONFIG_ROOT = './config';
2031
+
2014
2032
  /**
2015
2033
  * Factory for the standard Jeeves service CLI.
2016
2034
  *
@@ -2053,14 +2071,11 @@ function createServiceCli(descriptor) {
2053
2071
  .command('start')
2054
2072
  .description('Launch the service process (foreground)')
2055
2073
  .requiredOption('-c, --config <path>', 'Config file path')
2056
- .action((opts) => {
2057
- const cmdArgs = descriptor.startCommand(opts.config);
2058
- const proc = spawn(cmdArgs[0], cmdArgs.slice(1), {
2059
- stdio: 'inherit',
2060
- });
2061
- proc.on('exit', (code) => {
2062
- process.exit(code ?? 1);
2063
- });
2074
+ .option('-w, --workspace <path>', 'Workspace root path', DEFAULT_WORKSPACE)
2075
+ .option('--config-root <path>', 'Platform config root path', DEFAULT_CONFIG_ROOT)
2076
+ .action(async (opts) => {
2077
+ init({ workspacePath: opts.workspace, configRoot: opts.configRoot });
2078
+ await descriptor.run(opts.config);
2064
2079
  });
2065
2080
  // --- status ---
2066
2081
  program
package/package.json CHANGED
@@ -50,7 +50,7 @@
50
50
  "prettier": "^3.8.1",
51
51
  "release-it": "^19.2.4",
52
52
  "rimraf": "^6.1.3",
53
- "rollup": "^4.60.0",
53
+ "rollup": "^4.60.1",
54
54
  "rollup-plugin-dts": "^6.4.1",
55
55
  "tslib": "^2.8.1",
56
56
  "typedoc": "^0.28.18",
@@ -139,5 +139,5 @@
139
139
  },
140
140
  "type": "module",
141
141
  "types": "dist/index.d.ts",
142
- "version": "0.4.4"
142
+ "version": "0.4.6"
143
143
  }