@xmemo/client 0.4.156 → 0.4.158

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.
Files changed (46) hide show
  1. package/README.md +37 -7
  2. package/package.json +2 -1
  3. package/plugins/kiro/.kiro-plugin/power.json +35 -0
  4. package/plugins/kiro/CHANGELOG.md +9 -0
  5. package/plugins/kiro/LICENSE +7 -0
  6. package/plugins/kiro/POWER.md +147 -0
  7. package/plugins/kiro/README.md +31 -0
  8. package/plugins/kiro/SETUP.md +234 -0
  9. package/plugins/kiro/assets/logo.svg +27 -0
  10. package/plugins/kiro/mcp.json +7 -0
  11. package/plugins/kiro/steering/AGENTS.md +32 -0
  12. package/src/cli.js +5 -5
  13. package/src/commands/auth.js +9 -8
  14. package/src/commands/diagnostics.js +10 -9
  15. package/src/commands/mcp.js +12 -11
  16. package/src/commands/profile.js +7 -6
  17. package/src/commands/setup.js +13 -12
  18. package/src/commands/update.js +6 -5
  19. package/src/{env.js → config/env.js} +7 -6
  20. package/src/{path-config.js → config/paths.js} +2 -1
  21. package/src/{profile.js → config/profile.js} +37 -42
  22. package/src/{constants.js → core/constants.js} +5 -5
  23. package/src/core/version.js +9 -0
  24. package/src/mcp/{detect.js → clients/detect.js} +3 -2
  25. package/src/mcp/{registry.js → clients/registry.js} +2 -1
  26. package/src/mcp/clients.js +6 -5
  27. package/src/mcp/{names.js → core/names.js} +2 -1
  28. package/src/mcp/{templates.js → core/templates.js} +4 -3
  29. package/src/mcp/{json-clients.js → formats/json.js} +11 -6
  30. package/src/mcp/{codex.js → formats/toml.js} +5 -4
  31. package/src/mcp/{hermes.js → formats/yaml.js} +5 -4
  32. package/src/mcp/{identity.js → identity/device.js} +28 -12
  33. package/src/mcp/{paths.js → identity/paths.js} +1 -0
  34. package/src/mcp/{copilot-proxy.js → proxy/copilot.js} +6 -5
  35. package/src/mcp/{proxy.js → proxy/server.js} +8 -7
  36. package/src/{auth.js → network/auth.js} +5 -4
  37. package/src/{base-url.js → network/base-url.js} +3 -2
  38. package/src/{discovery.js → network/discovery.js} +5 -4
  39. package/src/{http.js → network/http.js} +3 -2
  40. package/src/{help.js → ui/help.js} +3 -2
  41. package/src/{setup.js → ui/setup.js} +9 -8
  42. package/src/version.js +0 -1
  43. /package/src/{args.js → core/args.js} +0 -0
  44. /package/src/{errors.js → core/errors.js} +0 -0
  45. /package/src/{io.js → core/io.js} +0 -0
  46. /package/src/{runtime.js → core/runtime.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { hasFlag, optionValue, parsePositiveInteger } from '../args.js';
1
+ import { hasFlag, optionValue, parsePositiveInteger } from '../core/args.js';
2
2
  import {
3
3
  formatAccount,
4
4
  pollDeviceLogin,
@@ -8,18 +8,18 @@ import {
8
8
  storeTokenFromStdin,
9
9
  storeTokenValue,
10
10
  validateToken
11
- } from '../auth.js';
12
- import { baseUrlOption } from '../base-url.js';
11
+ } from '../network/auth.js';
12
+ import { baseUrlOption } from '../network/base-url.js';
13
13
  import {
14
14
  COMMAND_NAME,
15
15
  LEGACY_TOKEN_ENV_VAR,
16
16
  PRODUCT_NAME,
17
17
  TOKEN_ENV_VAR
18
- } from '../constants.js';
19
- import { UsageError } from '../errors.js';
20
- import { normalizeBaseUrl, verifyTokenWithMcp } from '../http.js';
21
- import { writeLine } from '../io.js';
22
- import { readAll } from '../runtime.js';
18
+ } from '../core/constants.js';
19
+ import { UsageError } from '../core/errors.js';
20
+ import { normalizeBaseUrl, verifyTokenWithMcp } from '../network/http.js';
21
+ import { writeLine } from '../core/io.js';
22
+ import { readAll } from '../core/runtime.js';
23
23
 
