@karmaniverous/jeeves-meta 0.4.1 → 0.4.2
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.
- package/dist/cli/jeeves-meta/index.js +53 -15
- package/dist/index.d.ts +16 -2
- package/dist/index.js +44 -6
- package/package.json +1 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { readFileSync, readdirSync, unlinkSync, mkdirSync, writeFileSync, existsSync, statSync, copyFileSync, watchFile } from 'node:fs';
|
|
4
|
-
import { dirname, join, relative } from 'node:path';
|
|
4
|
+
import { dirname, join, resolve, relative } from 'node:path';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
6
7
|
import { createHash, randomUUID } from 'node:crypto';
|
|
8
|
+
import { tmpdir } from 'node:os';
|
|
7
9
|
import pino from 'pino';
|
|
8
10
|
import { Cron } from 'croner';
|
|
9
11
|
import Fastify from 'fastify';
|
|
@@ -166,6 +168,42 @@ var configLoader = /*#__PURE__*/Object.freeze({
|
|
|
166
168
|
resolveConfigPath: resolveConfigPath
|
|
167
169
|
});
|
|
168
170
|
|
|
171
|
+
/**
|
|
172
|
+
* Shared constants for the jeeves-meta service package.
|
|
173
|
+
*
|
|
174
|
+
* @module constants
|
|
175
|
+
*/
|
|
176
|
+
/** Default HTTP port for the jeeves-meta service. */
|
|
177
|
+
const DEFAULT_PORT = 1938;
|
|
178
|
+
/** Default port as a string (for Commander CLI defaults). */
|
|
179
|
+
const DEFAULT_PORT_STR = String(DEFAULT_PORT);
|
|
180
|
+
/** Service name identifier. */
|
|
181
|
+
const SERVICE_NAME = 'jeeves-meta';
|
|
182
|
+
/** Service version, read from package.json at startup. */
|
|
183
|
+
const SERVICE_VERSION = (() => {
|
|
184
|
+
try {
|
|
185
|
+
const dir = dirname(fileURLToPath(import.meta.url));
|
|
186
|
+
// Walk up to find package.json (works from src/ or dist/)
|
|
187
|
+
for (const candidate of [
|
|
188
|
+
resolve(dir, '..', 'package.json'),
|
|
189
|
+
resolve(dir, '..', '..', 'package.json'),
|
|
190
|
+
]) {
|
|
191
|
+
try {
|
|
192
|
+
const pkg = JSON.parse(readFileSync(candidate, 'utf8'));
|
|
193
|
+
if (pkg.version)
|
|
194
|
+
return pkg.version;
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
// try next candidate
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return 'unknown';
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
return 'unknown';
|
|
204
|
+
}
|
|
205
|
+
})();
|
|
206
|
+
|
|
169
207
|
/**
|
|
170
208
|
* List archive snapshot files in chronological order.
|
|
171
209
|
*
|
|
@@ -962,7 +1000,7 @@ class GatewayExecutor {
|
|
|
962
1000
|
this.gatewayUrl = (options.gatewayUrl ?? 'http://127.0.0.1:18789').replace(/\/+$/, '');
|
|
963
1001
|
this.apiKey = options.apiKey;
|
|
964
1002
|
this.pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
965
|
-
this.workspaceDir = options.workspaceDir ?? '
|
|
1003
|
+
this.workspaceDir = options.workspaceDir ?? join(tmpdir(), 'jeeves-meta');
|
|
966
1004
|
}
|
|
967
1005
|
/** Invoke a gateway tool via the /tools/invoke HTTP endpoint. */
|
|
968
1006
|
async invoke(tool, args) {
|
|
@@ -2930,8 +2968,8 @@ function registerStatusRoute(app, deps) {
|
|
|
2930
2968
|
// Metas summary is expensive (paginated watcher scan + disk reads).
|
|
2931
2969
|
// Use GET /metas for full inventory; status is a lightweight health check.
|
|
2932
2970
|
return {
|
|
2933
|
-
service:
|
|
2934
|
-
version:
|
|
2971
|
+
service: SERVICE_NAME,
|
|
2972
|
+
version: SERVICE_VERSION,
|
|
2935
2973
|
uptime: process.uptime(),
|
|
2936
2974
|
status,
|
|
2937
2975
|
currentTarget: queue.current?.path ?? null,
|
|
@@ -3153,7 +3191,7 @@ function buildMetaRules(config) {
|
|
|
3153
3191
|
},
|
|
3154
3192
|
],
|
|
3155
3193
|
render: {
|
|
3156
|
-
frontmatter: ['meta_id', 'generated_at', '*', '!has_error'],
|
|
3194
|
+
frontmatter: ['meta_id', 'generated_at', '*', '!_*', '!has_error'],
|
|
3157
3195
|
body: [{ path: 'json._content', heading: 1, label: 'Synthesis' }],
|
|
3158
3196
|
},
|
|
3159
3197
|
renderAs: 'md',
|
|
@@ -3670,7 +3708,7 @@ async function startService(config, configPath) {
|
|
|
3670
3708
|
* @module cli
|
|
3671
3709
|
*/
|
|
3672
3710
|
const program = new Command();
|
|
3673
|
-
program.name(
|
|
3711
|
+
program.name(SERVICE_NAME).description('Jeeves Meta synthesis service');
|
|
3674
3712
|
// ─── start ──────────────────────────────────────────────────────────
|
|
3675
3713
|
program
|
|
3676
3714
|
.command('start')
|
|
@@ -3709,7 +3747,7 @@ async function apiPost(port, path, body) {
|
|
|
3709
3747
|
program
|
|
3710
3748
|
.command('status')
|
|
3711
3749
|
.description('Show service status')
|
|
3712
|
-
.option('-p, --port <port>', 'Service port',
|
|
3750
|
+
.option('-p, --port <port>', 'Service port', DEFAULT_PORT_STR)
|
|
3713
3751
|
.action(async (opts) => {
|
|
3714
3752
|
try {
|
|
3715
3753
|
const data = await apiGet(parseInt(opts.port, 10), '/status');
|
|
@@ -3724,7 +3762,7 @@ program
|
|
|
3724
3762
|
program
|
|
3725
3763
|
.command('list')
|
|
3726
3764
|
.description('List all discovered meta entities')
|
|
3727
|
-
.option('-p, --port <port>', 'Service port',
|
|
3765
|
+
.option('-p, --port <port>', 'Service port', DEFAULT_PORT_STR)
|
|
3728
3766
|
.action(async (opts) => {
|
|
3729
3767
|
try {
|
|
3730
3768
|
const data = await apiGet(parseInt(opts.port, 10), '/metas');
|
|
@@ -3739,7 +3777,7 @@ program
|
|
|
3739
3777
|
program
|
|
3740
3778
|
.command('detail <path>')
|
|
3741
3779
|
.description('Show full detail for a single meta entity')
|
|
3742
|
-
.option('-p, --port <port>', 'Service port',
|
|
3780
|
+
.option('-p, --port <port>', 'Service port', DEFAULT_PORT_STR)
|
|
3743
3781
|
.action(async (metaPath, opts) => {
|
|
3744
3782
|
try {
|
|
3745
3783
|
const encoded = encodeURIComponent(metaPath);
|
|
@@ -3755,7 +3793,7 @@ program
|
|
|
3755
3793
|
program
|
|
3756
3794
|
.command('preview')
|
|
3757
3795
|
.description('Dry-run: preview inputs for next synthesis cycle')
|
|
3758
|
-
.option('-p, --port <port>', 'Service port',
|
|
3796
|
+
.option('-p, --port <port>', 'Service port', DEFAULT_PORT_STR)
|
|
3759
3797
|
.option('--path <path>', 'Specific meta path to preview')
|
|
3760
3798
|
.action(async (opts) => {
|
|
3761
3799
|
try {
|
|
@@ -3772,7 +3810,7 @@ program
|
|
|
3772
3810
|
program
|
|
3773
3811
|
.command('synthesize')
|
|
3774
3812
|
.description('Trigger synthesis (enqueues work)')
|
|
3775
|
-
.option('-p, --port <port>', 'Service port',
|
|
3813
|
+
.option('-p, --port <port>', 'Service port', DEFAULT_PORT_STR)
|
|
3776
3814
|
.option('--path <path>', 'Specific meta path to synthesize')
|
|
3777
3815
|
.action(async (opts) => {
|
|
3778
3816
|
try {
|
|
@@ -3789,7 +3827,7 @@ program
|
|
|
3789
3827
|
program
|
|
3790
3828
|
.command('seed <path>')
|
|
3791
3829
|
.description('Create .meta/ directory + meta.json for a path')
|
|
3792
|
-
.option('-p, --port <port>', 'Service port',
|
|
3830
|
+
.option('-p, --port <port>', 'Service port', DEFAULT_PORT_STR)
|
|
3793
3831
|
.action(async (metaPath, opts) => {
|
|
3794
3832
|
try {
|
|
3795
3833
|
const data = await apiPost(parseInt(opts.port, 10), '/seed', {
|
|
@@ -3806,7 +3844,7 @@ program
|
|
|
3806
3844
|
program
|
|
3807
3845
|
.command('unlock <path>')
|
|
3808
3846
|
.description('Remove .lock file from a meta entity')
|
|
3809
|
-
.option('-p, --port <port>', 'Service port',
|
|
3847
|
+
.option('-p, --port <port>', 'Service port', DEFAULT_PORT_STR)
|
|
3810
3848
|
.action(async (metaPath, opts) => {
|
|
3811
3849
|
try {
|
|
3812
3850
|
const data = await apiPost(parseInt(opts.port, 10), '/unlock', {
|
|
@@ -3823,7 +3861,7 @@ program
|
|
|
3823
3861
|
program
|
|
3824
3862
|
.command('validate')
|
|
3825
3863
|
.description('Validate current or candidate config')
|
|
3826
|
-
.option('-p, --port <port>', 'Service port',
|
|
3864
|
+
.option('-p, --port <port>', 'Service port', DEFAULT_PORT_STR)
|
|
3827
3865
|
.option('-c, --config <path>', 'Validate a candidate config file locally')
|
|
3828
3866
|
.action(async (opts) => {
|
|
3829
3867
|
try {
|
|
@@ -3959,7 +3997,7 @@ service.addCommand(new Command('stop')
|
|
|
3959
3997
|
// status command (service subcommand — queries HTTP API)
|
|
3960
3998
|
service.addCommand(new Command('status')
|
|
3961
3999
|
.description('Show service status via HTTP API')
|
|
3962
|
-
.option('-p, --port <port>', 'Service port',
|
|
4000
|
+
.option('-p, --port <port>', 'Service port', DEFAULT_PORT_STR)
|
|
3963
4001
|
.action(async (opts) => {
|
|
3964
4002
|
try {
|
|
3965
4003
|
const data = await apiGet(parseInt(opts.port, 10), '/status');
|
package/dist/index.d.ts
CHANGED
|
@@ -185,6 +185,20 @@ declare function readLatestArchive(metaPath: string): MetaJson | null;
|
|
|
185
185
|
*/
|
|
186
186
|
declare function createSnapshot(metaPath: string, meta: MetaJson): string;
|
|
187
187
|
|
|
188
|
+
/**
|
|
189
|
+
* Shared constants for the jeeves-meta service package.
|
|
190
|
+
*
|
|
191
|
+
* @module constants
|
|
192
|
+
*/
|
|
193
|
+
/** Default HTTP port for the jeeves-meta service. */
|
|
194
|
+
declare const DEFAULT_PORT = 1938;
|
|
195
|
+
/** Default port as a string (for Commander CLI defaults). */
|
|
196
|
+
declare const DEFAULT_PORT_STR: string;
|
|
197
|
+
/** Service name identifier. */
|
|
198
|
+
declare const SERVICE_NAME = "jeeves-meta";
|
|
199
|
+
/** Service version, read from package.json at startup. */
|
|
200
|
+
declare const SERVICE_VERSION: string;
|
|
201
|
+
|
|
188
202
|
/**
|
|
189
203
|
* Load and resolve jeeves-meta service config.
|
|
190
204
|
*
|
|
@@ -778,7 +792,7 @@ interface GatewayExecutorOptions {
|
|
|
778
792
|
apiKey?: string;
|
|
779
793
|
/** Polling interval in ms. Default: 5000. */
|
|
780
794
|
pollIntervalMs?: number;
|
|
781
|
-
/** Workspace directory for output staging. Default:
|
|
795
|
+
/** Workspace directory for output staging. Default: OS temp dir + /jeeves-meta. */
|
|
782
796
|
workspaceDir?: string;
|
|
783
797
|
}
|
|
784
798
|
/**
|
|
@@ -1445,5 +1459,5 @@ declare function registerShutdownHandlers(deps: ShutdownDeps): void;
|
|
|
1445
1459
|
*/
|
|
1446
1460
|
declare function startService(config: ServiceConfig, configPath?: string): Promise<void>;
|
|
1447
1461
|
|
|
1448
|
-
export { GatewayExecutor, HttpWatcherClient, ProgressReporter, RuleRegistrar, Scheduler, SynthesisQueue, acquireLock, actualStaleness, buildArchitectTask, buildBuilderTask, buildContextPackage, buildCriticTask, buildMetaFilter, buildOwnershipTree, cleanupStaleLocks, computeEffectiveStaleness, computeEma, computeStructureHash, createLogger, createServer, createSnapshot, discoverMetas, filterInScope, findNode, formatProgressEvent, getScopePrefix, hasSteerChanged, isArchitectTriggered, isLocked, isStale, listArchiveFiles, listMetas, loadServiceConfig, mergeAndWrite, metaConfigSchema, metaErrorSchema, metaJsonSchema, normalizePath, orchestrate, paginatedScan, parseArchitectOutput, parseBuilderOutput, parseCriticOutput, pruneArchive, readLatestArchive, readLockState, registerRoutes, registerShutdownHandlers, releaseLock, resolveConfigPath, resolveMetaDir, selectCandidate, serviceConfigSchema, sleep, startService, toMetaError, walkFiles };
|
|
1462
|
+
export { DEFAULT_PORT, DEFAULT_PORT_STR, GatewayExecutor, HttpWatcherClient, ProgressReporter, RuleRegistrar, SERVICE_NAME, SERVICE_VERSION, Scheduler, SynthesisQueue, acquireLock, actualStaleness, buildArchitectTask, buildBuilderTask, buildContextPackage, buildCriticTask, buildMetaFilter, buildOwnershipTree, cleanupStaleLocks, computeEffectiveStaleness, computeEma, computeStructureHash, createLogger, createServer, createSnapshot, discoverMetas, filterInScope, findNode, formatProgressEvent, getScopePrefix, hasSteerChanged, isArchitectTriggered, isLocked, isStale, listArchiveFiles, listMetas, loadServiceConfig, mergeAndWrite, metaConfigSchema, metaErrorSchema, metaJsonSchema, normalizePath, orchestrate, paginatedScan, parseArchitectOutput, parseBuilderOutput, parseCriticOutput, pruneArchive, readLatestArchive, readLockState, registerRoutes, registerShutdownHandlers, releaseLock, resolveConfigPath, resolveMetaDir, selectCandidate, serviceConfigSchema, sleep, startService, toMetaError, walkFiles };
|
|
1449
1463
|
export type { BuilderOutput, EnqueueResult, GatewayExecutorOptions, HttpWatcherClientOptions, InferenceRuleSpec, LockState, LoggerConfig, MergeOptions, MetaConfig, MetaContext, MetaEntry, MetaError, MetaExecutor, MetaJson, MetaListResult, MetaListSummary, MetaNode, MetaSpawnOptions, MetaSpawnResult, MinimalLogger, OrchestrateResult, OwnershipTree, ProgressCallback, ProgressEvent, ProgressPhase, ProgressReporterConfig, QueueItem, QueueState, RouteDeps, ScanFile, ScanParams, ScanResponse, ServerOptions, ServiceConfig, ServiceStats, StalenessCandidate, WatcherClient };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { readdirSync, unlinkSync, readFileSync, mkdirSync, writeFileSync, existsSync, statSync, copyFileSync, watchFile } from 'node:fs';
|
|
2
|
-
import { join, dirname, relative } from 'node:path';
|
|
2
|
+
import { join, dirname, resolve, relative } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
3
4
|
import { z } from 'zod';
|
|
4
5
|
import { createHash, randomUUID } from 'node:crypto';
|
|
6
|
+
import { tmpdir } from 'node:os';
|
|
5
7
|
import pino from 'pino';
|
|
6
8
|
import { Cron } from 'croner';
|
|
7
9
|
import Fastify from 'fastify';
|
|
@@ -102,6 +104,42 @@ function createSnapshot(metaPath, meta) {
|
|
|
102
104
|
return archiveFile;
|
|
103
105
|
}
|
|
104
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Shared constants for the jeeves-meta service package.
|
|
109
|
+
*
|
|
110
|
+
* @module constants
|
|
111
|
+
*/
|
|
112
|
+
/** Default HTTP port for the jeeves-meta service. */
|
|
113
|
+
const DEFAULT_PORT = 1938;
|
|
114
|
+
/** Default port as a string (for Commander CLI defaults). */
|
|
115
|
+
const DEFAULT_PORT_STR = String(DEFAULT_PORT);
|
|
116
|
+
/** Service name identifier. */
|
|
117
|
+
const SERVICE_NAME = 'jeeves-meta';
|
|
118
|
+
/** Service version, read from package.json at startup. */
|
|
119
|
+
const SERVICE_VERSION = (() => {
|
|
120
|
+
try {
|
|
121
|
+
const dir = dirname(fileURLToPath(import.meta.url));
|
|
122
|
+
// Walk up to find package.json (works from src/ or dist/)
|
|
123
|
+
for (const candidate of [
|
|
124
|
+
resolve(dir, '..', 'package.json'),
|
|
125
|
+
resolve(dir, '..', '..', 'package.json'),
|
|
126
|
+
]) {
|
|
127
|
+
try {
|
|
128
|
+
const pkg = JSON.parse(readFileSync(candidate, 'utf8'));
|
|
129
|
+
if (pkg.version)
|
|
130
|
+
return pkg.version;
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
// try next candidate
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return 'unknown';
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return 'unknown';
|
|
140
|
+
}
|
|
141
|
+
})();
|
|
142
|
+
|
|
105
143
|
/**
|
|
106
144
|
* Zod schema for jeeves-meta service configuration.
|
|
107
145
|
*
|
|
@@ -954,7 +992,7 @@ class GatewayExecutor {
|
|
|
954
992
|
this.gatewayUrl = (options.gatewayUrl ?? 'http://127.0.0.1:18789').replace(/\/+$/, '');
|
|
955
993
|
this.apiKey = options.apiKey;
|
|
956
994
|
this.pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
957
|
-
this.workspaceDir = options.workspaceDir ?? '
|
|
995
|
+
this.workspaceDir = options.workspaceDir ?? join(tmpdir(), 'jeeves-meta');
|
|
958
996
|
}
|
|
959
997
|
/** Invoke a gateway tool via the /tools/invoke HTTP endpoint. */
|
|
960
998
|
async invoke(tool, args) {
|
|
@@ -2926,8 +2964,8 @@ function registerStatusRoute(app, deps) {
|
|
|
2926
2964
|
// Metas summary is expensive (paginated watcher scan + disk reads).
|
|
2927
2965
|
// Use GET /metas for full inventory; status is a lightweight health check.
|
|
2928
2966
|
return {
|
|
2929
|
-
service:
|
|
2930
|
-
version:
|
|
2967
|
+
service: SERVICE_NAME,
|
|
2968
|
+
version: SERVICE_VERSION,
|
|
2931
2969
|
uptime: process.uptime(),
|
|
2932
2970
|
status,
|
|
2933
2971
|
currentTarget: queue.current?.path ?? null,
|
|
@@ -3149,7 +3187,7 @@ function buildMetaRules(config) {
|
|
|
3149
3187
|
},
|
|
3150
3188
|
],
|
|
3151
3189
|
render: {
|
|
3152
|
-
frontmatter: ['meta_id', 'generated_at', '*', '!has_error'],
|
|
3190
|
+
frontmatter: ['meta_id', 'generated_at', '*', '!_*', '!has_error'],
|
|
3153
3191
|
body: [{ path: 'json._content', heading: 1, label: 'Synthesis' }],
|
|
3154
3192
|
},
|
|
3155
3193
|
renderAs: 'md',
|
|
@@ -3660,4 +3698,4 @@ async function startService(config, configPath) {
|
|
|
3660
3698
|
logger.info('Service fully initialized');
|
|
3661
3699
|
}
|
|
3662
3700
|
|
|
3663
|
-
export { GatewayExecutor, HttpWatcherClient, ProgressReporter, RuleRegistrar, Scheduler, SynthesisQueue, acquireLock, actualStaleness, buildArchitectTask, buildBuilderTask, buildContextPackage, buildCriticTask, buildMetaFilter, buildOwnershipTree, cleanupStaleLocks, computeEffectiveStaleness, computeEma, computeStructureHash, createLogger, createServer, createSnapshot, discoverMetas, filterInScope, findNode, formatProgressEvent, getScopePrefix, hasSteerChanged, isArchitectTriggered, isLocked, isStale, listArchiveFiles, listMetas, loadServiceConfig, mergeAndWrite, metaConfigSchema, metaErrorSchema, metaJsonSchema, normalizePath, orchestrate, paginatedScan, parseArchitectOutput, parseBuilderOutput, parseCriticOutput, pruneArchive, readLatestArchive, readLockState, registerRoutes, registerShutdownHandlers, releaseLock, resolveConfigPath, resolveMetaDir, selectCandidate, serviceConfigSchema, sleep, startService, toMetaError, walkFiles };
|
|
3701
|
+
export { DEFAULT_PORT, DEFAULT_PORT_STR, GatewayExecutor, HttpWatcherClient, ProgressReporter, RuleRegistrar, SERVICE_NAME, SERVICE_VERSION, Scheduler, SynthesisQueue, acquireLock, actualStaleness, buildArchitectTask, buildBuilderTask, buildContextPackage, buildCriticTask, buildMetaFilter, buildOwnershipTree, cleanupStaleLocks, computeEffectiveStaleness, computeEma, computeStructureHash, createLogger, createServer, createSnapshot, discoverMetas, filterInScope, findNode, formatProgressEvent, getScopePrefix, hasSteerChanged, isArchitectTriggered, isLocked, isStale, listArchiveFiles, listMetas, loadServiceConfig, mergeAndWrite, metaConfigSchema, metaErrorSchema, metaJsonSchema, normalizePath, orchestrate, paginatedScan, parseArchitectOutput, parseBuilderOutput, parseCriticOutput, pruneArchive, readLatestArchive, readLockState, registerRoutes, registerShutdownHandlers, releaseLock, resolveConfigPath, resolveMetaDir, selectCandidate, serviceConfigSchema, sleep, startService, toMetaError, walkFiles };
|