@causyne/agent 1.20.124 → 1.20.128
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/bin/causyne.js +1 -1
- package/docs/THIRD_PARTY_NOTICES.md +36 -2
- package/package.json +6 -4
- package/src/acp/protocol.ts +19 -1
- package/src/acp/server.js +282 -8
- package/src/acp/server.ts +284 -8
- package/src/agent/abortableDelay.js +2 -2
- package/src/agent/abortableDelay.ts +2 -2
- package/src/agent/errorClassifier.js +9 -1
- package/src/agent/errorClassifier.ts +8 -1
- package/src/agentLoop.js +142 -53
- package/src/agentLoop.ts +151 -50
- package/src/approvalPolicy.js +34 -10
- package/src/approvalPolicy.ts +42 -11
- package/src/browser/causyneBrowser.js +61 -3
- package/src/browser/causyneBrowser.ts +65 -3
- package/src/browser/urlPolicy.js +14 -1
- package/src/browser/urlPolicy.ts +12 -1
- package/src/cliMode.js +21 -9
- package/src/cliMode.ts +20 -8
- package/src/commands.js +365 -45
- package/src/commands.ts +403 -45
- package/src/config.js +19 -4
- package/src/config.ts +18 -4
- package/src/core/contextCompactor.js +54 -7
- package/src/core/contextCompactor.ts +63 -7
- package/src/core/goalLoop.js +257 -0
- package/src/core/goalLoop.ts +310 -0
- package/src/entrypoint.js +135 -3
- package/src/entrypoint.ts +136 -3
- package/src/game/causyneCoreBridge.js +686 -0
- package/src/game/causyneCoreBridge.ts +702 -0
- package/src/game/gameLauncher.js +287 -0
- package/src/game/gameLauncher.ts +352 -0
- package/src/game/gameProvisioner.js +425 -0
- package/src/game/gameProvisioner.ts +488 -0
- package/src/headlessCli.js +19 -12
- package/src/headlessCli.ts +22 -8
- package/src/infra/atomicWriter.js +40 -4
- package/src/infra/atomicWriter.ts +36 -4
- package/src/launchIntent.js +73 -3
- package/src/launchIntent.ts +76 -3
- package/src/lsp/lspClient.js +83 -12
- package/src/lsp/lspClient.ts +75 -12
- package/src/mcp/mcpRegistry.js +75 -8
- package/src/mcp/mcpRegistry.ts +70 -7
- package/src/memory/contextBudget.js +2 -0
- package/src/memory/contextBudget.ts +1 -0
- package/src/memory/episodicStore.js +40 -0
- package/src/memory/episodicStore.ts +46 -0
- package/src/memory.js +67 -0
- package/src/memory.ts +65 -0
- package/src/modelVariants.js +45 -0
- package/src/modelVariants.ts +54 -0
- package/src/outputRecovery.js +3 -2
- package/src/outputRecovery.ts +4 -2
- package/src/permissionPresets.js +327 -0
- package/src/permissionPresets.ts +361 -0
- package/src/personalization.js +365 -0
- package/src/personalization.ts +471 -0
- package/src/projectInstructions.js +30 -10
- package/src/projectInstructions.ts +31 -12
- package/src/providers/acp.js +3 -2
- package/src/providers/acp.ts +3 -2
- package/src/providers/antigravity.js +64 -9
- package/src/providers/antigravity.ts +75 -9
- package/src/providers/byokHttp.js +7 -1
- package/src/providers/byokHttp.ts +6 -1
- package/src/providers/byokStream.js +21 -8
- package/src/providers/byokStream.ts +17 -7
- package/src/providers/dashscope-byok.js +21 -5
- package/src/providers/dashscope-byok.ts +29 -11
- package/src/providers/moonshot.js +26 -7
- package/src/providers/moonshot.ts +34 -13
- package/src/providers/muse.js +6 -0
- package/src/providers/muse.ts +8 -0
- package/src/providers/ollama.js +39 -7
- package/src/providers/ollama.ts +36 -7
- package/src/providers/openai-compatible.js +16 -3
- package/src/providers/openai-compatible.ts +13 -3
- package/src/providers/openai.js +62 -4
- package/src/providers/openai.ts +50 -4
- package/src/providers/openrouter.js +19 -4
- package/src/providers/openrouter.ts +21 -4
- package/src/providers/qwen-byok.js +21 -5
- package/src/providers/qwen-byok.ts +29 -11
- package/src/providers/xai.js +26 -10
- package/src/providers/xai.ts +34 -16
- package/src/reporting.js +4 -2
- package/src/reporting.ts +4 -2
- package/src/sandbox.js +34 -0
- package/src/sandbox.ts +43 -0
- package/src/scheduler/scheduler.js +372 -0
- package/src/scheduler/scheduler.ts +433 -0
- package/src/sessionSearchIndex.js +267 -0
- package/src/sessionSearchIndex.ts +311 -0
- package/src/skillsManager.js +2 -3
- package/src/skillsManager.ts +2 -3
- package/src/toolPacks.js +6 -0
- package/src/toolPacks.ts +6 -0
- package/src/tools/applyPatch.js +1 -1
- package/src/tools/applyPatch.ts +1 -1
- package/src/tools/generateMediaViaApi.js +4 -3
- package/src/tools/generateMediaViaApi.ts +4 -3
- package/src/tools/memoryWrite.js +15 -1
- package/src/tools/memoryWrite.ts +16 -1
- package/src/tools/nativeEngine.js +2 -2
- package/src/tools/nativeEngine.ts +2 -2
- package/src/tools/openSourceToolProvisioner.js +2 -2
- package/src/tools/openSourceToolProvisioner.ts +2 -2
- package/src/tools/osSandbox.js +1 -1
- package/src/tools/osSandbox.ts +1 -1
- package/src/tools/payloadSanitizer.js +0 -1
- package/src/tools/payloadSanitizer.ts +0 -1
- package/src/tools/pdfReader.js +122 -20
- package/src/tools/pdfReader.ts +111 -20
- package/src/tools/presentDeliverable.js +103 -0
- package/src/tools/presentDeliverable.ts +127 -0
- package/src/tools/ptcRuntime.js +444 -0
- package/src/tools/ptcRuntime.ts +490 -0
- package/src/tools/ptyTerminal.js +1108 -0
- package/src/tools/ptyTerminal.ts +1245 -0
- package/src/tools/registry.js +21 -12
- package/src/tools/registry.ts +21 -12
- package/src/tools/toolOutputStore.js +26 -4
- package/src/tools/toolOutputStore.ts +22 -4
- package/src/tools/webFetch.js +158 -11
- package/src/tools/webFetch.ts +145 -11
- package/src/tools/webSearch.js +123 -36
- package/src/tools/webSearch.ts +124 -33
- package/src/tui/banner.js +5 -1
- package/src/tui/banner.ts +6 -1
- package/src/tui/chatRenderer.js +1 -2
- package/src/tui/chatRenderer.ts +1 -2
- package/src/tui/completion.js +1 -0
- package/src/tui/completion.ts +1 -0
- package/src/tui/composerControls.js +111 -27
- package/src/tui/composerControls.ts +124 -28
- package/src/tui/dialogs.js +3 -16
- package/src/tui/dialogs.ts +3 -16
- package/src/tui/home.js +1 -0
- package/src/tui/home.ts +1 -0
- package/src/tui/invocation.js +1 -2
- package/src/tui/invocation.ts +1 -2
- package/src/tui/modelPicker.js +22 -12
- package/src/tui/modelPicker.ts +22 -12
- package/src/tui/overlay.js +2 -5
- package/src/tui/overlay.ts +2 -5
- package/src/tui/prompt.js +6 -4
- package/src/tui/prompt.ts +6 -4
- package/src/tui/selectList.js +4 -12
- package/src/tui/selectList.ts +4 -12
- package/src/tui/setup.js +22 -9
- package/src/tui/setup.ts +26 -9
- package/src/tui/statusLine.ts +2 -0
- package/src/web/client/browserPanel.js +905 -0
- package/src/web/client/browserPanel.ts +872 -0
- package/src/web/client/chatStream.js +321 -0
- package/src/web/client/chatStream.ts +297 -0
- package/src/web/client/cliPanel.js +165 -0
- package/src/web/client/cliPanel.ts +171 -0
- package/src/web/client/composer.js +204 -0
- package/src/web/client/composer.ts +209 -0
- package/src/web/client/diffPanel.js +176 -0
- package/src/web/client/diffPanel.ts +203 -0
- package/src/web/client/dom.js +271 -0
- package/src/web/client/dom.ts +272 -0
- package/src/web/client/filesAndCanvas.js +233 -0
- package/src/web/client/filesAndCanvas.ts +240 -0
- package/src/web/client/gameLauncherUi.js +78 -0
- package/src/web/client/gameLauncherUi.ts +78 -0
- package/src/web/client/main.js +316 -0
- package/src/web/client/main.ts +391 -0
- package/src/web/client/markdown.js +364 -0
- package/src/web/client/markdown.ts +373 -0
- package/src/web/client/modelPicker.js +455 -0
- package/src/web/client/modelPicker.ts +451 -0
- package/src/web/client/permissionPresetsUi.js +307 -0
- package/src/web/client/permissionPresetsUi.ts +333 -0
- package/src/web/client/sessions.js +353 -0
- package/src/web/client/sessions.ts +372 -0
- package/src/web/client/settingsModal.js +824 -0
- package/src/web/client/settingsModal.ts +959 -0
- package/src/web/client/state.js +280 -0
- package/src/web/client/state.ts +259 -0
- package/src/web/client/streamSmoother.js +127 -0
- package/src/web/client/streamSmoother.ts +119 -0
- package/src/web/client/studioLayout.js +89 -0
- package/src/web/client/studioLayout.ts +103 -0
- package/src/web/client/studioShell.js +660 -0
- package/src/web/client/studioShell.ts +672 -0
- package/src/web/client/studioStart.js +77 -0
- package/src/web/client/studioStart.ts +89 -0
- package/src/web/client/terminalPanel.js +606 -0
- package/src/web/client/terminalPanel.ts +632 -0
- package/src/web/client/terminalTheme.js +249 -0
- package/src/web/client/terminalTheme.ts +258 -0
- package/src/web/client/turnView.js +934 -0
- package/src/web/client/turnView.ts +981 -0
- package/src/web/client/types.js +1 -0
- package/src/web/client/types.ts +322 -0
- package/src/web/client/validators.js +147 -0
- package/src/web/client/validators.ts +140 -0
- package/src/web/server/activeRuns.js +152 -0
- package/src/web/server/activeRuns.ts +171 -0
- package/src/web/server/routesBrowser.js +409 -0
- package/src/web/server/routesBrowser.ts +435 -0
- package/src/web/server/routesChat.js +304 -0
- package/src/web/server/routesChat.ts +347 -0
- package/src/web/server/routesCore.js +472 -0
- package/src/web/server/routesCore.ts +522 -0
- package/src/web/server/routesSettings.js +344 -0
- package/src/web/server/routesSettings.ts +397 -0
- package/src/web/server/routesTerminal.js +162 -0
- package/src/web/server/routesTerminal.ts +182 -0
- package/src/web/server/routesWorkspace.js +510 -0
- package/src/web/server/routesWorkspace.ts +546 -0
- package/src/web/server/security.js +98 -0
- package/src/web/server/security.ts +108 -0
- package/src/web/server/sessionTranscript.js +586 -0
- package/src/web/server/sessionTranscript.ts +566 -0
- package/src/web/server/staticAssets.js +104 -0
- package/src/web/server/staticAssets.ts +116 -0
- package/src/web/server/types.js +1 -0
- package/src/web/server/types.ts +135 -0
- package/src/web/server/workspaceFiles.js +368 -0
- package/src/web/server/workspaceFiles.ts +363 -0
- package/src/web/skybridgeServer.js +78 -2448
- package/src/web/skybridgeServer.ts +120 -2600
- package/src/web/skybridgeUi.js +20 -450
- package/src/web/skybridgeUi.ts +24 -455
- package/src/web/styles/agent.css +380 -0
- package/src/web/styles/composer.css +193 -0
- package/src/web/styles/overlays.css +935 -0
- package/src/web/styles/shell.css +387 -0
- package/src/web/styles/studio.css +951 -0
- package/src/web/styles/thread.css +221 -0
- package/src/web/styles/tokens.css +94 -0
- package/src/web/ui/brandMark.js +73 -0
- package/src/web/ui/brandMark.ts +82 -0
- package/src/web/ui/modalsTemplate.js +388 -0
- package/src/web/ui/modalsTemplate.ts +388 -0
- package/src/web/ui/sidebarTemplate.js +63 -0
- package/src/web/ui/sidebarTemplate.ts +64 -0
- package/src/web/ui/studioTemplate.js +256 -0
- package/src/web/ui/studioTemplate.ts +256 -0
- package/src/web/ui/workspaceTemplate.js +72 -0
- package/src/web/ui/workspaceTemplate.ts +73 -0
- package/src/worktreeManager.js +16 -1
- package/src/worktreeManager.ts +22 -1
- package/src/web/skybridgeClientScript.js +0 -3951
- package/src/web/skybridgeClientScript.ts +0 -3952
- package/src/web/skybridgeStyles.js +0 -827
- package/src/web/skybridgeStyles.ts +0 -828
package/src/commands.js
CHANGED
|
@@ -15,6 +15,7 @@ import { readCompiledSkill, listCompiledSkills, invalidateUserSkills, userSkillP
|
|
|
15
15
|
import { userSkillsRoot, parseSkillId, writeUserSkill, deleteUserSkill, skillTemplate } from './userSkills.js';
|
|
16
16
|
import { buildContextText, buildUsageText, buildCheckpointsText, buildUndoText, buildStatusText } from './reporting.js';
|
|
17
17
|
import { loadConfig, saveConfig } from './config.js';
|
|
18
|
+
import { getDefaultPermissionPreset, getPermissionPresetDescriptor, normalizePermissionPreset, setDefaultPermissionPreset } from './permissionPresets.js';
|
|
18
19
|
import { resolveAvailableModels, getCuratedModels, getLiveAntigravityModels, getModelVariantsForPeer, getAvailableProvidersOverview, resolveAvailableProvidersOverview, pickDefaultPeerModel } from './dynamicCatalogue.js';
|
|
19
20
|
import { DEFAULT_MODEL_BY_PROVIDER, PEER_MODEL_CATALOGUE } from './modelCatalogue.js';
|
|
20
21
|
import { isAcpProvider } from './providers/acp.js';
|
|
@@ -57,10 +58,13 @@ import { collectWorkingTreeDiff, renderDiffReview } from './diffReview.js';
|
|
|
57
58
|
import { fetchFailedCiLogs, formatPrStatusReport, inspectPrStatus, preparePrDraft } from './prWorkflow.js';
|
|
58
59
|
import { formatEvalScorecard, runCodingEvalSuite } from './benchmarks/codingEval.js';
|
|
59
60
|
import { formatProjectRulesReport } from './projectInstructions.js';
|
|
61
|
+
import { deleteCausyneMemories, readPersonalizationOverview, saveMemoryPreferences, savePersonalizationInstructions } from './personalization.js';
|
|
60
62
|
import { buildRepoMap } from './codebase/repoMap.js';
|
|
61
63
|
import { backgroundTaskManager } from './backgroundTasks.js';
|
|
62
64
|
import { resolveModelVariants, matchVariantOption, normalizeVariantToken } from './modelVariants.js';
|
|
63
65
|
import { launchGuiServer, getGuiServerStatus, stopGuiServer } from './web/guiLauncher.js';
|
|
66
|
+
import { launchGameStudio, getGameStudioStatus, stopGameStudio } from './game/gameLauncher.js';
|
|
67
|
+
import { defaultGameManifestUrl, installGameStudio, locateGameStudio } from './game/gameProvisioner.js';
|
|
64
68
|
export const SCOPES = ['local'];
|
|
65
69
|
function ok(output, extra = {}) {
|
|
66
70
|
return { ok: true, output, ...extra };
|
|
@@ -203,12 +207,19 @@ async function applySelectedVariant(rawChoice, spec, config, ctx = {}) {
|
|
|
203
207
|
const allowed = spec.options.map((o) => o.id).join(', ');
|
|
204
208
|
return fail(`Variant "${safeDisplay(rawChoice)}" is not supported by ${safeDisplay(spec.model || spec.provider)}.\nSupported variants: ${allowed}, auto`);
|
|
205
209
|
}
|
|
206
|
-
config.reasoningEffort = matched.id;
|
|
207
210
|
const modelChanged = Boolean(matched.targetModelId && matched.targetModelId !== config.model);
|
|
208
211
|
if (matched.targetModelId) {
|
|
209
212
|
config.model = matched.targetModelId;
|
|
210
213
|
}
|
|
214
|
+
if (spec.source === 'agy_models') {
|
|
215
|
+
delete config.reasoningEffort;
|
|
216
|
+
delete config.reasoningBudgetTokens;
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
config.reasoningEffort = matched.id;
|
|
220
|
+
}
|
|
211
221
|
saveConfig(config);
|
|
222
|
+
const displayedVariant = spec.source === 'agy_models' ? '' : matched.id;
|
|
212
223
|
let liveSynced = false;
|
|
213
224
|
if (typeof ctx.loop?.llm?.applyVariant === 'function' && !modelChanged) {
|
|
214
225
|
liveSynced = Boolean(await ctx.loop.llm.applyVariant(matched.id, matched.acpConfigId));
|
|
@@ -224,18 +235,18 @@ async function applySelectedVariant(rawChoice, spec, config, ctx = {}) {
|
|
|
224
235
|
}
|
|
225
236
|
if (ctx.prompt) {
|
|
226
237
|
if (typeof ctx.prompt.updateModel === 'function') {
|
|
227
|
-
ctx.prompt.updateModel(config.provider || spec.provider, config.model || spec.model,
|
|
238
|
+
ctx.prompt.updateModel(config.provider || spec.provider, config.model || spec.model, displayedVariant);
|
|
228
239
|
}
|
|
229
240
|
else if (ctx.prompt.renderer?.status) {
|
|
230
241
|
ctx.prompt.renderer.status.setSession({
|
|
231
242
|
provider: config.provider || spec.provider,
|
|
232
243
|
model: config.model || spec.model,
|
|
233
|
-
variant:
|
|
244
|
+
variant: displayedVariant
|
|
234
245
|
});
|
|
235
246
|
ctx.prompt.surface?.setSessionInfo?.({
|
|
236
247
|
provider: config.provider || spec.provider,
|
|
237
248
|
model: config.model || spec.model,
|
|
238
|
-
variant:
|
|
249
|
+
variant: displayedVariant
|
|
239
250
|
});
|
|
240
251
|
if (typeof ctx.prompt.scheduleDraw === 'function')
|
|
241
252
|
ctx.prompt.scheduleDraw();
|
|
@@ -501,12 +512,10 @@ export const COMMANDS = [
|
|
|
501
512
|
/**
|
|
502
513
|
* Argument suggestions, offered as the user types `/skills <prefix>`.
|
|
503
514
|
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
* filenames, so `/skills doc` reaches devops/docker-multi-stage-builds by a
|
|
509
|
-
* basename-prefix match rather than needing the domain typed first.
|
|
515
|
+
* The command owns its argument vocabulary and the prompt ranks and filters
|
|
516
|
+
* candidates using the shared fuzzy scorer, so `/skills doc` reaches
|
|
517
|
+
* `devops/docker-multi-stage-builds` by a basename-prefix match rather than
|
|
518
|
+
* requiring the domain to be typed first.
|
|
510
519
|
*
|
|
511
520
|
* Domains are offered alongside skills because `/skills devops` is a valid
|
|
512
521
|
* argument in its own right.
|
|
@@ -1229,32 +1238,66 @@ export const COMMANDS = [
|
|
|
1229
1238
|
},
|
|
1230
1239
|
{
|
|
1231
1240
|
name: 'cortex',
|
|
1232
|
-
aliases: ['memory'],
|
|
1241
|
+
aliases: ['memory', 'memories'],
|
|
1233
1242
|
scope: 'local',
|
|
1234
|
-
usage: '/cortex [status | list | search <query> | on | off | forget <id|--workspace>]',
|
|
1235
|
-
description: 'Inspect, search, toggle, or clear
|
|
1243
|
+
usage: '/cortex [status | list | search <query> | on | off | tool-assisted on|off | forget <id|--workspace|all>]',
|
|
1244
|
+
description: 'Inspect, search, toggle, or clear Causyne & Cortex persistent memory',
|
|
1236
1245
|
dialogTitle: 'Cortex Memory',
|
|
1237
1246
|
complete: () => [
|
|
1238
|
-
{ value: 'status', label: 'status', description: 'show
|
|
1247
|
+
{ value: 'status', label: 'status', description: 'show memory controls, counts, and Cortex engine status' },
|
|
1239
1248
|
{ value: 'list', label: 'list', description: 'list recent memories stored for this workspace' },
|
|
1240
1249
|
{ value: 'search', label: 'search', description: 'semantic search across stored memories' },
|
|
1241
|
-
{ value: 'on', label: 'on', description: 'enable
|
|
1242
|
-
{ value: 'off', label: 'off', description: 'disable
|
|
1243
|
-
{ value: '
|
|
1250
|
+
{ value: 'on', label: 'on', description: 'enable Causyne memories for this project (add "global" for all)' },
|
|
1251
|
+
{ value: 'off', label: 'off', description: 'disable Causyne memories for this project (add "global" for all)' },
|
|
1252
|
+
{ value: 'tool-assisted on', label: 'tool-assisted on', description: 'allow memories from MCP/web tool-assisted chats' },
|
|
1253
|
+
{ value: 'tool-assisted off', label: 'tool-assisted off', description: 'block memories from MCP/web tool-assisted chats' },
|
|
1254
|
+
{ value: 'forget --workspace', label: 'forget --workspace', description: 'clear memories for the current workspace' },
|
|
1255
|
+
{ value: 'forget all', label: 'forget all', description: 'clear all stored Causyne memories on this device' }
|
|
1244
1256
|
],
|
|
1245
1257
|
run: async (argv, ctx = {}) => {
|
|
1246
1258
|
const sub = String(argv[0] || 'status').trim().toLowerCase();
|
|
1247
1259
|
const workspace = ctx.loop?.workspaceRoot || process.cwd();
|
|
1260
|
+
const invalidateLoop = () => {
|
|
1261
|
+
if (ctx.loop && 'staticContext' in ctx.loop) {
|
|
1262
|
+
ctx.loop.staticContext = null;
|
|
1263
|
+
}
|
|
1264
|
+
};
|
|
1248
1265
|
if (sub === 'on' || sub === 'enable' || sub === 'off' || sub === 'disable') {
|
|
1249
1266
|
const enabled = sub === 'on' || sub === 'enable';
|
|
1250
|
-
const
|
|
1251
|
-
const
|
|
1252
|
-
|
|
1253
|
-
|
|
1267
|
+
const explicitScope = String(argv[1] || '').trim().toLowerCase();
|
|
1268
|
+
const scopeArg = explicitScope === 'global'
|
|
1269
|
+
? 'global'
|
|
1270
|
+
: explicitScope === 'project'
|
|
1271
|
+
? 'project'
|
|
1272
|
+
: (ctx.loop?.workspaceRoot ? 'project' : 'global');
|
|
1273
|
+
const policy = saveMemoryPreferences(workspace, scopeArg, { enabled });
|
|
1274
|
+
if (scopeArg === 'global') {
|
|
1275
|
+
const config = loadConfig();
|
|
1276
|
+
const prev = config.cortex && typeof config.cortex === 'object' ? config.cortex : {};
|
|
1277
|
+
config.cortex = { ...prev, enabled };
|
|
1278
|
+
saveConfig(config);
|
|
1279
|
+
}
|
|
1254
1280
|
if (ctx.loop) {
|
|
1255
1281
|
ctx.loop.config = loadConfig();
|
|
1256
1282
|
}
|
|
1257
|
-
|
|
1283
|
+
invalidateLoop();
|
|
1284
|
+
return ok(`Causyne & Cortex memory (${scopeArg}) is now ${policy.enabled ? 'ENABLED' : 'DISABLED'}.`, { effect: 'inline' });
|
|
1285
|
+
}
|
|
1286
|
+
if (sub === 'tool-assisted' || sub === 'tool-memory') {
|
|
1287
|
+
const toggle = String(argv[1] || '').trim().toLowerCase();
|
|
1288
|
+
const scopeArg = String(argv[2] || 'project').trim().toLowerCase() === 'global' ? 'global' : 'project';
|
|
1289
|
+
if (toggle !== 'on' && toggle !== 'off') {
|
|
1290
|
+
return fail('Usage: /memory tool-assisted on|off [project|global]');
|
|
1291
|
+
}
|
|
1292
|
+
const policy = saveMemoryPreferences(workspace, scopeArg, { allowToolAssisted: toggle === 'on' });
|
|
1293
|
+
invalidateLoop();
|
|
1294
|
+
return ok(`Tool-assisted chat memories (${scopeArg}) are now ${policy.allowToolAssisted ? 'ALLOWED' : 'BLOCKED'}.`, { effect: 'inline' });
|
|
1295
|
+
}
|
|
1296
|
+
if (sub === 'forget' && (String(argv[1] || '').trim().toLowerCase() === 'all' || String(argv[1] || '').trim().toLowerCase() === 'project')) {
|
|
1297
|
+
const delScope = String(argv[1] || '').trim().toLowerCase() === 'all' ? 'all' : 'project';
|
|
1298
|
+
const deleted = deleteCausyneMemories(workspace, delScope);
|
|
1299
|
+
invalidateLoop();
|
|
1300
|
+
return ok(`Deleted Causyne memories (${delScope}): ${deleted.factsRemoved} facts, ${deleted.observationsRemoved} observations, ${deleted.summariesRemoved} summaries removed.`);
|
|
1258
1301
|
}
|
|
1259
1302
|
const config = loadConfig();
|
|
1260
1303
|
const enabled = config.cortex?.enabled !== false;
|
|
@@ -2111,6 +2154,142 @@ export const COMMANDS = [
|
|
|
2111
2154
|
return ok(outLines.join('\n'), { effect: 'inline' });
|
|
2112
2155
|
}
|
|
2113
2156
|
},
|
|
2157
|
+
{
|
|
2158
|
+
name: 'game',
|
|
2159
|
+
aliases: ['gamestudio', 'causyne-game'],
|
|
2160
|
+
scope: 'local',
|
|
2161
|
+
usage: '/game [open | status | stop | install [--yes] | --port <n> | --no-open]',
|
|
2162
|
+
description: 'Launch, inspect, stop, or install Causyne Game (official separate AI Game Studio)',
|
|
2163
|
+
complete: () => [
|
|
2164
|
+
{ value: 'open', label: 'open', description: 'launch and open Causyne Game Studio in your browser' },
|
|
2165
|
+
{ value: 'status', label: 'status', description: 'show Causyne Game installation and running server status' },
|
|
2166
|
+
{ value: 'stop', label: 'stop', description: 'shut down the local Causyne Game server' },
|
|
2167
|
+
{ value: 'install', label: 'install', description: 'check or download Causyne Game from the release manifest' },
|
|
2168
|
+
{ value: '--no-open', label: '--no-open', description: 'start Causyne Game without automatically opening a browser tab' }
|
|
2169
|
+
],
|
|
2170
|
+
run: async (argv, ctx = {}) => {
|
|
2171
|
+
const tokens = argv.map((t) => String(t || '').trim()).filter(Boolean);
|
|
2172
|
+
const first = (tokens[0] || 'open').toLowerCase();
|
|
2173
|
+
if (first === 'status') {
|
|
2174
|
+
const located = locateGameStudio();
|
|
2175
|
+
const status = getGameStudioStatus();
|
|
2176
|
+
const lines = ['Causyne Game Studio'];
|
|
2177
|
+
if (located) {
|
|
2178
|
+
lines.push(` Installed : yes (${located.source}${located.version ? ` · v${located.version}` : ''})`);
|
|
2179
|
+
lines.push(` Location : ${safeDisplay(located.dir)}`);
|
|
2180
|
+
lines.push(` Build : ${located.hasNodeModules && located.hasStudioBuild ? 'ready' : 'incomplete (run npm ci && npm run build:studio)'}`);
|
|
2181
|
+
}
|
|
2182
|
+
else {
|
|
2183
|
+
lines.push(' Installed : no (run /game install --yes or set CAUSYNE_GAME_DIR)');
|
|
2184
|
+
}
|
|
2185
|
+
lines.push(` Manifest : ${defaultGameManifestUrl()}`);
|
|
2186
|
+
if (status.running) {
|
|
2187
|
+
lines.push(` Server : running at ${status.url} (127.0.0.1 loopback only)`);
|
|
2188
|
+
lines.push(' Control : /game stop (also stops automatically on CLI exit)');
|
|
2189
|
+
}
|
|
2190
|
+
else {
|
|
2191
|
+
lines.push(' Server : not running (run /game to launch)');
|
|
2192
|
+
}
|
|
2193
|
+
return ok(lines.join('\n'), { effect: 'inline' });
|
|
2194
|
+
}
|
|
2195
|
+
if (first === 'stop' || first === 'close' || first === 'off') {
|
|
2196
|
+
const stopped = await stopGameStudio();
|
|
2197
|
+
if (ctx.prompt) {
|
|
2198
|
+
ctx.prompt.notice = stopped ? 'Causyne Game stopped' : 'Causyne Game was not running';
|
|
2199
|
+
ctx.prompt.scheduleDraw?.();
|
|
2200
|
+
}
|
|
2201
|
+
return ok(stopped ? 'Stopped local Causyne Game Studio server.' : 'Causyne Game Studio is not currently running.', { effect: 'inline' });
|
|
2202
|
+
}
|
|
2203
|
+
if (first === 'install') {
|
|
2204
|
+
const confirm = tokens.some((tok) => tok === '--yes' || tok === '-y' || tok === '--confirm');
|
|
2205
|
+
let manifestUrl;
|
|
2206
|
+
for (let i = 1; i < tokens.length; i++) {
|
|
2207
|
+
const tok = tokens[i];
|
|
2208
|
+
if (tok === '--manifest' && i + 1 < tokens.length) {
|
|
2209
|
+
manifestUrl = tokens[++i];
|
|
2210
|
+
}
|
|
2211
|
+
else if (tok.startsWith('--manifest=')) {
|
|
2212
|
+
manifestUrl = tok.slice('--manifest='.length);
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
const res = await installGameStudio({ confirm, manifestUrl });
|
|
2216
|
+
if (res.requiresConsent) {
|
|
2217
|
+
const lines = [
|
|
2218
|
+
`Causyne Game v${res.version ?? 'latest'} is ready to install from ${safeDisplay(res.manifestUrl)}.`
|
|
2219
|
+
];
|
|
2220
|
+
if (res.license)
|
|
2221
|
+
lines.push(` License : ${safeDisplay(res.license)}`);
|
|
2222
|
+
if (res.size)
|
|
2223
|
+
lines.push(` Size : ${(res.size / (1024 * 1024)).toFixed(1)} MB (SHA-256 verified)`);
|
|
2224
|
+
lines.push(' Confirm : run /game install --yes to download and install into ~/.causyne/game/');
|
|
2225
|
+
return ok(lines.join('\n'), { effect: 'inline' });
|
|
2226
|
+
}
|
|
2227
|
+
if (!res.success) {
|
|
2228
|
+
return fail(`Causyne Game install failed: ${safeDisplay(res.error || 'unknown error')}`);
|
|
2229
|
+
}
|
|
2230
|
+
return ok(res.alreadyInstalled
|
|
2231
|
+
? `Causyne Game v${res.version ?? ''} is already installed at ${safeDisplay(res.path || '')}. Run /game to launch.`
|
|
2232
|
+
: `Installed Causyne Game v${res.version ?? ''} to ${safeDisplay(res.path || '')}. Run /game to launch.`, { effect: 'inline' });
|
|
2233
|
+
}
|
|
2234
|
+
let port = 0;
|
|
2235
|
+
let noOpen = false;
|
|
2236
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
2237
|
+
const tok = tokens[i];
|
|
2238
|
+
const lower = tok.toLowerCase();
|
|
2239
|
+
if (lower === 'open' || lower === 'start')
|
|
2240
|
+
continue;
|
|
2241
|
+
if (lower === '--no-open' || lower === '--no-browser') {
|
|
2242
|
+
noOpen = true;
|
|
2243
|
+
continue;
|
|
2244
|
+
}
|
|
2245
|
+
if (lower === '--port' && i + 1 < tokens.length) {
|
|
2246
|
+
const parsed = Number.parseInt(tokens[++i], 10);
|
|
2247
|
+
if (!Number.isInteger(parsed) || parsed < 0 || parsed > 65535) {
|
|
2248
|
+
return fail(`Invalid port "${safeDisplay(tokens[i])}". Expected 0-65535.`);
|
|
2249
|
+
}
|
|
2250
|
+
port = parsed;
|
|
2251
|
+
continue;
|
|
2252
|
+
}
|
|
2253
|
+
if (lower.startsWith('--port=')) {
|
|
2254
|
+
const rawPort = tok.slice('--port='.length);
|
|
2255
|
+
const parsed = Number.parseInt(rawPort, 10);
|
|
2256
|
+
if (!Number.isInteger(parsed) || parsed < 0 || parsed > 65535) {
|
|
2257
|
+
return fail(`Invalid port "${safeDisplay(rawPort)}". Expected 0-65535.`);
|
|
2258
|
+
}
|
|
2259
|
+
port = parsed;
|
|
2260
|
+
continue;
|
|
2261
|
+
}
|
|
2262
|
+
return fail(`Unknown /game option "${safeDisplay(tok)}". Usage: /game [open | status | stop | install [--yes] | --port <n> | --no-open]`);
|
|
2263
|
+
}
|
|
2264
|
+
let launched;
|
|
2265
|
+
try {
|
|
2266
|
+
launched = await launchGameStudio({
|
|
2267
|
+
port,
|
|
2268
|
+
openBrowser: !noOpen
|
|
2269
|
+
});
|
|
2270
|
+
}
|
|
2271
|
+
catch (error) {
|
|
2272
|
+
return fail(error instanceof Error ? error.message : String(error));
|
|
2273
|
+
}
|
|
2274
|
+
if (ctx.prompt) {
|
|
2275
|
+
ctx.prompt.notice = `Causyne Game live at ${launched.origin}`;
|
|
2276
|
+
ctx.prompt.scheduleDraw?.();
|
|
2277
|
+
}
|
|
2278
|
+
const outLines = [
|
|
2279
|
+
launched.reused
|
|
2280
|
+
? 'Causyne Game Studio is already running (127.0.0.1 loopback only):'
|
|
2281
|
+
: 'Causyne Game Studio started (127.0.0.1 loopback only · primary agent: Causyne Agent):',
|
|
2282
|
+
` Open URL : ${launched.url}${launched.copiedToClipboard ? ' (copied to clipboard)' : ''}`,
|
|
2283
|
+
` Source : ${launched.source}${launched.version ? ` (v${launched.version})` : ''} · ${safeDisplay(launched.dir)}`,
|
|
2284
|
+
` Browser : ${launched.openedBrowser ? 'Opened in your default browser' : 'Open the URL above in your browser'}`
|
|
2285
|
+
];
|
|
2286
|
+
if (launched.browserHint) {
|
|
2287
|
+
outLines.push(` Remote : ${safeDisplay(launched.browserHint)}`);
|
|
2288
|
+
}
|
|
2289
|
+
outLines.push(' Control : /game status | /game stop (auto-stops when CLI exits)');
|
|
2290
|
+
return ok(outLines.join('\n'), { effect: 'inline' });
|
|
2291
|
+
}
|
|
2292
|
+
},
|
|
2114
2293
|
{
|
|
2115
2294
|
name: 'openrouter',
|
|
2116
2295
|
aliases: ['free'],
|
|
@@ -2917,46 +3096,58 @@ export const COMMANDS = [
|
|
|
2917
3096
|
},
|
|
2918
3097
|
{
|
|
2919
3098
|
name: 'mode',
|
|
2920
|
-
aliases: ['autonomy'],
|
|
3099
|
+
aliases: ['autonomy', 'permissions', 'permission'],
|
|
2921
3100
|
scope: 'local',
|
|
2922
|
-
usage: '/mode [
|
|
2923
|
-
description: 'View or switch
|
|
2924
|
-
dialogTitle: '
|
|
3101
|
+
usage: '/mode [read-only | workspace-write | full-access]',
|
|
3102
|
+
description: 'View or switch permission preset (Read Only, Workspace Write, Full access)',
|
|
3103
|
+
dialogTitle: 'Permission Preset',
|
|
2925
3104
|
complete: () => [
|
|
2926
|
-
{ value: '
|
|
2927
|
-
{ value: '
|
|
2928
|
-
{ value: '
|
|
3105
|
+
{ value: 'read-only', label: 'Read Only', description: 'Inspect files and search without modifying workspace files' },
|
|
3106
|
+
{ value: 'workspace-write', label: 'Workspace Write', description: 'Edit files inside workspace with approval for risky actions' },
|
|
3107
|
+
{ value: 'full-access', label: 'Full access', description: 'Direct workspace edits and commands within safety guardrails' }
|
|
2929
3108
|
],
|
|
2930
3109
|
run: async (argv, ctx = {}) => {
|
|
2931
3110
|
const config = loadConfig();
|
|
2932
|
-
const
|
|
2933
|
-
if (!
|
|
3111
|
+
const rawTarget = (argv[0] || '').trim();
|
|
3112
|
+
if (!rawTarget) {
|
|
2934
3113
|
if (ctx.prompt) {
|
|
2935
3114
|
const { openModeControl } = await import('./tui/composerControls.js');
|
|
2936
3115
|
if (ctx.loop) {
|
|
2937
3116
|
openModeControl(ctx.prompt, ctx.loop);
|
|
2938
|
-
return ok('Opened
|
|
3117
|
+
return ok('Opened permission preset selector.', { effect: 'silent' });
|
|
2939
3118
|
}
|
|
2940
3119
|
}
|
|
2941
|
-
|
|
3120
|
+
const curPreset = getDefaultPermissionPreset();
|
|
3121
|
+
const curDesc = getPermissionPresetDescriptor(curPreset);
|
|
3122
|
+
return ok(`Current permission preset: ${curDesc.label} (${curPreset})\n`
|
|
3123
|
+
+ `Presets:\n`
|
|
3124
|
+
+ ` read-only Read Only — inspect and search without workspace writes\n`
|
|
3125
|
+
+ ` workspace-write Workspace Write — edits scoped to workspace with approval gates\n`
|
|
3126
|
+
+ ` full-access Full access — direct execution within safety guardrails`);
|
|
3127
|
+
}
|
|
3128
|
+
const preset = normalizePermissionPreset(rawTarget);
|
|
3129
|
+
if (!preset) {
|
|
3130
|
+
return fail(`Invalid permission preset "${rawTarget}". Choose read-only, workspace-write, or full-access.`);
|
|
2942
3131
|
}
|
|
2943
|
-
|
|
2944
|
-
|
|
3132
|
+
const desc = getPermissionPresetDescriptor(preset);
|
|
3133
|
+
setDefaultPermissionPreset(preset);
|
|
3134
|
+
config.permissionPreset = preset;
|
|
3135
|
+
config.autonomyMode = desc.autonomyMode;
|
|
3136
|
+
if (ctx.loop && typeof ctx.loop.setPermissionPreset === 'function') {
|
|
3137
|
+
ctx.loop.setPermissionPreset(preset);
|
|
2945
3138
|
}
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
if (ctx.loop && typeof ctx.loop.setAutonomyMode === 'function') {
|
|
2949
|
-
ctx.loop.setAutonomyMode(target);
|
|
3139
|
+
else if (ctx.loop && typeof ctx.loop.setAutonomyMode === 'function') {
|
|
3140
|
+
ctx.loop.setAutonomyMode(desc.autonomyMode);
|
|
2950
3141
|
}
|
|
2951
3142
|
if (ctx.prompt) {
|
|
2952
|
-
ctx.prompt.renderer?.status?.setSession?.({ autonomyMode:
|
|
2953
|
-
ctx.prompt.surface?.setSessionInfo?.({ autonomyMode:
|
|
2954
|
-
ctx.prompt.notice =
|
|
3143
|
+
ctx.prompt.renderer?.status?.setSession?.({ permissionPreset: preset, autonomyMode: desc.autonomyMode });
|
|
3144
|
+
ctx.prompt.surface?.setSessionInfo?.({ permissionPreset: preset, autonomyMode: desc.autonomyMode });
|
|
3145
|
+
ctx.prompt.notice = `${desc.label} active`;
|
|
2955
3146
|
if (ctx.prompt.scheduleDraw)
|
|
2956
3147
|
ctx.prompt.scheduleDraw();
|
|
2957
|
-
return ok(`
|
|
3148
|
+
return ok(`Permission preset switched to ${desc.label} (${preset}).`, { effect: 'inline' });
|
|
2958
3149
|
}
|
|
2959
|
-
return ok(`
|
|
3150
|
+
return ok(`Permission preset switched to ${desc.label} (${preset}).`);
|
|
2960
3151
|
}
|
|
2961
3152
|
},
|
|
2962
3153
|
{
|
|
@@ -3443,13 +3634,142 @@ export const COMMANDS = [
|
|
|
3443
3634
|
name: 'rules',
|
|
3444
3635
|
scope: 'local',
|
|
3445
3636
|
usage: '/rules',
|
|
3446
|
-
description: 'Show hierarchical project instructions loaded from CAUSYNE.md, AGENTS.md, CLAUDE.md, and .causyne/rules/',
|
|
3637
|
+
description: 'Show hierarchical project instructions loaded from .causyne/personalization.md, CAUSYNE.md, AGENTS.md, CLAUDE.md, and .causyne/rules/',
|
|
3447
3638
|
dialogTitle: 'Project Rules',
|
|
3448
3639
|
run: async (_argv, ctx = {}) => {
|
|
3449
3640
|
const ws = ctx.loop?.workspaceRoot || process.cwd();
|
|
3450
3641
|
return ok(formatProjectRulesReport(ws));
|
|
3451
3642
|
}
|
|
3452
3643
|
},
|
|
3644
|
+
{
|
|
3645
|
+
name: 'personalization',
|
|
3646
|
+
aliases: ['persona', 'instructions'],
|
|
3647
|
+
scope: 'local',
|
|
3648
|
+
usage: '/personalization [show | set <text> | append <text> | global <text> | clear [project|global] | memory on|off [global] | tool-memory on|off [global] | forget [project|all]]',
|
|
3649
|
+
description: 'Manage per-project personalization instructions (.causyne/personalization.md), global instructions, and Causyne memory controls',
|
|
3650
|
+
dialogTitle: 'Personalization',
|
|
3651
|
+
complete: () => [
|
|
3652
|
+
{ value: 'show', label: 'show', description: 'inspect project & global personalization and memory controls' },
|
|
3653
|
+
{ value: 'set ', label: 'set <text>', description: 'save per-project personalization (.causyne/personalization.md)' },
|
|
3654
|
+
{ value: 'append ', label: 'append <text>', description: 'append a directive to this project personalization' },
|
|
3655
|
+
{ value: 'global ', label: 'global <text>', description: 'save global instructions (~/.causyne/CAUSYNE.md)' },
|
|
3656
|
+
{ value: 'clear project', label: 'clear project', description: 'clear this project personalization' },
|
|
3657
|
+
{ value: 'clear global', label: 'clear global', description: 'clear global instructions' },
|
|
3658
|
+
{ value: 'memory on', label: 'memory on', description: 'enable Causyne memories for this project' },
|
|
3659
|
+
{ value: 'memory off', label: 'memory off', description: 'disable Causyne memories for this project' },
|
|
3660
|
+
{ value: 'tool-memory on', label: 'tool-memory on', description: 'allow memories from MCP/web tool-assisted chats' },
|
|
3661
|
+
{ value: 'tool-memory off', label: 'tool-memory off', description: 'disable memories from MCP/web tool-assisted chats' },
|
|
3662
|
+
{ value: 'forget project', label: 'forget project', description: 'delete stored memories for this project' },
|
|
3663
|
+
{ value: 'forget all', label: 'forget all', description: 'delete all Causyne memories on this device' }
|
|
3664
|
+
],
|
|
3665
|
+
run: async (argv, ctx = {}) => {
|
|
3666
|
+
const ws = ctx.loop?.workspaceRoot || process.cwd();
|
|
3667
|
+
const sub = String(argv[0] || 'show').toLowerCase();
|
|
3668
|
+
const invalidateLoop = () => {
|
|
3669
|
+
if (ctx.loop && 'staticContext' in ctx.loop) {
|
|
3670
|
+
ctx.loop.staticContext = null;
|
|
3671
|
+
}
|
|
3672
|
+
};
|
|
3673
|
+
const renderOverview = () => {
|
|
3674
|
+
const info = readPersonalizationOverview(ws);
|
|
3675
|
+
const lines = [
|
|
3676
|
+
'Causyne Personalization & Memory',
|
|
3677
|
+
` Workspace : ${safeDisplay(info.workspaceRoot)}`,
|
|
3678
|
+
` Project file : ${info.project.displayPath} (${info.project.exists ? `${info.project.bytes} bytes` : 'not set'})`,
|
|
3679
|
+
` Global file : ${info.global.displayPath} (${info.global.exists ? `${info.global.bytes} bytes` : 'not set'})`,
|
|
3680
|
+
` Memories : ${info.memory.enabled ? 'enabled' : 'disabled'} (source: ${info.memory.source})`,
|
|
3681
|
+
` Tool-assisted mem : ${info.memory.allowToolAssisted ? 'allowed' : 'blocked'} (MCP/web chats)`,
|
|
3682
|
+
` Stored memories : ${info.memoryStats.projectFacts} project facts (${info.memoryStats.totalFacts} total), ${info.memoryStats.projectObservations} project observations (${info.memoryStats.totalObservations} total)`
|
|
3683
|
+
];
|
|
3684
|
+
if (info.project.content.trim()) {
|
|
3685
|
+
lines.push('', 'Project Personalization (.causyne/personalization.md):', info.project.content.trim());
|
|
3686
|
+
}
|
|
3687
|
+
if (info.global.content.trim()) {
|
|
3688
|
+
lines.push('', 'Global Instructions (~/.causyne/CAUSYNE.md):', info.global.content.trim());
|
|
3689
|
+
}
|
|
3690
|
+
if (info.activeRules.length > 0) {
|
|
3691
|
+
lines.push('', `Active Instruction Files (${info.activeRules.length}):`);
|
|
3692
|
+
for (const r of info.activeRules) {
|
|
3693
|
+
lines.push(` • [${r.scope}] ${safeDisplay(r.label)} (${r.bytes} bytes)`);
|
|
3694
|
+
}
|
|
3695
|
+
}
|
|
3696
|
+
lines.push('', 'Usage: /personalization set <text> | append <text> | global <text> | clear [project|global] | memory on|off [global] | tool-memory on|off [global] | forget [project|all]');
|
|
3697
|
+
return lines.join('\n');
|
|
3698
|
+
};
|
|
3699
|
+
try {
|
|
3700
|
+
if (sub === 'show' || sub === 'status') {
|
|
3701
|
+
return ok(renderOverview());
|
|
3702
|
+
}
|
|
3703
|
+
if (sub === 'set') {
|
|
3704
|
+
const text = argv.slice(1).join(' ').trim();
|
|
3705
|
+
if (!text)
|
|
3706
|
+
return fail('Usage: /personalization set <project instructions>');
|
|
3707
|
+
const doc = savePersonalizationInstructions(ws, 'project', text);
|
|
3708
|
+
invalidateLoop();
|
|
3709
|
+
return ok(`Saved project personalization to ${doc.displayPath} (${doc.bytes} bytes). Active immediately for this workspace.`);
|
|
3710
|
+
}
|
|
3711
|
+
if (sub === 'append') {
|
|
3712
|
+
const text = argv.slice(1).join(' ').trim();
|
|
3713
|
+
if (!text)
|
|
3714
|
+
return fail('Usage: /personalization append <additional project instruction>');
|
|
3715
|
+
const existing = readPersonalizationOverview(ws).project.content.trim();
|
|
3716
|
+
const combined = existing ? `${existing}\n\n${text}` : text;
|
|
3717
|
+
const doc = savePersonalizationInstructions(ws, 'project', combined);
|
|
3718
|
+
invalidateLoop();
|
|
3719
|
+
return ok(`Updated project personalization at ${doc.displayPath} (${doc.bytes} bytes). Active immediately for this workspace.`);
|
|
3720
|
+
}
|
|
3721
|
+
if (sub === 'global') {
|
|
3722
|
+
const text = argv.slice(1).join(' ').trim();
|
|
3723
|
+
if (!text)
|
|
3724
|
+
return fail('Usage: /personalization global <global instructions>');
|
|
3725
|
+
const doc = savePersonalizationInstructions(ws, 'global', text);
|
|
3726
|
+
invalidateLoop();
|
|
3727
|
+
return ok(`Saved global instructions to ${doc.displayPath} (${doc.bytes} bytes).`);
|
|
3728
|
+
}
|
|
3729
|
+
if (sub === 'clear') {
|
|
3730
|
+
const scopeArg = String(argv[1] || 'project').toLowerCase();
|
|
3731
|
+
if (scopeArg !== 'project' && scopeArg !== 'global') {
|
|
3732
|
+
return fail('Usage: /personalization clear [project|global]');
|
|
3733
|
+
}
|
|
3734
|
+
savePersonalizationInstructions(ws, scopeArg, '');
|
|
3735
|
+
invalidateLoop();
|
|
3736
|
+
return ok(`Cleared ${scopeArg} personalization instructions.`);
|
|
3737
|
+
}
|
|
3738
|
+
if (sub === 'memory') {
|
|
3739
|
+
const toggle = String(argv[1] || '').toLowerCase();
|
|
3740
|
+
const scopeArg = String(argv[2] || 'project').toLowerCase() === 'global' ? 'global' : 'project';
|
|
3741
|
+
if (toggle !== 'on' && toggle !== 'off' && toggle !== 'inherit') {
|
|
3742
|
+
return fail('Usage: /personalization memory on|off|inherit [project|global]');
|
|
3743
|
+
}
|
|
3744
|
+
const value = toggle === 'inherit' ? null : toggle === 'on';
|
|
3745
|
+
const policy = saveMemoryPreferences(ws, scopeArg, { enabled: value });
|
|
3746
|
+
invalidateLoop();
|
|
3747
|
+
return ok(`Causyne memories (${scopeArg}): ${policy.enabled ? 'enabled' : 'disabled'} (effective source: ${policy.source}).`);
|
|
3748
|
+
}
|
|
3749
|
+
if (sub === 'tool-memory' || sub === 'tool-assisted') {
|
|
3750
|
+
const toggle = String(argv[1] || '').toLowerCase();
|
|
3751
|
+
const scopeArg = String(argv[2] || 'project').toLowerCase() === 'global' ? 'global' : 'project';
|
|
3752
|
+
if (toggle !== 'on' && toggle !== 'off' && toggle !== 'inherit') {
|
|
3753
|
+
return fail('Usage: /personalization tool-memory on|off|inherit [project|global]');
|
|
3754
|
+
}
|
|
3755
|
+
const value = toggle === 'inherit' ? null : toggle === 'on';
|
|
3756
|
+
const policy = saveMemoryPreferences(ws, scopeArg, { allowToolAssisted: value });
|
|
3757
|
+
invalidateLoop();
|
|
3758
|
+
return ok(`Tool-assisted chat memories (${scopeArg}): ${policy.allowToolAssisted ? 'allowed' : 'blocked'} (effective source: ${policy.source}).`);
|
|
3759
|
+
}
|
|
3760
|
+
if (sub === 'forget' || sub === 'delete') {
|
|
3761
|
+
const scopeArg = String(argv[1] || 'project').toLowerCase() === 'all' ? 'all' : 'project';
|
|
3762
|
+
const deleted = deleteCausyneMemories(ws, scopeArg);
|
|
3763
|
+
invalidateLoop();
|
|
3764
|
+
return ok(`Deleted Causyne memories (${scopeArg}): ${deleted.factsRemoved} facts, ${deleted.observationsRemoved} observations, ${deleted.summariesRemoved} summaries removed.`);
|
|
3765
|
+
}
|
|
3766
|
+
return fail(`Unknown /personalization action "${safeDisplay(sub)}". Try: show, set, append, global, clear, memory, tool-memory, forget.`);
|
|
3767
|
+
}
|
|
3768
|
+
catch (err) {
|
|
3769
|
+
return fail(safeDisplay(errMsg(err)));
|
|
3770
|
+
}
|
|
3771
|
+
}
|
|
3772
|
+
},
|
|
3453
3773
|
{
|
|
3454
3774
|
name: 'map',
|
|
3455
3775
|
aliases: ['repomap'],
|