24
24
  export async function loginCommand(args, io) {
25
25
  const outputJson = hasFlag(args, '--json');
@@ -227,3 +227,4 @@ function writeCredentialStatus(report, io, { mode }) {
227
227
  }
228
228
  writeLine(io.stdout, report.loggedIn ? 'Credential is ready; token value remains hidden.' : `Run \`${COMMAND_NAME} login\` to sign in.`);
229
229
  }
230
+
@@ -5,30 +5,30 @@ import {
5
5
  parsePositiveInteger,
6
6
  sameMajorMinor,
7
7
  stringValue
8
- } from '../args.js';
9
- import { baseUrlOption } from '../base-url.js';
8
+ } from '../core/args.js';
9
+ import { baseUrlOption } from '../network/base-url.js';
10
10
  import {
11
11
  CLI_VERSION,
12
12
  COMMAND_NAME,
13
13
  PACKAGE_NAME,
14
14
  PRODUCT_NAME
15
- } from '../constants.js';
16
- import { UsageError } from '../errors.js';
15
+ } from '../core/constants.js';
16
+ import { UsageError } from '../core/errors.js';
17
17
  import {
18
18
  agentDiscoveryClientIds,
19
19
  bestEffortRootVersion,
20
20
  discoveryMcpUrl,
21
21
  ensureDiscoveryService
22
- } from '../discovery.js';
22
+ } from '../network/discovery.js';
23
23
  import {
24
24
  endpointUrl,
25
25
  fetchJson,
26
26
  normalizeBaseUrl,
27
27
  probe
28
- } from '../http.js';
29
- import { writeLine } from '../io.js';
30
- import { codexSmokeReport } from '../mcp/codex.js';
31
- import { defaultCodexConfigPath } from '../path-config.js';
28
+ } from '../network/http.js';
29
+ import { writeLine } from '../core/io.js';
30
+ import { codexSmokeReport } from '../mcp/formats/toml.js';
31
+ import { defaultCodexConfigPath } from '../config/paths.js';
32
32
 
33
33
  export async function doctorCommand(args, io) {
34
34
  const baseUrl = normalizeBaseUrl(baseUrlOption(args, io.env));
@@ -194,3 +194,4 @@ export async function smokeCommand(args, io) {
194
194
  }
195
195
  return report.ok ? 0 : 1;
196
196
  }
197
+
@@ -1,5 +1,5 @@
1
- import { hasFlag, optionValue, parsePositiveInteger } from '../args.js';
2
- import { baseUrlOption } from '../base-url.js';
1
+ import { hasFlag, optionValue, parsePositiveInteger } from '../core/args.js';
2
+ import { baseUrlOption } from '../network/base-url.js';
3
3
  import {
4
4
  AGENT_INSTANCE_ENV_VAR,
5
5
  COMMAND_NAME,
@@ -8,30 +8,30 @@ import {
8
8
  MCP_SERVER_NAME,
9
9
  PRODUCT_NAME,
10
10
  TOKEN_ENV_VAR
11
- } from '../constants.js';
12
- import { UsageError } from '../errors.js';
13
- import { endpointUrl, normalizeBaseUrl } from '../http.js';
14
- import { writeLine } from '../io.js';
11
+ } from '../core/constants.js';
12
+ import { UsageError } from '../core/errors.js';
13
+ import { endpointUrl, normalizeBaseUrl } from '../network/http.js';
14
+ import { writeLine } from '../core/io.js';
15
15
  import {
16
16
  MCP_CLIENTS,
17
17
  supportedMcpClientIds,
18
18
  supportedMcpClients
19
19
  } from '../mcp/clients.js';
20
- import { mcpProxyCommand } from '../mcp/copilot-proxy.js';
20
+ import { mcpProxyCommand } from '../mcp/proxy/copilot.js';
21
21
  import {
22
22
  agentIdentity,
23
23
  envReferenceIdentity
24
- } from '../mcp/identity.js';
24
+ } from '../mcp/identity/device.js';
25
25
  import {
26
26
  agentInstanceGenerationPolicy,
27
27
  mcpConfigTemplate,
28
28
  mcpLocalProxyTemplate
29
- } from '../mcp/templates.js';
30
- import { usesClientOAuth } from '../mcp/registry.js';
29
+ } from '../mcp/core/templates.js';
30
+ import { usesClientOAuth } from '../mcp/clients/registry.js';
31
31
  import {
32
32
  codexMemoryProfile,
33
33
  writeCodexMemoryProfile
34
- } from '../profile.js';
34
+ } from '../config/profile.js';
35
35
 
