@hoilab/ada-cli 0.84.21 → 0.84.22
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/CHANGELOG.md +20 -0
- package/README.es.md +163 -0
- package/README.md +99 -652
- package/dist/cli/args.d.ts +3 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +11 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +2 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/home-screen.d.ts.map +1 -1
- package/dist/cli/home-screen.js +2 -2
- package/dist/cli/home-screen.js.map +1 -1
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +9 -3
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -1
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +57 -7
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +449 -73
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +4 -3
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +3 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +4 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +41 -32
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/defaults.d.ts +1 -0
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/defaults.js +9 -0
- package/dist/core/defaults.js.map +1 -1
- package/dist/core/engine-personality.d.ts +12 -0
- package/dist/core/engine-personality.d.ts.map +1 -0
- package/dist/core/engine-personality.js +53 -0
- package/dist/core/engine-personality.js.map +1 -0
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +10 -5
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/types.d.ts +23 -4
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +2 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/memory-engine/audit-export.d.ts +54 -0
- package/dist/core/memory-engine/audit-export.d.ts.map +1 -0
- package/dist/core/memory-engine/audit-export.js +85 -0
- package/dist/core/memory-engine/audit-export.js.map +1 -0
- package/dist/core/memory-engine/audit.d.ts.map +1 -1
- package/dist/core/memory-engine/audit.js +7 -8
- package/dist/core/memory-engine/audit.js.map +1 -1
- package/dist/core/memory-engine/engine.d.ts +2 -3
- package/dist/core/memory-engine/engine.d.ts.map +1 -1
- package/dist/core/memory-engine/engine.js +148 -50
- package/dist/core/memory-engine/engine.js.map +1 -1
- package/dist/core/memory-engine/inverted-index.d.ts.map +1 -1
- package/dist/core/memory-engine/inverted-index.js +67 -10
- package/dist/core/memory-engine/inverted-index.js.map +1 -1
- package/dist/core/memory-engine/keychain.d.ts.map +1 -1
- package/dist/core/memory-engine/keychain.js +1 -6
- package/dist/core/memory-engine/keychain.js.map +1 -1
- package/dist/core/memory-engine/observation-store.d.ts +1 -0
- package/dist/core/memory-engine/observation-store.d.ts.map +1 -1
- package/dist/core/memory-engine/observation-store.js +37 -8
- package/dist/core/memory-engine/observation-store.js.map +1 -1
- package/dist/core/memory-engine/scanner.d.ts.map +1 -1
- package/dist/core/memory-engine/scanner.js +25 -5
- package/dist/core/memory-engine/scanner.js.map +1 -1
- package/dist/core/memory-engine/security.d.ts.map +1 -1
- package/dist/core/memory-engine/security.js +131 -23
- package/dist/core/memory-engine/security.js.map +1 -1
- package/dist/core/memory-engine/session-indexer.d.ts.map +1 -1
- package/dist/core/memory-engine/session-indexer.js +8 -2
- package/dist/core/memory-engine/session-indexer.js.map +1 -1
- package/dist/core/memory-engine/tools.d.ts +2 -2
- package/dist/core/memory-engine/tools.d.ts.map +1 -1
- package/dist/core/memory-engine/tools.js +14 -7
- package/dist/core/memory-engine/tools.js.map +1 -1
- package/dist/core/memory-engine/vault.d.ts.map +1 -1
- package/dist/core/memory-engine/vault.js +2 -2
- package/dist/core/memory-engine/vault.js.map +1 -1
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +2 -1
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -0
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +12 -6
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js +2 -1
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +11 -6
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-manifest.d.ts.map +1 -1
- package/dist/core/pi-manifest.js +2 -1
- package/dist/core/pi-manifest.js.map +1 -1
- package/dist/core/prompt-optimizer.d.ts +53 -0
- package/dist/core/prompt-optimizer.d.ts.map +1 -0
- package/dist/core/prompt-optimizer.js +138 -0
- package/dist/core/prompt-optimizer.js.map +1 -0
- package/dist/core/provider-attribution.d.ts.map +1 -1
- package/dist/core/provider-attribution.js +1 -1
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +2 -1
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts +50 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +233 -7
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +8 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +11 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +2 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-diagnostics.d.ts +9 -0
- package/dist/core/settings-diagnostics.d.ts.map +1 -0
- package/dist/core/settings-diagnostics.js +21 -0
- package/dist/core/settings-diagnostics.js.map +1 -0
- package/dist/core/settings-manager.d.ts +52 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +204 -10
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +51 -33
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +0 -5
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +2 -5
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +20 -4
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +2 -2
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/project-memory-tool.d.ts.map +1 -1
- package/dist/core/tools/project-memory-tool.js +4 -1
- package/dist/core/tools/project-memory-tool.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +2 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/workflows/agent-runner.d.ts +86 -0
- package/dist/core/workflows/agent-runner.d.ts.map +1 -0
- package/dist/core/workflows/agent-runner.js +225 -0
- package/dist/core/workflows/agent-runner.js.map +1 -0
- package/dist/core/workflows/builtins.d.ts +41 -0
- package/dist/core/workflows/builtins.d.ts.map +1 -0
- package/dist/core/workflows/builtins.js +282 -0
- package/dist/core/workflows/builtins.js.map +1 -0
- package/dist/core/workflows/goal-engine/engine.d.ts +134 -0
- package/dist/core/workflows/goal-engine/engine.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/engine.js +462 -0
- package/dist/core/workflows/goal-engine/engine.js.map +1 -0
- package/dist/core/workflows/goal-engine/errors.d.ts +7 -0
- package/dist/core/workflows/goal-engine/errors.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/errors.js +9 -0
- package/dist/core/workflows/goal-engine/errors.js.map +1 -0
- package/dist/core/workflows/goal-engine/index.d.ts +13 -0
- package/dist/core/workflows/goal-engine/index.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/index.js +8 -0
- package/dist/core/workflows/goal-engine/index.js.map +1 -0
- package/dist/core/workflows/goal-engine/persistence.d.ts +31 -0
- package/dist/core/workflows/goal-engine/persistence.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/persistence.js +145 -0
- package/dist/core/workflows/goal-engine/persistence.js.map +1 -0
- package/dist/core/workflows/goal-engine/prompts.d.ts +37 -0
- package/dist/core/workflows/goal-engine/prompts.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/prompts.js +131 -0
- package/dist/core/workflows/goal-engine/prompts.js.map +1 -0
- package/dist/core/workflows/goal-engine/state.d.ts +41 -0
- package/dist/core/workflows/goal-engine/state.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/state.js +397 -0
- package/dist/core/workflows/goal-engine/state.js.map +1 -0
- package/dist/core/workflows/goal-engine/tools.d.ts +31 -0
- package/dist/core/workflows/goal-engine/tools.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/tools.js +211 -0
- package/dist/core/workflows/goal-engine/tools.js.map +1 -0
- package/dist/core/workflows/goal-engine/types.d.ts +286 -0
- package/dist/core/workflows/goal-engine/types.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/types.js +17 -0
- package/dist/core/workflows/goal-engine/types.js.map +1 -0
- package/dist/core/workflows/goal-engine/worktree-fingerprint.d.ts +23 -0
- package/dist/core/workflows/goal-engine/worktree-fingerprint.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/worktree-fingerprint.js +72 -0
- package/dist/core/workflows/goal-engine/worktree-fingerprint.js.map +1 -0
- package/dist/core/workflows/graph-sync.d.ts +67 -0
- package/dist/core/workflows/graph-sync.d.ts.map +1 -0
- package/dist/core/workflows/graph-sync.js +188 -0
- package/dist/core/workflows/graph-sync.js.map +1 -0
- package/dist/core/workflows/graph.d.ts +143 -0
- package/dist/core/workflows/graph.d.ts.map +1 -0
- package/dist/core/workflows/graph.js +319 -0
- package/dist/core/workflows/graph.js.map +1 -0
- package/dist/core/workflows/index.d.ts +18 -0
- package/dist/core/workflows/index.d.ts.map +1 -0
- package/dist/core/workflows/index.js +14 -0
- package/dist/core/workflows/index.js.map +1 -0
- package/dist/core/workflows/journal.d.ts +68 -0
- package/dist/core/workflows/journal.d.ts.map +1 -0
- package/dist/core/workflows/journal.js +83 -0
- package/dist/core/workflows/journal.js.map +1 -0
- package/dist/core/workflows/manager.d.ts +112 -0
- package/dist/core/workflows/manager.d.ts.map +1 -0
- package/dist/core/workflows/manager.js +327 -0
- package/dist/core/workflows/manager.js.map +1 -0
- package/dist/core/workflows/resolve-script.d.ts +35 -0
- package/dist/core/workflows/resolve-script.d.ts.map +1 -0
- package/dist/core/workflows/resolve-script.js +66 -0
- package/dist/core/workflows/resolve-script.js.map +1 -0
- package/dist/core/workflows/runtime.d.ts +49 -0
- package/dist/core/workflows/runtime.d.ts.map +1 -0
- package/dist/core/workflows/runtime.js +301 -0
- package/dist/core/workflows/runtime.js.map +1 -0
- package/dist/core/workflows/shared-store.d.ts +31 -0
- package/dist/core/workflows/shared-store.d.ts.map +1 -0
- package/dist/core/workflows/shared-store.js +80 -0
- package/dist/core/workflows/shared-store.js.map +1 -0
- package/dist/core/workflows/subagent-host.d.ts +50 -0
- package/dist/core/workflows/subagent-host.d.ts.map +1 -0
- package/dist/core/workflows/subagent-host.js +225 -0
- package/dist/core/workflows/subagent-host.js.map +1 -0
- package/dist/core/workflows/tool-workflow.d.ts +22 -0
- package/dist/core/workflows/tool-workflow.d.ts.map +1 -0
- package/dist/core/workflows/tool-workflow.js +120 -0
- package/dist/core/workflows/tool-workflow.js.map +1 -0
- package/dist/core/workflows/types.d.ts +142 -0
- package/dist/core/workflows/types.d.ts.map +1 -0
- package/dist/core/workflows/types.js +26 -0
- package/dist/core/workflows/types.js.map +1 -0
- package/dist/core/workflows/worktree.d.ts +42 -0
- package/dist/core/workflows/worktree.d.ts.map +1 -0
- package/dist/core/workflows/worktree.js +107 -0
- package/dist/core/workflows/worktree.js.map +1 -0
- package/dist/extensions/llama/index.d.ts.map +1 -1
- package/dist/extensions/llama/index.js +2 -0
- package/dist/extensions/llama/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +6 -2
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/index.d.ts +16 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -11
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +4 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +20 -15
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +4 -3
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/home-screen.d.ts.map +1 -1
- package/dist/modes/interactive/components/home-screen.js +2 -2
- package/dist/modes/interactive/components/home-screen.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +2 -3
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +16 -6
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/prompt-optimization.d.ts +16 -0
- package/dist/modes/interactive/components/prompt-optimization.d.ts.map +1 -0
- package/dist/modes/interactive/components/prompt-optimization.js +46 -0
- package/dist/modes/interactive/components/prompt-optimization.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +19 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +247 -46
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts +72 -0
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-submenu.js +165 -0
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +8 -3
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +29 -3
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +24 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +677 -34
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +4 -3
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/json-event.d.ts +16 -13
- package/dist/modes/json-event.d.ts.map +1 -1
- package/dist/modes/json-event.js +20 -6
- package/dist/modes/json-event.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +173 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +29 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +1 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/skills/ada-engine/SKILL.md +153 -0
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +2 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/management-http.d.ts +5 -3
- package/dist/utils/management-http.d.ts.map +1 -1
- package/dist/utils/management-http.js +14 -10
- package/dist/utils/management-http.js.map +1 -1
- package/dist/utils/text.d.ts +8 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +9 -0
- package/dist/utils/text.js.map +1 -0
- package/docs/compaction.md +15 -0
- package/docs/custom-provider.md +5 -2
- package/docs/extensions.md +11 -2
- package/docs/json.md +7 -2
- package/docs/llama-cpp.md +2 -0
- package/docs/models.md +8 -2
- package/docs/rpc.md +9 -3
- package/docs/settings.md +2 -2
- package/docs/skills.md +4 -3
- package/examples/extensions/border-status-editor.ts +1 -1
- package/examples/extensions/git-checkpoint.ts +2 -2
- package/examples/extensions/notify.ts +3 -1
- package/examples/extensions/subagent/README.md +1 -1
- package/examples/extensions/subagent/index.ts +6 -1
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/rpc-extension-ui.ts +1 -1
- package/examples/sdk/06-extensions.ts +1 -1
- package/examples/sdk/README.md +1 -1
- package/npm-shrinkwrap.json +2 -12
- package/package.json +3 -3
|
@@ -13,16 +13,15 @@
|
|
|
13
13
|
* conversation.
|
|
14
14
|
*/
|
|
15
15
|
import { createHash } from "node:crypto";
|
|
16
|
-
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
17
16
|
import { existsSync } from "node:fs";
|
|
17
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
18
18
|
import { join } from "node:path";
|
|
19
|
-
import {
|
|
19
|
+
import { AuditLog } from "./audit.js";
|
|
20
20
|
import { InvertedIndex } from "./inverted-index.js";
|
|
21
|
-
import {
|
|
21
|
+
import { ENTRY_DELIMITER, listProjectHashes, ObservationStore } from "./observation-store.js";
|
|
22
22
|
import { classifySensitive } from "./security.js";
|
|
23
|
-
import {
|
|
24
|
-
import "./types.js";
|
|
25
|
-
import { OBSERVATION_TYPES } from "./types.js";
|
|
23
|
+
import { SessionIndexer } from "./session-indexer.js";
|
|
24
|
+
import { OBSERVATION_TYPES, } from "./types.js";
|
|
26
25
|
// ─── Prompts (captured/adapted from pi-hermes-memory + pi-memory) ───
|
|
27
26
|
export const MEMORY_POLICY_PROMPT = `<memory-policy>
|
|
28
27
|
Persistent memory is available through memory tools. Do not assume memory has already been loaded into the prompt.
|
|
@@ -119,12 +118,7 @@ const CORRECTION_STRONG_PATTERNS = [
|
|
|
119
118
|
/^please don'?t/i,
|
|
120
119
|
/^that'?s not what I/i,
|
|
121
120
|
];
|
|
122
|
-
const CORRECTION_WEAK_PATTERNS = [
|
|
123
|
-
/^no[,\.\s!]/i,
|
|
124
|
-
/^wrong[,\.\s!]/i,
|
|
125
|
-
/^actually[,\.\s]/i,
|
|
126
|
-
/^stop[,\.\s!]/i,
|
|
127
|
-
];
|
|
121
|
+
const CORRECTION_WEAK_PATTERNS = [/^no[,.\s!]/i, /^wrong[,.\s!]/i, /^actually[,.\s]/i, /^stop[,.\s!]/i];
|
|
128
122
|
const CORRECTION_NEGATIVE_PATTERNS = [
|
|
129
123
|
/^no worries/i,
|
|
130
124
|
/^no problem/i,
|
|
@@ -134,9 +128,29 @@ const CORRECTION_NEGATIVE_PATTERNS = [
|
|
|
134
128
|
/^stop.{0,5}(there|here|for now)/i,
|
|
135
129
|
];
|
|
136
130
|
const CORRECTION_DIRECTIVE_WORDS = [
|
|
137
|
-
"use",
|
|
138
|
-
"
|
|
139
|
-
"
|
|
131
|
+
"use",
|
|
132
|
+
"don't",
|
|
133
|
+
"dont",
|
|
134
|
+
"do",
|
|
135
|
+
"try",
|
|
136
|
+
"make",
|
|
137
|
+
"run",
|
|
138
|
+
"install",
|
|
139
|
+
"add",
|
|
140
|
+
"remove",
|
|
141
|
+
"delete",
|
|
142
|
+
"change",
|
|
143
|
+
"fix",
|
|
144
|
+
"put",
|
|
145
|
+
"set",
|
|
146
|
+
"write",
|
|
147
|
+
"go",
|
|
148
|
+
"stop",
|
|
149
|
+
"start",
|
|
150
|
+
"the",
|
|
151
|
+
"that",
|
|
152
|
+
"this",
|
|
153
|
+
"it",
|
|
140
154
|
];
|
|
141
155
|
function escapeRegexLiteral(value) {
|
|
142
156
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -185,7 +199,6 @@ export class MemoryEngine {
|
|
|
185
199
|
_userTurns = 0;
|
|
186
200
|
_pendingCorrection = false;
|
|
187
201
|
_turnsSinceCorrection = 3;
|
|
188
|
-
_lastReviewAt = 0;
|
|
189
202
|
_consolidationLocks = new Set();
|
|
190
203
|
currentSessionId = "";
|
|
191
204
|
auditLog = null;
|
|
@@ -198,7 +211,12 @@ export class MemoryEngine {
|
|
|
198
211
|
this.stores = {
|
|
199
212
|
global: new ObservationStore({ rootDir: this.rootDir, projectHash: null, charLimit: 5000, target: "global" }),
|
|
200
213
|
user: new ObservationStore({ rootDir: this.rootDir, projectHash: null, charLimit: 5000, target: "user" }),
|
|
201
|
-
failure: new ObservationStore({
|
|
214
|
+
failure: new ObservationStore({
|
|
215
|
+
rootDir: this.rootDir,
|
|
216
|
+
projectHash: null,
|
|
217
|
+
charLimit: 10000,
|
|
218
|
+
target: "failure",
|
|
219
|
+
}),
|
|
202
220
|
project: null,
|
|
203
221
|
};
|
|
204
222
|
this.sessionIndexer = new SessionIndexer({
|
|
@@ -245,16 +263,36 @@ export class MemoryEngine {
|
|
|
245
263
|
await this.auditLog.load();
|
|
246
264
|
}
|
|
247
265
|
const limits = this.config.charLimits;
|
|
248
|
-
this.stores.global = new ObservationStore({
|
|
249
|
-
|
|
250
|
-
|
|
266
|
+
this.stores.global = new ObservationStore({
|
|
267
|
+
rootDir: this.rootDir,
|
|
268
|
+
projectHash: null,
|
|
269
|
+
charLimit: limits.global,
|
|
270
|
+
target: "global",
|
|
271
|
+
});
|
|
272
|
+
this.stores.user = new ObservationStore({
|
|
273
|
+
rootDir: this.rootDir,
|
|
274
|
+
projectHash: null,
|
|
275
|
+
charLimit: limits.user,
|
|
276
|
+
target: "user",
|
|
277
|
+
});
|
|
278
|
+
this.stores.failure = new ObservationStore({
|
|
279
|
+
rootDir: this.rootDir,
|
|
280
|
+
projectHash: null,
|
|
281
|
+
charLimit: limits.failure,
|
|
282
|
+
target: "failure",
|
|
283
|
+
});
|
|
251
284
|
await Promise.all([
|
|
252
285
|
this.stores.global.loadFromDisk(),
|
|
253
286
|
this.stores.user.loadFromDisk(),
|
|
254
287
|
this.stores.failure.loadFromDisk(),
|
|
255
288
|
]);
|
|
256
289
|
if (this.projectHash) {
|
|
257
|
-
this.stores.project = new ObservationStore({
|
|
290
|
+
this.stores.project = new ObservationStore({
|
|
291
|
+
rootDir: this.rootDir,
|
|
292
|
+
projectHash: this.projectHash,
|
|
293
|
+
charLimit: limits.project,
|
|
294
|
+
target: "project",
|
|
295
|
+
});
|
|
258
296
|
await this.stores.project.loadFromDisk();
|
|
259
297
|
await this.migrateLegacyProjectMemory();
|
|
260
298
|
}
|
|
@@ -302,14 +340,28 @@ export class MemoryEngine {
|
|
|
302
340
|
project: this.projectHash,
|
|
303
341
|
lastReferenced: new Date().toISOString().split("T")[0],
|
|
304
342
|
});
|
|
305
|
-
await this.audit({
|
|
343
|
+
await this.audit({
|
|
344
|
+
action: "migrate",
|
|
345
|
+
source: "auto",
|
|
346
|
+
target: "project",
|
|
347
|
+
scope: this.projectHash ?? "global",
|
|
348
|
+
ok: true,
|
|
349
|
+
});
|
|
306
350
|
}
|
|
307
351
|
}
|
|
308
352
|
// ─── Accessors ───
|
|
309
|
-
get globalStore() {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
get
|
|
353
|
+
get globalStore() {
|
|
354
|
+
return this.stores.global;
|
|
355
|
+
}
|
|
356
|
+
get userStore() {
|
|
357
|
+
return this.stores.user;
|
|
358
|
+
}
|
|
359
|
+
get failureStore() {
|
|
360
|
+
return this.stores.failure;
|
|
361
|
+
}
|
|
362
|
+
get projectStore() {
|
|
363
|
+
return this.stores.project;
|
|
364
|
+
}
|
|
313
365
|
getStore(target) {
|
|
314
366
|
if (target === "global")
|
|
315
367
|
return this.stores.global;
|
|
@@ -386,7 +438,8 @@ export class MemoryEngine {
|
|
|
386
438
|
};
|
|
387
439
|
}
|
|
388
440
|
const result = await store.add(input.content, {
|
|
389
|
-
type: input.type ??
|
|
441
|
+
type: input.type ??
|
|
442
|
+
(input.target === "user" ? "user-info" : input.target === "failure" ? "failure" : "discovery"),
|
|
390
443
|
project: this.projectHash,
|
|
391
444
|
});
|
|
392
445
|
if (result.success) {
|
|
@@ -430,7 +483,13 @@ export class MemoryEngine {
|
|
|
430
483
|
const result = await store.replace(oldText, content, { type });
|
|
431
484
|
if (result.success) {
|
|
432
485
|
this.upsertObservationIndex(target, store);
|
|
433
|
-
await this.audit({
|
|
486
|
+
await this.audit({
|
|
487
|
+
action: "replace",
|
|
488
|
+
source: "agent",
|
|
489
|
+
target,
|
|
490
|
+
scope: this.projectHash ?? "global",
|
|
491
|
+
ok: true,
|
|
492
|
+
});
|
|
434
493
|
}
|
|
435
494
|
return result;
|
|
436
495
|
}
|
|
@@ -501,7 +560,12 @@ export class MemoryEngine {
|
|
|
501
560
|
}
|
|
502
561
|
upsertObservationIndex(target, store) {
|
|
503
562
|
for (const entry of store.getRawEntries()) {
|
|
504
|
-
this.memoriesIndex.upsert(`${target}:${entry.id}`, entry.text, {
|
|
563
|
+
this.memoriesIndex.upsert(`${target}:${entry.id}`, entry.text, {
|
|
564
|
+
target,
|
|
565
|
+
type: entry.type,
|
|
566
|
+
created: entry.created,
|
|
567
|
+
project: entry.project,
|
|
568
|
+
});
|
|
505
569
|
}
|
|
506
570
|
}
|
|
507
571
|
searchMemories(query) {
|
|
@@ -579,7 +643,7 @@ export class MemoryEngine {
|
|
|
579
643
|
return this.buildPromptContext();
|
|
580
644
|
}
|
|
581
645
|
/** Build the memory context block (policy mode by default). */
|
|
582
|
-
buildPromptContext(
|
|
646
|
+
buildPromptContext(_prompt) {
|
|
583
647
|
if (!this.config.enabled)
|
|
584
648
|
return "";
|
|
585
649
|
if (this.config.mode === "policy") {
|
|
@@ -603,11 +667,13 @@ export class MemoryEngine {
|
|
|
603
667
|
}
|
|
604
668
|
push(this.stores.user.formatForSystemPrompt("USER PROFILE (who the user is)"));
|
|
605
669
|
push(this.stores.global.formatForSystemPrompt("MEMORY (your personal notes)"));
|
|
606
|
-
const recentFailures = this.failureStore
|
|
670
|
+
const recentFailures = this.failureStore
|
|
671
|
+
.getEntries()
|
|
607
672
|
.filter((e) => e.type === "failure" || e.type === "correction")
|
|
608
673
|
.slice(-this.config.failureInjectMaxEntries);
|
|
609
674
|
if (recentFailures.length > 0) {
|
|
610
|
-
const block = `═`.repeat(46) +
|
|
675
|
+
const block = `═`.repeat(46) +
|
|
676
|
+
`\nRECENT FAILURES & LESSONS (learn from these):\n` +
|
|
611
677
|
recentFailures.map((e) => `• [${e.type}] ${e.text}`).join("\n");
|
|
612
678
|
push(this.fence(block));
|
|
613
679
|
}
|
|
@@ -736,16 +802,21 @@ export class MemoryEngine {
|
|
|
736
802
|
if (!this.deps.complete)
|
|
737
803
|
return;
|
|
738
804
|
const assistantText = extractMessageText(turn.message?.content);
|
|
739
|
-
const currentMemory = this.stores.global
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
805
|
+
const currentMemory = this.stores.global
|
|
806
|
+
.getEntries()
|
|
807
|
+
.map((e) => e.text)
|
|
808
|
+
.join(ENTRY_DELIMITER) || "(empty)";
|
|
809
|
+
const currentUser = this.stores.user
|
|
810
|
+
.getEntries()
|
|
811
|
+
.map((e) => e.text)
|
|
812
|
+
.join(ENTRY_DELIMITER) || "(empty)";
|
|
813
|
+
const currentProject = this.stores.project
|
|
814
|
+
? this.stores.project
|
|
815
|
+
.getEntries()
|
|
816
|
+
.map((e) => e.text)
|
|
817
|
+
.join(ENTRY_DELIMITER) || "(empty)"
|
|
818
|
+
: null;
|
|
819
|
+
const sections = ["--- Current Memory ---", currentMemory, "", "--- Current User Profile ---", currentUser];
|
|
749
820
|
if (currentProject !== null) {
|
|
750
821
|
sections.push("", "--- Current Project Memory ---", currentProject);
|
|
751
822
|
}
|
|
@@ -768,13 +839,18 @@ export class MemoryEngine {
|
|
|
768
839
|
// Always record the correction as a failure entry (fast, no LLM).
|
|
769
840
|
const userText = extractMessageText(turn.message?.content);
|
|
770
841
|
if (userText) {
|
|
771
|
-
await this.stores.failure
|
|
842
|
+
await this.stores.failure
|
|
843
|
+
.add(`[correction] ${userText.slice(0, 300)}`, {
|
|
772
844
|
type: "correction",
|
|
773
845
|
project: this.projectHash,
|
|
774
|
-
})
|
|
846
|
+
})
|
|
847
|
+
.catch(() => ({ success: false }));
|
|
775
848
|
}
|
|
776
849
|
if (this.deps.complete) {
|
|
777
|
-
const currentUser = this.stores.user
|
|
850
|
+
const currentUser = this.stores.user
|
|
851
|
+
.getEntries()
|
|
852
|
+
.map((e) => e.text)
|
|
853
|
+
.join(ENTRY_DELIMITER) || "(empty)";
|
|
778
854
|
try {
|
|
779
855
|
const output = await this.deps.complete(CORRECTION_SYSTEM_PROMPT, `--- Current User Profile ---\n${currentUser}\n\n--- Latest User Message ---\n${userText ?? ""}`);
|
|
780
856
|
const operations = parseOperations(output);
|
|
@@ -793,8 +869,16 @@ export class MemoryEngine {
|
|
|
793
869
|
if (!this.config.enabled || !this.deps.complete)
|
|
794
870
|
return;
|
|
795
871
|
try {
|
|
796
|
-
const currentUser = this.stores.user
|
|
797
|
-
|
|
872
|
+
const currentUser = this.stores.user
|
|
873
|
+
.getEntries()
|
|
874
|
+
.map((e) => e.text)
|
|
875
|
+
.join(ENTRY_DELIMITER) || "(empty)";
|
|
876
|
+
const currentProject = this.stores.project
|
|
877
|
+
? this.stores.project
|
|
878
|
+
.getEntries()
|
|
879
|
+
.map((e) => e.text)
|
|
880
|
+
.join(ENTRY_DELIMITER) || "(empty)"
|
|
881
|
+
: null;
|
|
798
882
|
const sections = [
|
|
799
883
|
"--- Current User Profile ---",
|
|
800
884
|
currentUser,
|
|
@@ -808,7 +892,13 @@ export class MemoryEngine {
|
|
|
808
892
|
const operations = parseOperations(output);
|
|
809
893
|
if (operations.length > 0) {
|
|
810
894
|
const result = await this.applyOperations(operations);
|
|
811
|
-
await this.audit({
|
|
895
|
+
await this.audit({
|
|
896
|
+
action: "flush",
|
|
897
|
+
source: "auto",
|
|
898
|
+
target: "project",
|
|
899
|
+
scope: this.projectHash ?? "global",
|
|
900
|
+
ok: result.applied > 0,
|
|
901
|
+
});
|
|
812
902
|
}
|
|
813
903
|
}
|
|
814
904
|
catch {
|
|
@@ -851,10 +941,18 @@ export class MemoryEngine {
|
|
|
851
941
|
await store.remove(op.old_text ?? "").catch(() => ({ success: false }));
|
|
852
942
|
}
|
|
853
943
|
for (const op of adds) {
|
|
854
|
-
await store
|
|
944
|
+
await store
|
|
945
|
+
.add(op.content ?? "", { type: op.type, project: this.projectHash })
|
|
946
|
+
.catch(() => ({ success: false }));
|
|
855
947
|
}
|
|
856
948
|
await this.rebuildMemoriesIndex();
|
|
857
|
-
await this.audit({
|
|
949
|
+
await this.audit({
|
|
950
|
+
action: "consolidate",
|
|
951
|
+
source: "auto",
|
|
952
|
+
target,
|
|
953
|
+
scope: this.projectHash ?? "global",
|
|
954
|
+
ok: true,
|
|
955
|
+
});
|
|
858
956
|
return { consolidated: true };
|
|
859
957
|
}
|
|
860
958
|
catch (error) {
|