compact-agent 1.8.4 → 1.10.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.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/index.js +145 -5
- package/dist/index.js.map +1 -1
- package/dist/mempalace/index.d.ts +100 -0
- package/dist/mempalace/index.js +196 -0
- package/dist/mempalace/index.js.map +1 -0
- package/dist/mempalace/search.d.ts +38 -0
- package/dist/mempalace/search.js +133 -0
- package/dist/mempalace/search.js.map +1 -0
- package/dist/mempalace/store.d.ts +77 -0
- package/dist/mempalace/store.js +332 -0
- package/dist/mempalace/store.js.map +1 -0
- package/dist/mempalace/types.d.ts +140 -0
- package/dist/mempalace/types.js +27 -0
- package/dist/mempalace/types.js.map +1 -0
- package/dist/permissions.js +16 -3
- package/dist/permissions.js.map +1 -1
- package/dist/query.js +8 -0
- package/dist/query.js.map +1 -1
- package/dist/system-prompt.js +41 -0
- package/dist/system-prompt.js.map +1 -1
- package/dist/tools/index.js +3 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/memory.d.ts +30 -0
- package/dist/tools/memory.js +319 -0
- package/dist/tools/memory.js.map +1 -0
- package/dist/turn-context.d.ts +43 -0
- package/dist/turn-context.js +123 -0
- package/dist/turn-context.js.map +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js.map +1 -1
- package/package.json +5 -2
package/dist/config.js
CHANGED
|
@@ -113,7 +113,7 @@ function validateConfig(config) {
|
|
|
113
113
|
config.permissionMode = 'ask';
|
|
114
114
|
}
|
|
115
115
|
// Warn on unexpected fields
|
|
116
|
-
const expectedFields = new Set(['apiKey', 'baseURL', 'model', 'fallbackModel', 'provider', 'maxTokens', 'temperature', 'permissionMode', 'dryRun', 'theme', 'palette', 'showThinking', 'voice']);
|
|
116
|
+
const expectedFields = new Set(['apiKey', 'baseURL', 'model', 'fallbackModel', 'provider', 'maxTokens', 'temperature', 'permissionMode', 'alwaysAllowedTools', 'dryRun', 'theme', 'palette', 'showThinking', 'voice']);
|
|
117
117
|
for (const key in config) {
|
|
118
118
|
if (!expectedFields.has(key)) {
|
|
119
119
|
console.warn(`Warning: Unexpected config field: ${key}`);
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC,wEAAwE;AACxE,0EAA0E;AAC1E,4DAA4D;AAC5D,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;AAC/E,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AAEpD,MAAM,cAAc,GAAoB;IACtC,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,8BAA8B;IACvC,KAAK,EAAE,2BAA2B;IAClC,gEAAgE;IAChE,mEAAmE;IACnE,gEAAgE;IAChE,oEAAoE;IACpE,4DAA4D;IAC5D,aAAa,EAAE,2BAA2B;IAC1C,QAAQ,EAAE,YAAY;IACtB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,GAAG;IAChB,cAAc,EAAE,KAAK;IACrB,sEAAsE;IACtE,wEAAwE;IACxE,OAAO,EAAE,cAAc;IACvB,4EAA4E;IAC5E,+DAA+D;IAC/D,YAAY,EAAE,IAAI;IAClB,4EAA4E;IAC5E,sEAAsE;IACtE,4EAA4E;IAC5E,oDAAoD;IACpD,KAAK,EAAE;QACL,OAAO,EAAE,KAAK;QACd,GAAG,EAAE;YACH,sEAAsE;YACtE,oEAAoE;YACpE,sEAAsE;YACtE,gBAAgB;YA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E,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC;IACvN,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,qCAAqC,GAAG,EAAE,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAuB;IAChD,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;IACzB,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,WAAW,CAAC,GAAoB;IACvC,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAClF,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -55,6 +55,8 @@ import { installEcc, getEccCommandPrompt, loadEccState, eccResourcesAvailable, r
|
|
|
55
55
|
import { buildWalkthroughPrompt } from './walkthrough.js';
|
|
56
56
|
// Stitch (Google's AI UI/UX design tool) — /stitch, /stitch-config, /stitch-tools
|
|
57
57
|
import { buildStitchPrompt, buildStitchToolsPrompt, saveStitchConfig, printStitchStatus, stitchConfigured } from './stitch.js';
|
|
58
|
+
// MemPalace memory subsystem — wings/rooms/drawers/tunnels/KG, both global + project stores
|
|
59
|
+
import * as mempalace from './mempalace/index.js';
|
|
58
60
|
// Voice / accessibility — built-in dictation (Whisper) + readout (ElevenLabs)
|
|
59
61
|
import { printVoiceStatus, isVoiceEnabled, getTtsConfig, getSttConfig, getAccessibilityConfig, speak, dictateOnce, } from './voice.js';
|
|
60
62
|
import { isFfmpegAvailable, audioCue, startRecording, probeMic, micProbeMessage } from './audio.js';
|
|
@@ -198,7 +200,8 @@ export function handleSlashCommand(input, config, messages, session, mode) {
|
|
|
198
200
|
console.log(h('\n ── Tools & Config ──'));
|
|
199
201
|
console.log(d(' ') + c('/tools') + d(' — list tools'));
|
|
200
202
|
console.log(d(' ') + c('/rules') + d(' — show coding rules'));
|
|
201
|
-
console.log(d(' ') + c('/perm <mode>') + d(' — set permission mode'));
|
|
203
|
+
console.log(d(' ') + c('/perm <mode>') + d(' — set permission mode (ask/auto/yolo); no arg shows current + always-allow list'));
|
|
204
|
+
console.log(d(' ') + c('/perm-reset') + d(' — clear the per-tool always-allow list'));
|
|
202
205
|
console.log(d(' ') + c('/dry-run') + d(' — toggle dry-run mode'));
|
|
203
206
|
console.log(d(' ') + c('/thinking') + d(' — toggle thinking/reasoning display'));
|
|
204
207
|
console.log(d(' ') + c('/cd <path>') + d(' — change directory'));
|
|
@@ -249,7 +252,7 @@ export function handleSlashCommand(input, config, messages, session, mode) {
|
|
|
249
252
|
console.log(d(' ') + c('/evolve') + d(' — cluster instincts into reusable skills'));
|
|
250
253
|
console.log(d(' ') + c('/prune') + d(' — delete expired instincts'));
|
|
251
254
|
console.log(d(' ') + c('/skills') + d(' — list learned skills'));
|
|
252
|
-
console.log(d(' ') + c('/memory') + d('
|
|
255
|
+
console.log(d(' ') + c('/memory [sub]') + d(' — MemPalace memory: status (default), wings, rooms, ls, search <q>, get <id>, rm <id>'));
|
|
253
256
|
console.log(d(' ') + c('/users') + d(' — manage users table'));
|
|
254
257
|
console.log(d(' ') + c('/count [inc|dec|reset]') + d(' — increment/decrement/reset counter'));
|
|
255
258
|
console.log(d(' ') + c('/detect') + d(' — detect package manager, test runner, build tool'));
|
|
@@ -560,8 +563,22 @@ export function handleSlashCommand(input, config, messages, session, mode) {
|
|
|
560
563
|
}
|
|
561
564
|
else {
|
|
562
565
|
console.log(chalk.dim(` Current: ${config.permissionMode} (options: ask, auto, yolo)`));
|
|
566
|
+
const allowed = config.alwaysAllowedTools || [];
|
|
567
|
+
if (allowed.length > 0) {
|
|
568
|
+
console.log(chalk.dim(` Always-allow list: ${allowed.join(', ')}`));
|
|
569
|
+
console.log(chalk.dim(` Clear with /perm-reset`));
|
|
570
|
+
}
|
|
563
571
|
}
|
|
564
572
|
return { handled: true };
|
|
573
|
+
// Clear the per-tool always-allow list. Useful after typing "always"
|
|
574
|
+
// by accident, or to re-tighten security after a session of work.
|
|
575
|
+
case '/perm-reset': {
|
|
576
|
+
const had = (config.alwaysAllowedTools || []).length;
|
|
577
|
+
config.alwaysAllowedTools = [];
|
|
578
|
+
saveConfig(config);
|
|
579
|
+
console.log(chalk.green(` Cleared ${had} always-allowed tool(s). Permission prompts re-enabled.`));
|
|
580
|
+
return { handled: true };
|
|
581
|
+
}
|
|
565
582
|
case '/dry-run':
|
|
566
583
|
config.dryRun = !config.dryRun;
|
|
567
584
|
saveConfig(config);
|
|
@@ -771,9 +788,132 @@ export function handleSlashCommand(input, config, messages, session, mode) {
|
|
|
771
788
|
case '/skills':
|
|
772
789
|
printSkillList();
|
|
773
790
|
return { handled: true };
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
791
|
+
// /memory <sub> — MemPalace inventory & inspection.
|
|
792
|
+
// /memory status + counts (legacy + new combined)
|
|
793
|
+
// /memory wings list wings in both stores
|
|
794
|
+
// /memory rooms <wing> rooms within a wing
|
|
795
|
+
// /memory ls <w> <r> drawers in a wing/room
|
|
796
|
+
// /memory search <q> text search (same backend as memory_search tool)
|
|
797
|
+
// /memory get <id> full content of a single drawer
|
|
798
|
+
// /memory rm <id> delete a drawer (cascades tunnels + triples)
|
|
799
|
+
// /memory stats storage + counts per scope
|
|
800
|
+
case '/memory': {
|
|
801
|
+
const parts = args.trim().split(/\s+/).filter(Boolean);
|
|
802
|
+
const sub = (parts[0] || '').toLowerCase();
|
|
803
|
+
try {
|
|
804
|
+
if (!sub || sub === 'status' || sub === 'stats') {
|
|
805
|
+
const s = mempalace.stats(process.cwd());
|
|
806
|
+
console.log(chalk.cyan('\n MemPalace status'));
|
|
807
|
+
console.log(chalk.dim(` global ${s.globalPath}`));
|
|
808
|
+
console.log(chalk.dim(` ${s.global.drawers} drawer(s) · ${s.global.wings} wing(s) · ${s.global.rooms} room(s) · ${s.global.tunnels} tunnel(s) · ${s.global.triples} fact(s)`));
|
|
809
|
+
console.log(chalk.dim(` project ${s.projectPath}${s.projectExists ? '' : ' (not yet created)'}`));
|
|
810
|
+
console.log(chalk.dim(` ${s.project.drawers} drawer(s) · ${s.project.wings} wing(s) · ${s.project.rooms} room(s) · ${s.project.tunnels} tunnel(s) · ${s.project.triples} fact(s)`));
|
|
811
|
+
console.log();
|
|
812
|
+
printMemoryStatus();
|
|
813
|
+
return { handled: true };
|
|
814
|
+
}
|
|
815
|
+
if (sub === 'wings') {
|
|
816
|
+
const w = mempalace.listWings(process.cwd());
|
|
817
|
+
console.log(chalk.cyan('\n Wings:'));
|
|
818
|
+
if (w.global.length === 0 && w.project.length === 0) {
|
|
819
|
+
console.log(chalk.dim(' (none yet — agent will create wings as it learns)'));
|
|
820
|
+
}
|
|
821
|
+
for (const wm of w.global)
|
|
822
|
+
console.log(chalk.dim(` global · ${wm.name.padEnd(20)} ${wm.drawerCount} drawer(s)`));
|
|
823
|
+
for (const wm of w.project)
|
|
824
|
+
console.log(chalk.dim(` project · ${wm.name.padEnd(19)} ${wm.drawerCount} drawer(s)`));
|
|
825
|
+
console.log();
|
|
826
|
+
return { handled: true };
|
|
827
|
+
}
|
|
828
|
+
if (sub === 'rooms') {
|
|
829
|
+
const r = mempalace.listRooms(process.cwd(), parts[1]);
|
|
830
|
+
const all = [...r.global.map((m) => ({ ...m, s: 'global' })), ...r.project.map((m) => ({ ...m, s: 'project' }))];
|
|
831
|
+
if (all.length === 0) {
|
|
832
|
+
console.log(chalk.dim(` No rooms${parts[1] ? ' in wing ' + parts[1] : ''}.`));
|
|
833
|
+
return { handled: true };
|
|
834
|
+
}
|
|
835
|
+
console.log(chalk.cyan(`\n Rooms${parts[1] ? ' in ' + parts[1] : ''}:`));
|
|
836
|
+
for (const m of all)
|
|
837
|
+
console.log(chalk.dim(` ${m.s.padEnd(7)} ${m.wing}/${m.name} — ${m.drawerCount} drawer(s), last ${m.lastTouched.slice(0, 10)}`));
|
|
838
|
+
console.log();
|
|
839
|
+
return { handled: true };
|
|
840
|
+
}
|
|
841
|
+
if (sub === 'ls' || sub === 'list') {
|
|
842
|
+
const drawers = mempalace.listDrawers({ wing: parts[1], room: parts[2], cwd: process.cwd() });
|
|
843
|
+
if (drawers.length === 0) {
|
|
844
|
+
console.log(chalk.dim(' No drawers match.'));
|
|
845
|
+
return { handled: true };
|
|
846
|
+
}
|
|
847
|
+
console.log(chalk.cyan(`\n Drawers (${drawers.length}):`));
|
|
848
|
+
for (const d of drawers.slice(0, 50)) {
|
|
849
|
+
const excerpt = d.content.length > 90 ? d.content.slice(0, 90) + '…' : d.content;
|
|
850
|
+
console.log(chalk.dim(` ${d.id} (${d.scope}) ${d.wing}/${d.room}: `) + chalk.white(excerpt));
|
|
851
|
+
}
|
|
852
|
+
if (drawers.length > 50)
|
|
853
|
+
console.log(chalk.dim(` … and ${drawers.length - 50} more`));
|
|
854
|
+
console.log();
|
|
855
|
+
return { handled: true };
|
|
856
|
+
}
|
|
857
|
+
if (sub === 'search') {
|
|
858
|
+
const q = parts.slice(1).join(' ');
|
|
859
|
+
if (!q) {
|
|
860
|
+
console.log(chalk.yellow(' Usage: /memory search <query>'));
|
|
861
|
+
return { handled: true };
|
|
862
|
+
}
|
|
863
|
+
const hits = mempalace.search(q, process.cwd(), { limit: 10 });
|
|
864
|
+
if (hits.length === 0) {
|
|
865
|
+
console.log(chalk.dim(` No matches for "${q}".`));
|
|
866
|
+
return { handled: true };
|
|
867
|
+
}
|
|
868
|
+
console.log(chalk.cyan(`\n ${hits.length} match(es) for "${q}":`));
|
|
869
|
+
for (const h of hits) {
|
|
870
|
+
const excerpt = h.drawer.content.length > 200 ? h.drawer.content.slice(0, 200) + '…' : h.drawer.content;
|
|
871
|
+
const tagStr = h.drawer.tags.length > 0 ? ` [${h.drawer.tags.join(', ')}]` : '';
|
|
872
|
+
console.log(chalk.dim(` ${h.drawer.id} (${h.drawer.scope} · ${h.drawer.wing}/${h.drawer.room}${tagStr}) score ${h.score.toFixed(2)}`));
|
|
873
|
+
console.log(chalk.white(` ${excerpt}`));
|
|
874
|
+
}
|
|
875
|
+
console.log();
|
|
876
|
+
return { handled: true };
|
|
877
|
+
}
|
|
878
|
+
if (sub === 'get' || sub === 'recall') {
|
|
879
|
+
const id = parts[1];
|
|
880
|
+
if (!id) {
|
|
881
|
+
console.log(chalk.yellow(' Usage: /memory get <drawer-id>'));
|
|
882
|
+
return { handled: true };
|
|
883
|
+
}
|
|
884
|
+
const d = mempalace.getDrawer(id, process.cwd());
|
|
885
|
+
if (!d) {
|
|
886
|
+
console.log(chalk.yellow(` No drawer ${id}.`));
|
|
887
|
+
return { handled: true };
|
|
888
|
+
}
|
|
889
|
+
const tagStr = d.tags.length > 0 ? ` [${d.tags.join(', ')}]` : '';
|
|
890
|
+
console.log(chalk.cyan(`\n ${d.id} (${d.scope} · ${d.wing}/${d.room}${tagStr})`));
|
|
891
|
+
console.log(chalk.dim(` importance ${d.importance} · created ${d.createdAt} · updated ${d.updatedAt}\n`));
|
|
892
|
+
console.log(d.content);
|
|
893
|
+
console.log();
|
|
894
|
+
return { handled: true };
|
|
895
|
+
}
|
|
896
|
+
if (sub === 'rm' || sub === 'delete') {
|
|
897
|
+
const id = parts[1];
|
|
898
|
+
if (!id) {
|
|
899
|
+
console.log(chalk.yellow(' Usage: /memory rm <drawer-id>'));
|
|
900
|
+
return { handled: true };
|
|
901
|
+
}
|
|
902
|
+
// Try both stores; whichever owns it returns true
|
|
903
|
+
const removed = mempalace.getGlobalStore().deleteDrawer(id)
|
|
904
|
+
|| mempalace.getProjectStore(process.cwd()).deleteDrawer(id);
|
|
905
|
+
console.log(removed ? chalk.green(` Deleted drawer ${id} (cascaded tunnels + triples).`) : chalk.yellow(` No drawer ${id}.`));
|
|
906
|
+
return { handled: true };
|
|
907
|
+
}
|
|
908
|
+
console.log(chalk.yellow(` Unknown /memory subcommand: ${sub}`));
|
|
909
|
+
console.log(chalk.dim(' Try: /memory (status), wings, rooms <wing>, ls <wing> <room>, search <q>, get <id>, rm <id>'));
|
|
910
|
+
return { handled: true };
|
|
911
|
+
}
|
|
912
|
+
catch (e) {
|
|
913
|
+
console.log(chalk.red(` /memory failed: ${e instanceof Error ? e.message : e}`));
|
|
914
|
+
return { handled: true };
|
|
915
|
+
}
|
|
916
|
+
}
|
|
777
917
|
// ── Users Table ──────────────────────────────────────
|
|
778
918
|
case '/users': {
|
|
779
919
|
const sub = args.trim();
|