36
36
  export async function mcpCommand(args, io) {
37
37
  const subcommand = args[0] ?? 'help';
@@ -185,3 +185,4 @@ export async function mcpCommand(args, io) {
185
185
  writeLine(io.stdout, `${AGENT_INSTANCE_ENV_VAR} must be stable per local ${client.label} install; run ${COMMAND_NAME} mcp add ${target} --write to generate it automatically.`);
186
186
  return 0;
187
187
  }
188
+
@@ -1,7 +1,7 @@
1
- import { hasFlag, optionValue } from '../args.js';
2
- import { COMMAND_NAME } from '../constants.js';
3
- import { UsageError } from '../errors.js';
4
- import { writeLine } from '../io.js';
1
+ import { hasFlag, optionValue } from '../core/args.js';
2
+ import { COMMAND_NAME } from '../core/constants.js';
3
+ import { UsageError } from '../core/errors.js';
4
+ import { writeLine } from '../core/io.js';
5
5
  import { MCP_CLIENTS } from '../mcp/clients.js';
6
6
  import {
7
7
  defaultProfileTarget,
@@ -11,8 +11,8 @@ import {
11
11
  profileUninstallResult,
12
12
  supportedProfileClientIds,
13
13
  writeProfileResult
14
- } from '../profile.js';
15
- import { normalizeSetupClientId } from '../setup.js';
14
+ } from '../config/profile.js';
15
+ import { normalizeSetupClientId } from '../ui/setup.js';
16
16
 
17
17
  export async function profileCommand(args, io) {
18
18
  const subcommand = args[0] ?? 'help';
@@ -54,3 +54,4 @@ export async function profileCommand(args, io) {
54
54
  writeProfileResult(subcommand, result, io);
55
55
  return 0;
56
56
  }
57
+
@@ -3,38 +3,38 @@ import {
3
3
  optionValue,
4
4
  parsePositiveInteger,
5
5
  stringValue
6
- } from '../args.js';
7
- import { baseUrlOption } from '../base-url.js';
6
+ } from '../core/args.js';
7
+ import { baseUrlOption } from '../network/base-url.js';
8
8
  import {
9
9
  DEFAULT_PROXY_PORT
10
- } from '../constants.js';
10
+ } from '../core/constants.js';
11
11
  import {
12
12
  buildSetupPlan,
13
13
  ensureDiscoveryService
14
- } from '../discovery.js';
15
- import { UsageError } from '../errors.js';
14
+ } from '../network/discovery.js';
15
+ import { UsageError } from '../core/errors.js';
16
16
  import {
17
17
  endpointUrl,
18
18
  fetchJson,
19
19
  normalizeBaseUrl
20
- } from '../http.js';
21
- import { writeLine } from '../io.js';
20
+ } from '../network/http.js';
21
+ import { writeLine } from '../core/io.js';
22
22
  import {
23
23
  MCP_CLIENTS,
24
24
  supportedMcpClients
25
25
  } from '../mcp/clients.js';
26
- import { mergeCopilotMcpConfig } from '../mcp/copilot-proxy.js';
27
- import { detectClient } from '../mcp/detect.js';
26
+ import { mergeCopilotMcpConfig } from '../mcp/proxy/copilot.js';
27
+ import { detectClient } from '../mcp/clients/detect.js';
28
28
  import {
29
29
  agentIdentity,
30
30
  envReferenceIdentity
31
- } from '../mcp/identity.js';
31
+ } from '../mcp/identity/device.js';
32
32
  import {
33
33
  confirmProfileInstall,
34
34
  defaultProfileTarget,
35
35
  profileClientConfig,
36
36
  profileInstallResult
37
- } from '../profile.js';
37
+ } from '../config/profile.js';
38
38
  import {
39
39
  clientSetupPlan,
40
40
  copilotSetupPlan,
@@ -42,7 +42,7 @@ import {
42
42
  positionalClientArg,
43
43
  supportedSetupClientIds,
44
44
  writeSetupSummary
45
- } from '../setup.js';
45
+ } from '../ui/setup.js';
46
46
 
