@massa-ai/opencode-plugin 1.46.0 → 1.48.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.
- package/dist/config-cli.js +571 -108
- package/dist/index.js +162 -7
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -400,9 +400,64 @@ var init_xdg = () => {};
|
|
|
400
400
|
|
|
401
401
|
// ../../packages/shared/dist/config/massa-ai-config.js
|
|
402
402
|
import path2 from "path";
|
|
403
|
-
var defaultMassaAiConfig;
|
|
403
|
+
var SCHEDULER_JOB_KINDS, MAX_MATCH_WORK = 1e5, MAX_IGNORE_PATTERNS = 1024, DEFAULT_CAPTURE_POLICY, DEFAULT_SCHEDULER_CONFIG, defaultMassaAiConfig;
|
|
404
404
|
var init_massa_ai_config = __esm(() => {
|
|
405
405
|
init_xdg();
|
|
406
|
+
SCHEDULER_JOB_KINDS = [
|
|
407
|
+
"memory-consolidation",
|
|
408
|
+
"decay-sweep",
|
|
409
|
+
"auto-improve",
|
|
410
|
+
"observation-bridge",
|
|
411
|
+
"checkpoint-purge"
|
|
412
|
+
];
|
|
413
|
+
DEFAULT_CAPTURE_POLICY = {
|
|
414
|
+
rules: [
|
|
415
|
+
{ pattern: "**/node_modules/**", disposition: "Drop" },
|
|
416
|
+
{ pattern: "**/.git/**", disposition: "Drop" },
|
|
417
|
+
{ pattern: "**/dist/**", disposition: "Drop" },
|
|
418
|
+
{ pattern: "**/build/**", disposition: "Drop" },
|
|
419
|
+
{ pattern: "**/coverage/**", disposition: "Drop" },
|
|
420
|
+
{ pattern: ".env", disposition: "Drop" },
|
|
421
|
+
{ pattern: ".env.*", disposition: "Drop" },
|
|
422
|
+
{ pattern: "**/generated/**", disposition: "Drop" },
|
|
423
|
+
{ pattern: "**/*.generated.*", disposition: "Drop" },
|
|
424
|
+
{ pattern: "**/*.d.ts", disposition: "Drop" },
|
|
425
|
+
{ pattern: "**/__tests__/**", disposition: "Drop" },
|
|
426
|
+
{ pattern: "**/tests/**", disposition: "Drop" },
|
|
427
|
+
{ pattern: "**/*.test.ts", disposition: "Drop" },
|
|
428
|
+
{ pattern: "**/*.test.tsx", disposition: "Drop" },
|
|
429
|
+
{ pattern: "**/*.test.js", disposition: "Drop" },
|
|
430
|
+
{ pattern: "**/*.test.jsx", disposition: "Drop" },
|
|
431
|
+
{ pattern: "**/*.spec.ts", disposition: "Drop" },
|
|
432
|
+
{ pattern: "**/*.spec.tsx", disposition: "Drop" },
|
|
433
|
+
{ pattern: "**/*.spec.js", disposition: "Drop" },
|
|
434
|
+
{ pattern: "**/*.spec.jsx", disposition: "Drop" },
|
|
435
|
+
{ pattern: "**/benchmarks/**", disposition: "Drop" },
|
|
436
|
+
{ pattern: "**/fixtures/**", disposition: "Drop" },
|
|
437
|
+
{ pattern: "**/*.wasm*", disposition: "Drop" },
|
|
438
|
+
{ pattern: "**/*.min.*", disposition: "Drop" },
|
|
439
|
+
{ pattern: "**/*.map", disposition: "Drop" },
|
|
440
|
+
{ pattern: "**/lock.yaml", disposition: "Drop" },
|
|
441
|
+
{ pattern: "**/pnpm-lock.yaml", disposition: "Drop" },
|
|
442
|
+
{ pattern: "**/package-lock.json", disposition: "Drop" },
|
|
443
|
+
{ pattern: "**/bun.lockb", disposition: "Drop" },
|
|
444
|
+
{ pattern: "**/yarn.lock", disposition: "Drop" }
|
|
445
|
+
],
|
|
446
|
+
maxMatchWork: MAX_MATCH_WORK,
|
|
447
|
+
maxIgnorePatterns: MAX_IGNORE_PATTERNS
|
|
448
|
+
};
|
|
449
|
+
DEFAULT_SCHEDULER_CONFIG = {
|
|
450
|
+
enabled: false,
|
|
451
|
+
tickMs: 60000,
|
|
452
|
+
maxConcurrent: 2,
|
|
453
|
+
jobs: {
|
|
454
|
+
"memory-consolidation": { enabled: false, intervalMs: 30 * 60 * 1000 },
|
|
455
|
+
"decay-sweep": { enabled: false, intervalMs: 60 * 60 * 1000 },
|
|
456
|
+
"auto-improve": { enabled: false, intervalMs: 30 * 60 * 1000 },
|
|
457
|
+
"observation-bridge": { enabled: false, intervalMs: 30 * 60 * 1000 },
|
|
458
|
+
"checkpoint-purge": { enabled: false, intervalMs: 60 * 60 * 1000 }
|
|
459
|
+
}
|
|
460
|
+
};
|
|
406
461
|
defaultMassaAiConfig = {
|
|
407
462
|
database: {
|
|
408
463
|
url: ""
|
|
@@ -421,7 +476,7 @@ var init_massa_ai_config = __esm(() => {
|
|
|
421
476
|
impact: {
|
|
422
477
|
bfsCteEnabled: false
|
|
423
478
|
},
|
|
424
|
-
capturePolicy:
|
|
479
|
+
capturePolicy: DEFAULT_CAPTURE_POLICY,
|
|
425
480
|
cache: {
|
|
426
481
|
enabled: true,
|
|
427
482
|
l1MaxSizeMB: 100,
|
|
@@ -544,7 +599,8 @@ var init_massa_ai_config = __esm(() => {
|
|
|
544
599
|
},
|
|
545
600
|
security: {
|
|
546
601
|
corsOrigins: []
|
|
547
|
-
}
|
|
602
|
+
},
|
|
603
|
+
scheduler: DEFAULT_SCHEDULER_CONFIG
|
|
548
604
|
};
|
|
549
605
|
});
|
|
550
606
|
|
|
@@ -554,6 +610,8 @@ __export(exports_config_loader, {
|
|
|
554
610
|
writeFileAtomically: () => writeFileAtomically,
|
|
555
611
|
saveConfig: () => saveConfig,
|
|
556
612
|
migrateDataDirOnce: () => migrateDataDirOnce,
|
|
613
|
+
mergeSchedulerSection: () => mergeSchedulerSection,
|
|
614
|
+
loadRawUserConfig: () => loadRawUserConfig,
|
|
557
615
|
loadConfigSafe: () => loadConfigSafe,
|
|
558
616
|
loadConfig: () => loadConfig,
|
|
559
617
|
initConfig: () => initConfig,
|
|
@@ -576,6 +634,22 @@ function getConfigPath() {
|
|
|
576
634
|
function configExists() {
|
|
577
635
|
return fs.existsSync(CONFIG_FILE);
|
|
578
636
|
}
|
|
637
|
+
function mergeSchedulerJobs(base, incoming) {
|
|
638
|
+
const defaults = defaultMassaAiConfig.scheduler?.jobs ?? {};
|
|
639
|
+
const merged = {};
|
|
640
|
+
for (const kind of Object.keys(defaults)) {
|
|
641
|
+
merged[kind] = { ...defaults[kind], ...base?.[kind], ...incoming?.[kind] };
|
|
642
|
+
}
|
|
643
|
+
return merged;
|
|
644
|
+
}
|
|
645
|
+
function mergeSchedulerSection(base, incoming) {
|
|
646
|
+
return {
|
|
647
|
+
...defaultMassaAiConfig.scheduler,
|
|
648
|
+
...base,
|
|
649
|
+
...incoming,
|
|
650
|
+
jobs: mergeSchedulerJobs(base?.jobs, incoming?.jobs)
|
|
651
|
+
};
|
|
652
|
+
}
|
|
579
653
|
function loadConfig() {
|
|
580
654
|
if (!fs.existsSync(CONFIG_FILE)) {
|
|
581
655
|
return defaultMassaAiConfig;
|
|
@@ -596,13 +670,27 @@ function loadConfig() {
|
|
|
596
670
|
memory: { ...defaultMassaAiConfig.memory, ...userConfig.memory },
|
|
597
671
|
hooks: { ...defaultMassaAiConfig.hooks, ...userConfig.hooks },
|
|
598
672
|
handoffs: { ...defaultMassaAiConfig.handoffs, ...userConfig.handoffs },
|
|
599
|
-
security: { ...defaultMassaAiConfig.security, ...userConfig.security }
|
|
673
|
+
security: { ...defaultMassaAiConfig.security, ...userConfig.security },
|
|
674
|
+
scheduler: mergeSchedulerSection(undefined, userConfig.scheduler),
|
|
675
|
+
capturePolicy: userConfig.capturePolicy ?? defaultMassaAiConfig.capturePolicy
|
|
600
676
|
};
|
|
601
677
|
} catch (error) {
|
|
602
678
|
console.error(`Error loading config from ${CONFIG_FILE}:`, error);
|
|
603
679
|
return defaultMassaAiConfig;
|
|
604
680
|
}
|
|
605
681
|
}
|
|
682
|
+
function loadRawUserConfig() {
|
|
683
|
+
try {
|
|
684
|
+
if (!fs.existsSync(CONFIG_FILE))
|
|
685
|
+
return {};
|
|
686
|
+
const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, "utf-8"));
|
|
687
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
688
|
+
return {};
|
|
689
|
+
return parsed;
|
|
690
|
+
} catch {
|
|
691
|
+
return {};
|
|
692
|
+
}
|
|
693
|
+
}
|
|
606
694
|
function loadConfigSafe() {
|
|
607
695
|
try {
|
|
608
696
|
return loadConfig();
|
|
@@ -733,11 +821,14 @@ try {
|
|
|
733
821
|
// ../../packages/shared/dist/config/index.js
|
|
734
822
|
init_config_loader();
|
|
735
823
|
init_massa_ai_config();
|
|
824
|
+
init_massa_ai_config();
|
|
825
|
+
init_massa_ai_config();
|
|
736
826
|
init_config_loader();
|
|
737
827
|
import path4 from "path";
|
|
738
828
|
|
|
739
829
|
// ../../packages/shared/dist/config/config-writer.js
|
|
740
830
|
init_config_loader();
|
|
831
|
+
init_massa_ai_config();
|
|
741
832
|
|
|
742
833
|
// ../../packages/shared/dist/config/index.js
|
|
743
834
|
init_xdg();
|
|
@@ -777,7 +868,49 @@ function envList(key, fallback) {
|
|
|
777
868
|
const parsed = s.split(",").map((v) => v.trim()).filter((v) => v.length > 0);
|
|
778
869
|
return parsed.length > 0 ? parsed : fallback;
|
|
779
870
|
}
|
|
780
|
-
|
|
871
|
+
function readSchedulerConfig(rawFileConfig) {
|
|
872
|
+
try {
|
|
873
|
+
const cfg = rawFileConfig;
|
|
874
|
+
return cfg?.scheduler ?? {};
|
|
875
|
+
} catch {
|
|
876
|
+
return {};
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
var SCHEDULER_JOB_ENV = {
|
|
880
|
+
"memory-consolidation": {
|
|
881
|
+
enabledVar: "MASSA_AI_SCHEDULER_CONSOLIDATION_ENABLED",
|
|
882
|
+
intervalVar: "MASSA_AI_SCHEDULER_CONSOLIDATION_INTERVAL_MS",
|
|
883
|
+
defaultIntervalMs: 30 * 60 * 1000
|
|
884
|
+
},
|
|
885
|
+
"decay-sweep": {
|
|
886
|
+
enabledVar: "MASSA_AI_SCHEDULER_DECAY_ENABLED",
|
|
887
|
+
intervalVar: "MASSA_AI_SCHEDULER_DECAY_INTERVAL_MS",
|
|
888
|
+
defaultIntervalMs: 60 * 60 * 1000
|
|
889
|
+
},
|
|
890
|
+
"auto-improve": {
|
|
891
|
+
enabledVar: "MASSA_AI_SCHEDULER_AUTO_IMPROVE_ENABLED",
|
|
892
|
+
intervalVar: "MASSA_AI_SCHEDULER_AUTO_IMPROVE_INTERVAL_MS",
|
|
893
|
+
defaultIntervalMs: 30 * 60 * 1000
|
|
894
|
+
},
|
|
895
|
+
"observation-bridge": {
|
|
896
|
+
enabledVar: "MASSA_AI_SCHEDULER_OBSERVATION_BRIDGE_ENABLED",
|
|
897
|
+
intervalVar: "MASSA_AI_SCHEDULER_OBSERVATION_BRIDGE_INTERVAL_MS",
|
|
898
|
+
defaultIntervalMs: 30 * 60 * 1000
|
|
899
|
+
},
|
|
900
|
+
"checkpoint-purge": {
|
|
901
|
+
enabledVar: "MASSA_AI_SCHEDULER_CHECKPOINT_PURGE_ENABLED",
|
|
902
|
+
intervalVar: "MASSA_AI_SCHEDULER_CHECKPOINT_PURGE_INTERVAL_MS",
|
|
903
|
+
defaultIntervalMs: 60 * 60 * 1000
|
|
904
|
+
}
|
|
905
|
+
};
|
|
906
|
+
function resolveSchedulerJob(kind, fileJobs) {
|
|
907
|
+
const meta = SCHEDULER_JOB_ENV[kind];
|
|
908
|
+
const fileJob = fileJobs?.[kind];
|
|
909
|
+
return {
|
|
910
|
+
enabled: envBool(meta.enabledVar, fileJob?.enabled ?? false),
|
|
911
|
+
intervalMs: envNum(meta.intervalVar, fileJob?.intervalMs ?? meta.defaultIntervalMs)
|
|
912
|
+
};
|
|
913
|
+
}
|
|
781
914
|
function validateCapturePolicyConfig(raw) {
|
|
782
915
|
if (!raw || typeof raw !== "object")
|
|
783
916
|
throw new TypeError("capturePolicy must be an object");
|
|
@@ -880,10 +1013,11 @@ var DEFAULT_ALLOWED_EXTENSIONS = [
|
|
|
880
1013
|
var fileConfig = loadConfigSafe();
|
|
881
1014
|
var fileCacheL1Bytes = fileConfig.cache?.l1MaxSizeMB ? fileConfig.cache.l1MaxSizeMB * 1024 * 1024 : undefined;
|
|
882
1015
|
var fileCacheL2Bytes = fileConfig.cache?.l2MaxSizeMB ? fileConfig.cache.l2MaxSizeMB * 1024 * 1024 : undefined;
|
|
1016
|
+
var resolvedDataDir = getGlobalDataDir();
|
|
883
1017
|
var defaultConfig = {
|
|
884
1018
|
name: "massa-ai-server",
|
|
885
1019
|
version: "1.0.0",
|
|
886
|
-
dataDir:
|
|
1020
|
+
dataDir: resolvedDataDir,
|
|
887
1021
|
cache: {
|
|
888
1022
|
l1: {
|
|
889
1023
|
maxSize: envNum("L1_CACHE_MAX_SIZE", fileCacheL1Bytes ?? 100 * 1024 * 1024),
|
|
@@ -1007,8 +1141,24 @@ var defaultConfig = {
|
|
|
1007
1141
|
logging: {
|
|
1008
1142
|
level: process.env.LOG_LEVEL || fileConfig.logging?.level || "info",
|
|
1009
1143
|
enableMetrics: process.env.ENABLE_METRICS === "true" || process.env.ENABLE_METRICS === undefined && !!fileConfig.logging?.enableMetrics,
|
|
1010
|
-
file: process.env.MASSA_AI_LOG_FILE || fileConfig.logging?.file ||
|
|
1144
|
+
file: process.env.MASSA_AI_LOG_FILE || fileConfig.logging?.file || path4.join(resolvedDataDir, "logs", "massa-ai.log"),
|
|
1145
|
+
enableFileSink: envBool("MASSA_AI_LOG_ENABLE_FILE_SINK", fileConfig.logging?.enableFileSink ?? true),
|
|
1146
|
+
bufferSize: envNum("MASSA_AI_LOG_BUFFER_SIZE", fileConfig.logging?.bufferSize ?? 2000),
|
|
1147
|
+
maxFileSizeMb: envNum("MASSA_AI_LOG_MAX_FILE_SIZE_MB", fileConfig.logging?.maxFileSizeMb ?? 32),
|
|
1148
|
+
maxFiles: envNum("MASSA_AI_LOG_MAX_FILES", fileConfig.logging?.maxFiles ?? 5)
|
|
1011
1149
|
},
|
|
1150
|
+
scheduler: (() => {
|
|
1151
|
+
const fileScheduler = readSchedulerConfig(fileConfig);
|
|
1152
|
+
return {
|
|
1153
|
+
enabled: envBool("MASSA_AI_SCHEDULER_ENABLED", fileScheduler.enabled ?? false),
|
|
1154
|
+
tickMs: envNum("MASSA_AI_SCHEDULER_TICK_MS", fileScheduler.tickMs ?? 60000),
|
|
1155
|
+
maxConcurrent: envNum("MASSA_AI_SCHEDULER_MAX_CONCURRENT", fileScheduler.maxConcurrent ?? 2),
|
|
1156
|
+
jobs: Object.fromEntries(SCHEDULER_JOB_KINDS.map((kind) => [
|
|
1157
|
+
kind,
|
|
1158
|
+
resolveSchedulerJob(kind, fileScheduler.jobs)
|
|
1159
|
+
]))
|
|
1160
|
+
};
|
|
1161
|
+
})(),
|
|
1012
1162
|
synapse: {
|
|
1013
1163
|
enabled: process.env.SYNAPSE_ENABLED !== "false",
|
|
1014
1164
|
inhibition: {
|
|
@@ -1123,6 +1273,11 @@ class Config {
|
|
|
1123
1273
|
rateLimit: { ...defaults.rateLimit, ...overrides.rateLimit },
|
|
1124
1274
|
security: { ...defaults.security, ...overrides.security },
|
|
1125
1275
|
logging: { ...defaults.logging, ...overrides.logging },
|
|
1276
|
+
scheduler: {
|
|
1277
|
+
...defaults.scheduler,
|
|
1278
|
+
...overrides.scheduler,
|
|
1279
|
+
jobs: { ...defaults.scheduler.jobs, ...overrides.scheduler?.jobs }
|
|
1280
|
+
},
|
|
1126
1281
|
synapse: {
|
|
1127
1282
|
...defaults.synapse,
|
|
1128
1283
|
...overrides.synapse,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@massa-ai/opencode-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.48.0",
|
|
4
4
|
"description": "massa-ai plugin for OpenCode - Semantic code search, memory, and context compression",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@opencode-ai/plugin": "^1.2.15",
|
|
26
26
|
"@opencode-ai/sdk": "^1.2.15",
|
|
27
|
-
"@massa-ai/core": "^1.
|
|
28
|
-
"@massa-ai/shared": "^1.
|
|
27
|
+
"@massa-ai/core": "^1.48.0",
|
|
28
|
+
"@massa-ai/shared": "^1.48.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.10.5",
|