47
47
  export async function setupCommand(args, io) {
48
48
  const positionalClientId = positionalClientArg(args, MCP_CLIENTS);
@@ -188,3 +188,4 @@ export async function setupCommand(args, io) {
188
188
  writeSetupSummary(setupPlan, io);
189
189
  return 0;
190
190
  }
191
+
@@ -1,14 +1,14 @@
1
- import { hasFlag } from '../args.js';
1
+ import { hasFlag } from '../core/args.js';
2
2
  import {
3
3
  COMMAND_NAME,
4
4
  PACKAGE_NAME
5
- } from '../constants.js';
6
- import { UsageError } from '../errors.js';
7
- import { writeLine } from '../io.js';
5
+ } from '../core/constants.js';
6
+ import { UsageError } from '../core/errors.js';
7
+ import { writeLine } from '../core/io.js';
8
8
  import {
9
9
  npmExecutable,
10
10
  runProcess
11
- } from '../runtime.js';
11
+ } from '../core/runtime.js';
12
12
 
13
13
  export async function updateCommand(args, io) {
14
14
  const outputJson = hasFlag(args, '--json');
@@ -55,3 +55,4 @@ export async function updateCommand(args, io) {
55
55
  }
56
56
  return 0;
57
57
  }
58
+
@@ -1,15 +1,15 @@
1
- import { hasFlag, optionValue } from './args.js';
2
- import { baseUrlOption } from './base-url.js';
1
+ import { hasFlag, optionValue } from '../core/args.js';
2
+ import { baseUrlOption } from '../network/base-url.js';
3
3
  import {
4
4
  AGENT_ID_ENV_VAR,
5
5
  AGENT_INSTANCE_ENV_VAR,
6
6
  COMMAND_NAME,
7
7
  PRODUCT_NAME,
8
8
  TOKEN_ENV_VAR
9
- } from './constants.js';
10
- import { UsageError } from './errors.js';
11
- import { normalizeBaseUrl } from './http.js';
12
- import { writeLine } from './io.js';
9
+ } from '../core/constants.js';
10
+ import { UsageError } from '../core/errors.js';
11
+ import { normalizeBaseUrl } from '../network/http.js';
12
+ import { writeLine } from '../core/io.js';
13
13
 
14
14
  export function envCommand(args, io) {
15
15
  const subcommand = args[0] ?? 'help';
@@ -79,3 +79,4 @@ export function writePrivacy(io) {
79
79
  writeLine(io.stdout, '- Legacy `token set` plaintext storage requires explicit --allow-plaintext.');
80
80
  writeLine(io.stdout, '- npm publishing is restricted by package.json files whitelist.');
81
81
  }
82
+
@@ -22,4 +22,5 @@ export {
22
22
  defaultTraeSoloConfigPath,
23
23
  defaultWindsurfConfigPath,
24
24
  defaultZedConfigPath
25
- } from './mcp/paths.js';
25
+ } from '../mcp/identity/paths.js';
26
+
@@ -4,6 +4,8 @@ import os from 'node:os';
4
4
  import path from 'node:path';
5
5
 
6
6
  import {
7
+ CLIENT_PROFILE_MARKER_END,
8
+ CLIENT_PROFILE_MARKER_START,
7
9
  CODEX_PROFILE_MARKER_END,
8
10
  CODEX_PROFILE_MARKER_START,
9
11
  CODEX_PROFILE_TARGET,
@@ -12,10 +14,10 @@ import {
12
14
  PRODUCT_NAME,
13
15
  PROFILE_MARKER_PREFIX,
14
16
  TOKEN_ENV_VAR
15
- } from './constants.js';
16
- import { UsageError } from './errors.js';
17
- import { writeLine } from './io.js';
18
- import { readTextIfExists } from './runtime.js';
17
+ } from '../core/constants.js';
18
+ import { UsageError } from '../core/errors.js';
19
+ import { writeLine } from '../core/io.js';
20
+ import { readTextIfExists } from '../core/runtime.js';
19
21
 
20
22
  export function codexMemoryProfile() {
21
23
  return memoryBehaviorProfile('codex');
@@ -51,7 +53,7 @@ function memoryBehaviorProfile(clientId) {
51
53
  'After meaningful decisions, bug fixes, release steps, or durable conventions, write a concise XMemo memory with scope, source, and no secret values.',
52
54
  'Never store tokens, API keys, cookies, private keys, raw credentials, or sensitive customer data in XMemo.',
53
55
  'For routine or low-signal output, skip durable writes. Prefer summarized procedural or semantic memories over verbose logs.',
54
- config.authInstruction
56
+ 'Keep XMemo authentication secure (using the XMEMO_KEY environment variable or client-managed OAuth); do not paste token values into prompts, config files, or logs.'
55
57
  ];
56
58
  return {
57
59
  client: clientId,
@@ -69,7 +71,7 @@ function memoryBehaviorProfile(clientId) {
69
71
  function profileInstructionText(clientId) {
70
72
  const profile = memoryBehaviorProfile(clientId);
71
73
  const lines = [
72
- `## XMemo ${profile.label} profile`,
74
+ '## XMemo Agent profile',
73
75
  '',
74
76
  `MCP server: \`${profile.mcpServerName}\``,
75
77
  ];
@@ -80,7 +82,7 @@ function profileInstructionText(clientId) {
80
82
  '',
81
83
  profile.objective,
82
84
  '',
83
- `Recommended ${profile.label} behavior:`
85
+ 'Recommended Agent behavior:'
84
86
  );
85
87
  for (const instruction of profile.instructions) {
86
88
  lines.push(`- ${instruction}`);
@@ -96,118 +98,110 @@ export function profileClientConfig(clientId) {
96
98
  setupAlias: 'codex',
97
99
  profileVersion: 'codex-mcp-depth-v1',
98
100
  requiredTokenEnv: TOKEN_ENV_VAR,
99
- markerStart: CODEX_PROFILE_MARKER_START,
100
- markerEnd: CODEX_PROFILE_MARKER_END,
101
- defaultTarget: () => defaultCodexProfileTarget(),
102
- authInstruction: `Keep XMemo authentication through the ${TOKEN_ENV_VAR} environment variable; do not paste token values into prompts, config files, or logs.`
101
+ markerStart: CLIENT_PROFILE_MARKER_START,
102
+ markerEnd: CLIENT_PROFILE_MARKER_END,
103
+ defaultTarget: () => defaultCodexProfileTarget()
103
104
  },
104
105
  cursor: {
105
106
  label: 'Cursor',
106
107
  setupAlias: 'cursor',
107
108
  profileVersion: 'cursor-mcp-depth-v1',
108
109
  requiredTokenEnv: TOKEN_ENV_VAR,
109
- markerStart: `<!-- ${PROFILE_MARKER_PREFIX}:cursor:start -->`,
110
- markerEnd: `<!-- ${PROFILE_MARKER_PREFIX}:cursor:end -->`,
110
+ markerStart: CLIENT_PROFILE_MARKER_START,
111
+ markerEnd: CLIENT_PROFILE_MARKER_END,
111
112
  defaultTarget: (env) => {
112
113
  const isTest = env.HOME && (env.HOME.includes('memory-os-') || env.HOME.includes('test'));
113
114
  if (!isTest && (existsSync(path.join(process.cwd(), '.cursor')) || existsSync(path.join(process.cwd(), '.git')) || existsSync(path.join(process.cwd(), 'package.json')))) {
114
- return path.join(process.cwd(), '.cursor', 'rules', 'xmemo-memory.md');
115
+ return path.join(process.cwd(), '.cursor', 'rules', 'AGENTS.md');
115
116
  }
116
117
  return path.join(userHome(env), '.cursor', 'memory-profile.md');
117
- },
118
- authInstruction: `Keep XMemo authentication through the ${TOKEN_ENV_VAR} environment variable; do not paste token values into prompts, config files, or logs.`
118
+ }
119
119
  },
120
120
  'gemini-cli': {
121
121
  label: 'Gemini CLI',
122
122
  setupAlias: 'gemini',
123
123
  profileVersion: 'gemini-cli-mcp-depth-v1',
124
- markerStart: `<!-- ${PROFILE_MARKER_PREFIX}:gemini-cli:start -->`,
125
- markerEnd: `<!-- ${PROFILE_MARKER_PREFIX}:gemini-cli:end -->`,
124
+ markerStart: CLIENT_PROFILE_MARKER_START,
125
+ markerEnd: CLIENT_PROFILE_MARKER_END,
126
126
  defaultTarget: (env) => {
127
127
  const isTest = env.HOME && (env.HOME.includes('memory-os-') || env.HOME.includes('test'));
128
128
  if (!isTest && (existsSync(path.join(process.cwd(), '.git')) || existsSync(path.join(process.cwd(), 'package.json')))) {
129
129
  return path.join(process.cwd(), 'GEMINI.md');
130
130
  }
131
131
  return path.join(userHome(env), '.gemini', 'GEMINI.md');
132
- },
133
- authInstruction: 'Use the client-managed MCP OAuth credential; do not paste token values into prompts, config files, or logs.'
132
+ }
134
133
  },
135
134
  antigravity: {
136
135
  label: 'Antigravity',
137
136
  setupAlias: 'antigravity',
138
137
  profileVersion: 'antigravity-mcp-depth-v1',
139
- markerStart: `<!-- ${PROFILE_MARKER_PREFIX}:antigravity:start -->`,
140
- markerEnd: `<!-- ${PROFILE_MARKER_PREFIX}:antigravity:end -->`,
138
+ markerStart: CLIENT_PROFILE_MARKER_START,
139
+ markerEnd: CLIENT_PROFILE_MARKER_END,
141
140
  defaultTarget: (env) => {
142
141
  const isTest = env.HOME && (env.HOME.includes('memory-os-') || env.HOME.includes('test'));
143
142
  if (!isTest && (existsSync(path.join(process.cwd(), '.git')) || existsSync(path.join(process.cwd(), 'package.json')))) {
144
143
  return path.join(process.cwd(), 'GEMINI.md');
145
144
  }
146
145
  return path.join(userHome(env), '.gemini', 'antigravity', 'MEMORY.md');
147
- },
148
- authInstruction: 'Use the client-managed MCP OAuth credential; do not paste token values into prompts, config files, or logs.'
146
+ }
149
147
  },
150
148
  qwen: {
151
149
  label: 'Qwen',
152
150
  setupAlias: 'qwen',
153
151
  profileVersion: 'qwen-mcp-depth-v1',
154
- markerStart: `<!-- ${PROFILE_MARKER_PREFIX}:qwen:start -->`,
155
- markerEnd: `<!-- ${PROFILE_MARKER_PREFIX}:qwen:end -->`,
152
+ markerStart: CLIENT_PROFILE_MARKER_START,
153
+ markerEnd: CLIENT_PROFILE_MARKER_END,
156
154
  defaultTarget: (env) => {
157
155
  const isTest = env.HOME && (env.HOME.includes('memory-os-') || env.HOME.includes('test'));
158
156
  if (!isTest && (existsSync(path.join(process.cwd(), '.git')) || existsSync(path.join(process.cwd(), 'package.json')))) {
159
157
  return path.join(process.cwd(), 'QWEN.md');
160
158
  }
161
159
  return path.join(userHome(env), '.qwen', 'QWEN.md');
162
- },
163
- authInstruction: `Keep XMemo authentication through the ${TOKEN_ENV_VAR} environment variable; do not paste token values into prompts, config files, or logs.`
160
+ }
164
161
  },
165
162
  opencode: {
166
163
  label: 'OpenCode',
167
164
  setupAlias: 'opencode',
168
165
  profileVersion: 'opencode-mcp-depth-v1',
169
- markerStart: `<!-- ${PROFILE_MARKER_PREFIX}:opencode:start -->`,
170
- markerEnd: `<!-- ${PROFILE_MARKER_PREFIX}:opencode:end -->`,
166
+ markerStart: CLIENT_PROFILE_MARKER_START,
167
+ markerEnd: CLIENT_PROFILE_MARKER_END,
171
168
  defaultTarget: (env) => {
172
169
  const isTest = env.HOME && (env.HOME.includes('memory-os-') || env.HOME.includes('test'));
173
170
  if (!isTest && (existsSync(path.join(process.cwd(), '.git')) || existsSync(path.join(process.cwd(), 'package.json')))) {
174
171
  return path.join(process.cwd(), 'AGENTS.md');
175
172
  }
176
173
  return path.join(userHome(env), '.config', 'opencode', 'AGENTS.md');
177
- },
178
- authInstruction: 'Use the client-managed MCP OAuth credential; do not paste token values into prompts, config files, or logs.'
174
+ }
179
175
  },
180
176
  trae: {
181
177
  label: 'Trae',
182
178
  setupAlias: 'trae',
183
179
  profileVersion: 'trae-mcp-depth-v1',
184
180
  requiredTokenEnv: TOKEN_ENV_VAR,
185
- markerStart: `<!-- ${PROFILE_MARKER_PREFIX}:trae:start -->`,
186
- markerEnd: `<!-- ${PROFILE_MARKER_PREFIX}:trae:end -->`,
181
+ markerStart: CLIENT_PROFILE_MARKER_START,
182
+ markerEnd: CLIENT_PROFILE_MARKER_END,
187
183
  defaultTarget: (env) => {
188
184
  const isTest = env.HOME && (env.HOME.includes('memory-os-') || env.HOME.includes('test'));
189
185
  if (!isTest && (existsSync(path.join(process.cwd(), '.trae')) || existsSync(path.join(process.cwd(), '.git')) || existsSync(path.join(process.cwd(), 'package.json')))) {
190
- return path.join(process.cwd(), '.trae', 'rules', 'xmemo-memory.md');
186
+ return path.join(process.cwd(), '.trae', 'rules', 'AGENTS.md');
191
187
  }
192
188
  return path.join(userHome(env), '.trae', 'memory-profile.md');
193
- },
194
- authInstruction: `Keep XMemo authentication through the ${TOKEN_ENV_VAR} environment variable; do not paste token values into prompts, config files, or logs.`
189
+ }
195
190
  },
196
191
  'trae-solo': {
197
192
  label: 'Trae Solo',
198
193
  setupAlias: 'trae-solo',
199
194
  profileVersion: 'trae-solo-mcp-depth-v1',
200
195
  requiredTokenEnv: TOKEN_ENV_VAR,
201
- markerStart: `<!-- ${PROFILE_MARKER_PREFIX}:trae-solo:start -->`,
202
- markerEnd: `<!-- ${PROFILE_MARKER_PREFIX}:trae-solo:end -->`,
196
+ markerStart: CLIENT_PROFILE_MARKER_START,
197
+ markerEnd: CLIENT_PROFILE_MARKER_END,
203
198
  defaultTarget: (env) => {
204
199
  const isTest = env.HOME && (env.HOME.includes('memory-os-') || env.HOME.includes('test'));
205
200
  if (!isTest && (existsSync(path.join(process.cwd(), '.trae')) || existsSync(path.join(process.cwd(), '.git')) || existsSync(path.join(process.cwd(), 'package.json')))) {
206
- return path.join(process.cwd(), '.trae', 'rules', 'xmemo-memory.md');
201
+ return path.join(process.cwd(), '.trae', 'rules', 'AGENTS.md');
207
202
  }
208
203
  return path.join(userHome(env), '.trae', 'memory-profile.md');
209
- },
210
- authInstruction: `Keep XMemo authentication through the ${TOKEN_ENV_VAR} environment variable; do not paste token values into prompts, config files, or logs.`
204
+ }
211
205
  }
212
206
  };
213
207
  return profileConfigs[clientId] ?? null;
@@ -530,3 +524,4 @@ export function writeProfileResult(action, result, io) {
530
524
  }
531
525
  writeLine(io.stdout, ' Token value embedded: false');
532
526
  }
527
+
@@ -14,14 +14,14 @@ export const AGENT_INSTANCE_HEADER = 'X-Memory-OS-Agent-Instance-ID';
14
14
  export const MCP_SERVER_NAME = 'XMemo';
15
15
  export const LEGACY_MCP_SERVER_NAMES = ['memory_os', 'memory-os'];
16
16
  export const CODEX_PROFILE_TARGET = 'AGENTS.md';
17
- export const CODEX_PROFILE_MARKER_START = '<!-- memory-os:codex-profile:start -->';
18
- export const CODEX_PROFILE_MARKER_END = '<!-- memory-os:codex-profile:end -->';
17
+ export const CODEX_PROFILE_MARKER_START = '<!-- xmemo:profile:start -->';
18
+ export const CODEX_PROFILE_MARKER_END = '<!-- xmemo:profile:end -->';
19
19
  export const CLIENT_PROFILE_TARGETS = {
20
- cursor: '.cursor/rules/xmemo-memory.md',
20
+ cursor: '.cursor/rules/AGENTS.md',
21
21
  'gemini-cli': 'GEMINI.md',
22
22
  antigravity: 'GEMINI.md',
23
- trae: '.trae/rules/xmemo-memory.md',
24
- 'trae-solo': '.trae/rules/xmemo-memory.md'
23
+ trae: '.trae/rules/AGENTS.md',
24
+ 'trae-solo': '.trae/rules/AGENTS.md'
25
25
  };
26
26
  export const CLIENT_PROFILE_MARKER_START = '<!-- xmemo:profile:start -->';
27
27
  export const CLIENT_PROFILE_MARKER_END = '<!-- xmemo:profile:end -->';
@@ -0,0 +1,9 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
3
+ import path from 'node:path';
4
+
5
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
+ const packageJsonPath = path.join(__dirname, '..', '..', 'package.json');
7
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
8
+
9
+ export const CLI_VERSION = packageJson.version;
@@ -1,8 +1,8 @@
1
1
  import os from 'node:os';
2
2
  import path from 'node:path';
3
3
 
4
- import { fileExists } from '../runtime.js';
5
- import { defaultCopilotConfigPath } from './paths.js';
4
+ import { fileExists } from '../../core/runtime.js';
5
+ import { defaultCopilotConfigPath } from '../identity/paths.js';
6
6
 
7
7
  export async function detectClient(clientId, env, mcpClients) {
8
8
  let filePaths = [];
@@ -48,3 +48,4 @@ export async function detectClient(clientId, env, mcpClients) {
48
48
 
49
49
  return { detected: false };
50
50
  }
51
+
@@ -1,4 +1,4 @@
1
- import { JSON_MCP_CLIENT_DEFINITIONS } from './json-clients.js';
1
+ import { JSON_MCP_CLIENT_DEFINITIONS } from '../formats/json.js';
2
2
 
3
3
  export function createMcpClients(deps) {
4
4
  const clients = new Map();
@@ -65,3 +65,4 @@ export function usesClientOAuth(clientId) {
65
65
  (definition) => definition.id === clientId && definition.authentication === 'oauth'
66
66
  );
67
67
  }
68
+
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  appendTomlServerConfig,
3
3
  codexTomlSnippet
4
- } from './codex.js';
4
+ } from './formats/toml.js';
5
5
  import {
6
6
  hermesYamlSnippet,
7
7
  mergeHermesMcpConfig
8
- } from './hermes.js';
8
+ } from './formats/yaml.js';
9
9
  import {
10
10
  JSON_MCP_CLIENT_DEFINITIONS,
11
11
  jsonClientSnippet,
12
12
  mergeJsonClientMcpConfig
13
- } from './json-clients.js';
13
+ } from './formats/json.js';
14
14
  import {
15
15
  defaultAntigravity2ConfigPath,
16
16
  defaultAntigravityCliConfigPath,
@@ -33,12 +33,12 @@ import {
33
33
  defaultTraeSoloConfigPath,
34
34
  defaultWindsurfConfigPath,
35
35
  defaultZedConfigPath
36
- } from '../path-config.js';
36
+ } from '../config/paths.js';
37
37
  import {
38
38
  createMcpClients,
39
39
  supportedMcpClientIds as registrySupportedMcpClientIds,
40
40
  supportedMcpClients as registrySupportedMcpClients
41
- } from './registry.js';
41
+ } from './clients/registry.js';
42
42
 
43
43
  export const MCP_CLIENTS = createMcpClients({
44
44
  JSON_MCP_CLIENT_DEFINITIONS,
@@ -78,3 +78,4 @@ export function supportedMcpClients() {
78
78
  export function supportedMcpClientIds() {
79
79
  return registrySupportedMcpClientIds(MCP_CLIENTS);
80
80
  }
81
+
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  LEGACY_MCP_SERVER_NAMES,
3
3
  MCP_SERVER_NAME
4
- } from '../constants.js';
4
+ } from '../../core/constants.js';
5
5
 
6
6
  export function knownMcpServerNames() {
7
7
  return [MCP_SERVER_NAME, ...LEGACY_MCP_SERVER_NAMES];
@@ -10,3 +10,4 @@ export function knownMcpServerNames() {
10
10
  export function existingJsonMcpServerName(mcpServers) {
11
11
  return knownMcpServerNames().find((name) => mcpServers[name]);
12
12
  }
13
+
@@ -6,12 +6,12 @@ import {
6
6
  DEFAULT_PROXY_PORT,
7
7
  MCP_SERVER_NAME,
8
8
  TOKEN_ENV_VAR
9
- } from '../constants.js';
10
- import { codexTomlSnippet } from './codex.js';
9
+ } from '../../core/constants.js';
10
+ import { codexTomlSnippet } from '../formats/toml.js';
11
11
  import {
12
12
  jsonClientConfig,
13
13
  jsonMcpClientDefinition
14
- } from './json-clients.js';
14
+ } from '../formats/json.js';
15
15
 
16
16
  export function mcpConfigTemplate(clientId, mcpUrl, options = {}) {
17
17
  if (clientId === 'codex') {
@@ -153,3 +153,4 @@ function oauthJsonMcpTemplate(clientId, mcpUrl, snippet, options) {
153
153
  writesTokenValue: false
154
154
  };
155
155
  }
156
+