@x-code-cli/core 0.1.3 → 0.1.5
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/LICENSE +21 -0
- package/README.en.md +15 -0
- package/README.md +15 -0
- package/dist/agent/api-errors.d.ts +11 -0
- package/dist/agent/api-errors.d.ts.map +1 -0
- package/dist/agent/api-errors.js +134 -0
- package/dist/agent/api-errors.js.map +1 -0
- package/dist/agent/context-window.d.ts +26 -0
- package/dist/agent/context-window.d.ts.map +1 -0
- package/dist/agent/context-window.js +126 -0
- package/dist/agent/context-window.js.map +1 -0
- package/dist/agent/loop-state.d.ts +14 -0
- package/dist/agent/loop-state.d.ts.map +1 -0
- package/dist/agent/loop-state.js +12 -0
- package/dist/agent/loop-state.js.map +1 -0
- package/dist/agent/loop.d.ts +11 -15
- package/dist/agent/loop.d.ts.map +1 -1
- package/dist/agent/loop.js +213 -381
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/messages.d.ts +0 -2
- package/dist/agent/messages.d.ts.map +1 -1
- package/dist/agent/messages.js +0 -32
- package/dist/agent/messages.js.map +1 -1
- package/dist/agent/provider-compat.d.ts +17 -0
- package/dist/agent/provider-compat.d.ts.map +1 -0
- package/dist/agent/provider-compat.js +31 -0
- package/dist/agent/provider-compat.js.map +1 -0
- package/dist/agent/stream-utils.d.ts +33 -0
- package/dist/agent/stream-utils.d.ts.map +1 -0
- package/dist/agent/stream-utils.js +14 -0
- package/dist/agent/stream-utils.js.map +1 -0
- package/dist/agent/system-prompt.d.ts +1 -3
- package/dist/agent/system-prompt.d.ts.map +1 -1
- package/dist/agent/system-prompt.js +34 -23
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/agent/tool-execution.d.ts +11 -0
- package/dist/agent/tool-execution.d.ts.map +1 -0
- package/dist/agent/tool-execution.js +171 -0
- package/dist/agent/tool-execution.js.map +1 -0
- package/dist/config/index.d.ts +19 -8
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +66 -32
- package/dist/config/index.js.map +1 -1
- package/dist/index.d.ts +7 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -6
- package/dist/index.js.map +1 -1
- package/dist/knowledge/auto-memory.d.ts +1 -1
- package/dist/knowledge/auto-memory.d.ts.map +1 -1
- package/dist/knowledge/auto-memory.js +55 -16
- package/dist/knowledge/auto-memory.js.map +1 -1
- package/dist/knowledge/init.d.ts +1 -2
- package/dist/knowledge/init.d.ts.map +1 -1
- package/dist/knowledge/init.js +83 -69
- package/dist/knowledge/init.js.map +1 -1
- package/dist/knowledge/loader.d.ts +0 -9
- package/dist/knowledge/loader.d.ts.map +1 -1
- package/dist/knowledge/loader.js +54 -99
- package/dist/knowledge/loader.js.map +1 -1
- package/dist/knowledge/session.d.ts +1 -1
- package/dist/knowledge/session.d.ts.map +1 -1
- package/dist/knowledge/session.js +2 -1
- package/dist/knowledge/session.js.map +1 -1
- package/dist/permissions/index.d.ts +2 -0
- package/dist/permissions/index.d.ts.map +1 -1
- package/dist/permissions/index.js +35 -14
- package/dist/permissions/index.js.map +1 -1
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +3 -1
- package/dist/tools/glob.js.map +1 -1
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +7 -2
- package/dist/tools/grep.js.map +1 -1
- package/dist/tools/index.d.ts +3 -7
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +1 -5
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/list-dir.d.ts.map +1 -1
- package/dist/tools/list-dir.js +3 -1
- package/dist/tools/list-dir.js.map +1 -1
- package/dist/tools/progress.d.ts +6 -0
- package/dist/tools/progress.d.ts.map +1 -0
- package/dist/tools/progress.js +14 -0
- package/dist/tools/progress.js.map +1 -0
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +3 -1
- package/dist/tools/read-file.js.map +1 -1
- package/dist/tools/save-knowledge.d.ts +2 -2
- package/dist/tools/save-knowledge.d.ts.map +1 -1
- package/dist/tools/save-knowledge.js +31 -6
- package/dist/tools/save-knowledge.js.map +1 -1
- package/dist/tools/shell-utils.d.ts.map +1 -1
- package/dist/tools/shell-utils.js +7 -0
- package/dist/tools/shell-utils.js.map +1 -1
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +88 -19
- package/dist/tools/web-fetch.js.map +1 -1
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +85 -12
- package/dist/tools/web-search.js.map +1 -1
- package/dist/types/index.d.ts +60 -21
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +64 -6
- package/dist/types/index.js.map +1 -1
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +32 -0
- package/dist/utils.js.map +1 -1
- package/package.json +6 -6
- package/dist/agent/plan-mode.d.ts +0 -11
- package/dist/agent/plan-mode.d.ts.map +0 -1
- package/dist/agent/plan-mode.js +0 -37
- package/dist/agent/plan-mode.js.map +0 -1
- package/dist/agent/pricing.d.ts +0 -9
- package/dist/agent/pricing.d.ts.map +0 -1
- package/dist/agent/pricing.js +0 -47
- package/dist/agent/pricing.js.map +0 -1
- package/dist/knowledge/hooks.d.ts +0 -3
- package/dist/knowledge/hooks.d.ts.map +0 -1
- package/dist/knowledge/hooks.js +0 -59
- package/dist/knowledge/hooks.js.map +0 -1
- package/dist/tools/enter-plan-mode.d.ts +0 -2
- package/dist/tools/enter-plan-mode.d.ts.map +0 -1
- package/dist/tools/enter-plan-mode.js +0 -11
- package/dist/tools/enter-plan-mode.js.map +0 -1
- package/dist/tools/exit-plan-mode.d.ts +0 -2
- package/dist/tools/exit-plan-mode.d.ts.map +0 -1
- package/dist/tools/exit-plan-mode.js +0 -9
- package/dist/tools/exit-plan-mode.js.map +0 -1
package/dist/types/index.js
CHANGED
|
@@ -1,27 +1,85 @@
|
|
|
1
1
|
// ─── Model aliases ───
|
|
2
2
|
export const MODEL_ALIASES = {
|
|
3
|
-
sonnet: 'anthropic:claude-sonnet-4-
|
|
4
|
-
opus: 'anthropic:claude-opus-4-
|
|
3
|
+
sonnet: 'anthropic:claude-sonnet-4-6',
|
|
4
|
+
opus: 'anthropic:claude-opus-4-7',
|
|
5
5
|
haiku: 'anthropic:claude-haiku-4-5',
|
|
6
6
|
gpt4: 'openai:gpt-4.1',
|
|
7
7
|
gemini: 'google:gemini-2.5-pro',
|
|
8
|
-
deepseek: 'deepseek:deepseek-
|
|
9
|
-
|
|
8
|
+
deepseek: 'deepseek:deepseek-v4-flash',
|
|
9
|
+
'deepseek-pro': 'deepseek:deepseek-v4-pro',
|
|
10
10
|
qwen: 'alibaba:qwen-max',
|
|
11
11
|
glm: 'zhipu:glm-4-plus',
|
|
12
12
|
kimi: 'moonshotai:kimi-k2.5',
|
|
13
13
|
};
|
|
14
14
|
// ─── Provider detection order (for smart defaults) ───
|
|
15
15
|
export const PROVIDER_DETECTION_ORDER = [
|
|
16
|
-
{ envKey: 'ANTHROPIC_API_KEY', defaultModel: 'anthropic:claude-sonnet-4-
|
|
16
|
+
{ envKey: 'ANTHROPIC_API_KEY', defaultModel: 'anthropic:claude-sonnet-4-6' },
|
|
17
17
|
{ envKey: 'OPENAI_API_KEY', defaultModel: 'openai:gpt-4.1' },
|
|
18
|
-
{ envKey: 'DEEPSEEK_API_KEY', defaultModel: 'deepseek:deepseek-
|
|
18
|
+
{ envKey: 'DEEPSEEK_API_KEY', defaultModel: 'deepseek:deepseek-v4-flash' },
|
|
19
19
|
{ envKey: 'ALIBABA_API_KEY', defaultModel: 'alibaba:qwen-max' },
|
|
20
20
|
{ envKey: 'GOOGLE_GENERATIVE_AI_API_KEY', defaultModel: 'google:gemini-2.5-pro' },
|
|
21
21
|
{ envKey: 'XAI_API_KEY', defaultModel: 'xai:grok-3' },
|
|
22
22
|
{ envKey: 'ZHIPU_API_KEY', defaultModel: 'zhipu:glm-4-plus' },
|
|
23
23
|
{ envKey: 'MOONSHOT_API_KEY', defaultModel: 'moonshotai:kimi-k2.5' },
|
|
24
24
|
];
|
|
25
|
+
/**
|
|
26
|
+
* Hand-curated models per provider. Only models we've tested or that are
|
|
27
|
+
* advertised as production-stable make the list — agents tend to pick
|
|
28
|
+
* whatever is visible, so we don't dump every experimental variant here.
|
|
29
|
+
* Users who need something exotic can still type the full id into
|
|
30
|
+
* `/model <provider>:<model>` or pass it via `--model`.
|
|
31
|
+
*/
|
|
32
|
+
export const PROVIDER_MODELS = {
|
|
33
|
+
anthropic: [
|
|
34
|
+
{
|
|
35
|
+
id: 'anthropic:claude-sonnet-4-6',
|
|
36
|
+
label: 'Sonnet 4.6',
|
|
37
|
+
description: 'Balanced default — good for coding + reasoning, 1M context',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'anthropic:claude-opus-4-7',
|
|
41
|
+
label: 'Opus 4.7',
|
|
42
|
+
description: 'Most capable, strongest at agentic coding, 1M context',
|
|
43
|
+
},
|
|
44
|
+
{ id: 'anthropic:claude-haiku-4-5', label: 'Haiku 4.5', description: 'Fastest, cheapest — shorter replies' },
|
|
45
|
+
],
|
|
46
|
+
openai: [
|
|
47
|
+
{ id: 'openai:gpt-4.1', label: 'GPT-4.1', description: 'General-purpose, 1M context window' },
|
|
48
|
+
{ id: 'openai:gpt-4.1-mini', label: 'GPT-4.1 Mini', description: 'Cheaper tier of 4.1, 1M context' },
|
|
49
|
+
{ id: 'openai:o3', label: 'o3', description: 'Reasoning model — slower, stronger on hard problems' },
|
|
50
|
+
{ id: 'openai:o4-mini', label: 'o4-mini', description: 'Smaller reasoning model' },
|
|
51
|
+
],
|
|
52
|
+
deepseek: [
|
|
53
|
+
{
|
|
54
|
+
id: 'deepseek:deepseek-v4-flash',
|
|
55
|
+
label: 'DeepSeek V4 Flash',
|
|
56
|
+
description: 'Fast, efficient general-purpose, 1M context',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 'deepseek:deepseek-v4-pro',
|
|
60
|
+
label: 'DeepSeek V4 Pro',
|
|
61
|
+
description: 'Flagship, stronger reasoning, 1M context',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
alibaba: [
|
|
65
|
+
{ id: 'alibaba:qwen-max', label: 'Qwen Max', description: 'Strongest general Qwen, 128k context' },
|
|
66
|
+
{ id: 'alibaba:qwen-plus', label: 'Qwen Plus', description: 'Balanced cost/quality' },
|
|
67
|
+
{ id: 'alibaba:qwen-turbo', label: 'Qwen Turbo', description: 'Cheapest, fast' },
|
|
68
|
+
{ id: 'alibaba:qwen3-max', label: 'Qwen3 Max', description: 'Latest flagship' },
|
|
69
|
+
{ id: 'alibaba:qwen3-coder-plus', label: 'Qwen3 Coder Plus', description: 'Tuned for coding tasks' },
|
|
70
|
+
{ id: 'alibaba:qwq-plus', label: 'QwQ Plus', description: 'Reasoning model' },
|
|
71
|
+
],
|
|
72
|
+
google: [
|
|
73
|
+
{ id: 'google:gemini-2.5-pro', label: 'Gemini 2.5 Pro', description: '1M context, strong long-doc handling' },
|
|
74
|
+
{ id: 'google:gemini-2.5-flash', label: 'Gemini 2.5 Flash', description: 'Cheaper/faster tier' },
|
|
75
|
+
],
|
|
76
|
+
xai: [
|
|
77
|
+
{ id: 'xai:grok-3', label: 'Grok 3', description: '131k context' },
|
|
78
|
+
{ id: 'xai:grok-3-mini', label: 'Grok 3 Mini', description: 'Smaller/cheaper variant' },
|
|
79
|
+
],
|
|
80
|
+
zhipu: [{ id: 'zhipu:glm-4-plus', label: 'GLM-4 Plus', description: '128k context' }],
|
|
81
|
+
moonshotai: [{ id: 'moonshotai:kimi-k2.5', label: 'Kimi K2.5', description: '131k context' }],
|
|
82
|
+
};
|
|
25
83
|
// ─── Provider API key URLs ───
|
|
26
84
|
export const PROVIDER_KEY_URLS = {
|
|
27
85
|
anthropic: 'https://console.anthropic.com/',
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AA0HA,wBAAwB;AAExB,MAAM,CAAC,MAAM,aAAa,GAA2B;IACnD,MAAM,EAAE,6BAA6B;IACrC,IAAI,EAAE,2BAA2B;IACjC,KAAK,EAAE,4BAA4B;IACnC,IAAI,EAAE,gBAAgB;IACtB,MAAM,EAAE,uBAAuB;IAC/B,QAAQ,EAAE,4BAA4B;IACtC,cAAc,EAAE,0BAA0B;IAC1C,IAAI,EAAE,kBAAkB;IACxB,GAAG,EAAE,kBAAkB;IACvB,IAAI,EAAE,sBAAsB;CAC7B,CAAA;AAED,wDAAwD;AAExD,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,EAAE,MAAM,EAAE,mBAAmB,EAAE,YAAY,EAAE,6BAA6B,EAAE;IAC5E,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE;IAC5D,EAAE,MAAM,EAAE,kBAAkB,EAAE,YAAY,EAAE,4BAA4B,EAAE;IAC1E,EAAE,MAAM,EAAE,iBAAiB,EAAE,YAAY,EAAE,kBAAkB,EAAE;IAC/D,EAAE,MAAM,EAAE,8BAA8B,EAAE,YAAY,EAAE,uBAAuB,EAAE;IACjF,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE;IACrD,EAAE,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAE;IAC7D,EAAE,MAAM,EAAE,kBAAkB,EAAE,YAAY,EAAE,sBAAsB,EAAE;CAC5D,CAAA;AAaV;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAA6C;IACvE,SAAS,EAAE;QACT;YACE,EAAE,EAAE,6BAA6B;YACjC,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,4DAA4D;SAC1E;QACD;YACE,EAAE,EAAE,2BAA2B;YAC/B,KAAK,E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E,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE;KAC9E;IACD,MAAM,EAAE;QACN,EAAE,EAAE,EAAE,uBAAuB,EAAE,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,sCAAsC,EAAE;QAC7G,EAAE,EAAE,EAAE,yBAAyB,EAAE,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,qBAAqB,EAAE;KACjG;IACD,GAAG,EAAE;QACH,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE;QAClE,EAAE,EAAE,EAAE,iBAAiB,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,yBAAyB,EAAE;KACxF;IACD,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;IACrF,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,sBAAsB,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;CAC9F,CAAA;AAED,gCAAgC;AAEhC,MAAM,CAAC,MAAM,iBAAiB,GAA2B;IACvD,SAAS,EAAE,gCAAgC;IAC3C,MAAM,EAAE,sCAAsC;IAC9C,MAAM,EAAE,oCAAoC;IAC5C,GAAG,EAAE,uBAAuB;IAC5B,QAAQ,EAAE,wCAAwC;IAClD,OAAO,EAAE,6CAA6C;IACtD,KAAK,EAAE,6CAA6C;IACpD,UAAU,EAAE,+CAA+C;CAC5D,CAAA"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/** Project-local config directory name */
|
|
2
2
|
export declare const XCODE_DIR = ".x-code";
|
|
3
|
+
/** Global config directory (~/.x-code) */
|
|
4
|
+
export declare const GLOBAL_XCODE_DIR: string;
|
|
5
|
+
export declare function debugLog(tag: string, content: string): void;
|
|
3
6
|
/** Check if a file exists */
|
|
4
7
|
export declare function fileExists(filePath: string): Promise<boolean>;
|
|
5
8
|
/** Read a file safely, return empty string on error */
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAMA,0CAA0C;AAC1C,eAAO,MAAM,SAAS,YAAY,CAAA;AAElC,0CAA0C;AAC1C,eAAO,MAAM,gBAAgB,QAAqC,CAAA;AAgBlE,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAY3D;AAED,6BAA6B;AAC7B,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnE;AAED,uDAAuD;AACvD,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAMpE;AAED,uDAAuD;AACvD,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAO5F"}
|
package/dist/utils.js
CHANGED
|
@@ -1,7 +1,39 @@
|
|
|
1
1
|
// @x-code-cli/core — Shared utilities and constants
|
|
2
|
+
import fsSync from 'node:fs';
|
|
2
3
|
import fs from 'node:fs/promises';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
3
6
|
/** Project-local config directory name */
|
|
4
7
|
export const XCODE_DIR = '.x-code';
|
|
8
|
+
/** Global config directory (~/.x-code) */
|
|
9
|
+
export const GLOBAL_XCODE_DIR = path.join(os.homedir(), '.x-code');
|
|
10
|
+
// ── Debug log (shared by core + cli) ────────────────────────────────────
|
|
11
|
+
// Turn on with `DEBUG_STDOUT=1`. Writes to <cwd>/stdout-debug.log —
|
|
12
|
+
// project-root rather than ~/.x-code so a single tail -f in the repo
|
|
13
|
+
// captures everything. Intentionally sync I/O because callers are in hot
|
|
14
|
+
// paths (every stream chunk, every tool call) and we want ordering to
|
|
15
|
+
// match real-time events; an async queue would reorder entries.
|
|
16
|
+
//
|
|
17
|
+
// Content is logged **verbatim**, no truncation. This file is gitignored.
|
|
18
|
+
const DEBUG = process.env.DEBUG_STDOUT === '1';
|
|
19
|
+
function debugLogPath() {
|
|
20
|
+
return path.join(process.cwd(), 'stdout-debug.log');
|
|
21
|
+
}
|
|
22
|
+
export function debugLog(tag, content) {
|
|
23
|
+
if (!DEBUG)
|
|
24
|
+
return;
|
|
25
|
+
try {
|
|
26
|
+
const ts = new Date().toISOString();
|
|
27
|
+
// `JSON.stringify(content)` quotes newlines/tabs so the full payload
|
|
28
|
+
// lands on ONE line in the log — much easier to grep across turns,
|
|
29
|
+
// and multi-line text-deltas don't visually merge with neighbours.
|
|
30
|
+
const line = `[${ts}] ${tag} ${JSON.stringify(content)}\n`;
|
|
31
|
+
fsSync.appendFileSync(debugLogPath(), line, 'utf8');
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// best effort — never crash the agent just because we can't log
|
|
35
|
+
}
|
|
36
|
+
}
|
|
5
37
|
/** Check if a file exists */
|
|
6
38
|
export async function fileExists(filePath) {
|
|
7
39
|
try {
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,OAAO,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjC,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI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,CAAC,KAAK,UAAU,YAAY,CAAC,QAAgB;IACjD,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC;AAED,uDAAuD;AACvD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,QAAgB;IACjD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QACpD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAA4B,CAAA;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x-code-cli/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/woai3c/x-code-cli",
|
|
@@ -19,10 +19,6 @@
|
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=20.19.0"
|
|
21
21
|
},
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "tsc -b",
|
|
24
|
-
"dev": "tsc -b --watch"
|
|
25
|
-
},
|
|
26
22
|
"dependencies": {
|
|
27
23
|
"ai": "^6.0.0",
|
|
28
24
|
"@ai-sdk/anthropic": "^3.0.0",
|
|
@@ -43,5 +39,9 @@
|
|
|
43
39
|
"turndown": "^7.2.0",
|
|
44
40
|
"diff": "^8.0.0",
|
|
45
41
|
"chalk": "^5.4.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc -b",
|
|
45
|
+
"dev": "tsc -b --watch"
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/** Generate a plan ID based on timestamp */
|
|
2
|
-
export declare function generatePlanId(): string;
|
|
3
|
-
/** Get the plan file path */
|
|
4
|
-
export declare function getPlanPath(planId: string): string;
|
|
5
|
-
/** Ensure plans directory exists */
|
|
6
|
-
export declare function ensurePlansDir(): Promise<void>;
|
|
7
|
-
/** Read a plan file */
|
|
8
|
-
export declare function readPlan(planId: string): Promise<string | null>;
|
|
9
|
-
/** List all plan files */
|
|
10
|
-
export declare function listPlans(): Promise<string[]>;
|
|
11
|
-
//# sourceMappingURL=plan-mode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plan-mode.d.ts","sourceRoot":"","sources":["../../src/agent/plan-mode.ts"],"names":[],"mappings":"AAMA,4CAA4C;AAC5C,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,6BAA6B;AAC7B,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,oCAAoC;AACpC,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAEpD;AAED,uBAAuB;AACvB,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAMrE;AAED,0BAA0B;AAC1B,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAQnD"}
|
package/dist/agent/plan-mode.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// @x-code-cli/core — Plan Mode logic
|
|
2
|
-
import fs from 'node:fs/promises';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
const PLANS_DIR = '.x-code/plans';
|
|
5
|
-
/** Generate a plan ID based on timestamp */
|
|
6
|
-
export function generatePlanId() {
|
|
7
|
-
return new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
8
|
-
}
|
|
9
|
-
/** Get the plan file path */
|
|
10
|
-
export function getPlanPath(planId) {
|
|
11
|
-
return path.join(process.cwd(), PLANS_DIR, `${planId}.md`);
|
|
12
|
-
}
|
|
13
|
-
/** Ensure plans directory exists */
|
|
14
|
-
export async function ensurePlansDir() {
|
|
15
|
-
await fs.mkdir(path.join(process.cwd(), PLANS_DIR), { recursive: true });
|
|
16
|
-
}
|
|
17
|
-
/** Read a plan file */
|
|
18
|
-
export async function readPlan(planId) {
|
|
19
|
-
try {
|
|
20
|
-
return await fs.readFile(getPlanPath(planId), 'utf-8');
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
/** List all plan files */
|
|
27
|
-
export async function listPlans() {
|
|
28
|
-
try {
|
|
29
|
-
const dir = path.join(process.cwd(), PLANS_DIR);
|
|
30
|
-
const files = await fs.readdir(dir);
|
|
31
|
-
return files.filter((f) => f.endsWith('.md')).map((f) => f.replace('.md', ''));
|
|
32
|
-
}
|
|
33
|
-
catch {
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=plan-mode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plan-mode.js","sourceRoot":"","sources":["../../src/agent/plan-mode.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjC,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,MAAM,SAAS,GAAG,eAAe,CAAA;AAEjC,4CAA4C;AAC5C,MAAM,UAAU,cAAc;IAC5B,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACpE,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,GAAG,MAAM,KAAK,CAAC,CAAA;AAC5D,CAAC;AAED,oCAAoC;AACpC,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;AAC1E,CAAC;AAED,uBAAuB;AACvB,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,MAAc;IAC3C,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAA;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC;AAED,0BAA0B;AAC1B,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAA;QAC/C,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACnC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAA;IAChF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC"}
|
package/dist/agent/pricing.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export interface CostEstimate {
|
|
2
|
-
cost: number;
|
|
3
|
-
currency: 'USD' | 'CNY';
|
|
4
|
-
}
|
|
5
|
-
/** Estimate cost from model ID and token counts. Returns cost and currency. */
|
|
6
|
-
export declare function estimateCost(modelId: string, inputTokens: number, outputTokens: number): CostEstimate;
|
|
7
|
-
/** Format cost string with currency symbol */
|
|
8
|
-
export declare function formatCost(estimate: CostEstimate): string;
|
|
9
|
-
//# sourceMappingURL=pricing.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../../src/agent/pricing.ts"],"names":[],"mappings":"AA2CA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,KAAK,GAAG,KAAK,CAAA;CACxB;AAED,+EAA+E;AAC/E,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,YAAY,CAKrG;AAED,8CAA8C;AAC9C,wBAAgB,UAAU,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAIzD"}
|
package/dist/agent/pricing.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// @x-code-cli/core — Model pricing table and cost estimation
|
|
2
|
-
const MODEL_PRICING = {
|
|
3
|
-
// ── USD providers ──
|
|
4
|
-
// Anthropic
|
|
5
|
-
'anthropic:claude-opus-4-6': { input: 15, output: 75, currency: 'USD' },
|
|
6
|
-
'anthropic:claude-sonnet-4-5': { input: 3, output: 15, currency: 'USD' },
|
|
7
|
-
'anthropic:claude-haiku-4-5': { input: 0.8, output: 4, currency: 'USD' },
|
|
8
|
-
// OpenAI
|
|
9
|
-
'openai:gpt-4.1': { input: 2, output: 8, currency: 'USD' },
|
|
10
|
-
'openai:gpt-4.1-mini': { input: 0.4, output: 1.6, currency: 'USD' },
|
|
11
|
-
'openai:gpt-4.1-nano': { input: 0.1, output: 0.4, currency: 'USD' },
|
|
12
|
-
'openai:o3': { input: 2, output: 8, currency: 'USD' },
|
|
13
|
-
'openai:o4-mini': { input: 1.1, output: 4.4, currency: 'USD' },
|
|
14
|
-
// Google
|
|
15
|
-
'google:gemini-2.5-pro': { input: 1.25, output: 10, currency: 'USD' },
|
|
16
|
-
'google:gemini-2.5-flash': { input: 0.15, output: 0.6, currency: 'USD' },
|
|
17
|
-
// xAI
|
|
18
|
-
'xai:grok-3': { input: 3, output: 15, currency: 'USD' },
|
|
19
|
-
'xai:grok-3-mini': { input: 0.3, output: 0.5, currency: 'USD' },
|
|
20
|
-
// ── CNY (人民币) providers ──
|
|
21
|
-
// DeepSeek (api.deepseek.com, V3.2 统一定价, 人民币)
|
|
22
|
-
'deepseek:deepseek-chat': { input: 2, output: 3, currency: 'CNY' },
|
|
23
|
-
'deepseek:deepseek-reasoner': { input: 2, output: 3, currency: 'CNY' },
|
|
24
|
-
// Alibaba / 阿里云百炼 (dashscope.aliyuncs.com, 中国内地定价)
|
|
25
|
-
'alibaba:qwen-max': { input: 2.4, output: 9.6, currency: 'CNY' },
|
|
26
|
-
'alibaba:qwen-plus': { input: 0.8, output: 2, currency: 'CNY' },
|
|
27
|
-
// Zhipu / 智谱 (bigmodel.cn)
|
|
28
|
-
'zhipu:glm-4-plus': { input: 5, output: 5, currency: 'CNY' },
|
|
29
|
-
// Moonshot / 月之暗面 (platform.moonshot.cn, 人民币)
|
|
30
|
-
'moonshotai:kimi-k2.5': { input: 4, output: 16, currency: 'CNY' },
|
|
31
|
-
};
|
|
32
|
-
/** Estimate cost from model ID and token counts. Returns cost and currency. */
|
|
33
|
-
export function estimateCost(modelId, inputTokens, outputTokens) {
|
|
34
|
-
const pricing = MODEL_PRICING[modelId];
|
|
35
|
-
if (!pricing)
|
|
36
|
-
return { cost: 0, currency: 'USD' };
|
|
37
|
-
const cost = (inputTokens * pricing.input + outputTokens * pricing.output) / 1_000_000;
|
|
38
|
-
return { cost, currency: pricing.currency };
|
|
39
|
-
}
|
|
40
|
-
/** Format cost string with currency symbol */
|
|
41
|
-
export function formatCost(estimate) {
|
|
42
|
-
if (estimate.cost <= 0)
|
|
43
|
-
return '';
|
|
44
|
-
const symbol = estimate.currency === 'CNY' ? '¥' : '$';
|
|
45
|
-
return `${symbol}${estimate.cost.toFixed(4)}`;
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=pricing.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pricing.js","sourceRoot":"","sources":["../../src/agent/pricing.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAS7D,MAAM,aAAa,GAA+B;IAChD,sBAAsB;IAEtB,YAAY;IACZ,2BAA2B,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE;IACvE,6BAA6B,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE;IACxE,4BAA4B,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE;IACxE,SAAS;IACT,gBAAgB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE;IAC1D,qBAAqB,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE;IACnE,qBAAqB,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE;IACnE,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE;IACrD,gBAAgB,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE;IAC9D,SAAS;IACT,uBAAuB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE;IACrE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AAM,IAAI,GAAG,CAAC,WAAW,GAAG,OAAO,CAAC,KAAK,GAAG,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;IACtF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAA;AAC7C,CAAC;AAED,8CAA8C;AAC9C,MAAM,UAAU,UAAU,CAAC,QAAsB;IAC/C,IAAI,QAAQ,CAAC,IAAI,IAAI,CAAC;QAAE,OAAO,EAAE,CAAA;IACjC,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;IACtD,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAA;AAC/C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/knowledge/hooks.ts"],"names":[],"mappings":"AAUA,kEAAkE;AAClE,wBAAsB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiDpE"}
|
package/dist/knowledge/hooks.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// @x-code-cli/core — Startup project scan (reads config files to inject basic context)
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { fileExists, readJsonSafe } from '../utils.js';
|
|
4
|
-
import { getAutoMemory } from './auto-memory.js';
|
|
5
|
-
function today() {
|
|
6
|
-
return new Date().toISOString().slice(0, 10);
|
|
7
|
-
}
|
|
8
|
-
/** Scan project root and populate auto memory with basic facts */
|
|
9
|
-
export async function scanProject(projectRoot) {
|
|
10
|
-
const memory = getAutoMemory('project');
|
|
11
|
-
// Detect package manager from lock files
|
|
12
|
-
if (await fileExists(path.join(projectRoot, 'pnpm-lock.yaml'))) {
|
|
13
|
-
memory.add({ key: 'package-manager', fact: 'pnpm', category: 'tech-stack', date: today() });
|
|
14
|
-
}
|
|
15
|
-
else if (await fileExists(path.join(projectRoot, 'yarn.lock'))) {
|
|
16
|
-
memory.add({ key: 'package-manager', fact: 'yarn', category: 'tech-stack', date: today() });
|
|
17
|
-
}
|
|
18
|
-
else if (await fileExists(path.join(projectRoot, 'package-lock.json'))) {
|
|
19
|
-
memory.add({ key: 'package-manager', fact: 'npm', category: 'tech-stack', date: today() });
|
|
20
|
-
}
|
|
21
|
-
// Read package.json
|
|
22
|
-
const pkg = await readJsonSafe(path.join(projectRoot, 'package.json'));
|
|
23
|
-
if (pkg) {
|
|
24
|
-
const scripts = pkg.scripts;
|
|
25
|
-
if (scripts?.test) {
|
|
26
|
-
memory.add({ key: 'test-command', fact: scripts.test, category: 'commands', date: today() });
|
|
27
|
-
}
|
|
28
|
-
if (scripts?.build) {
|
|
29
|
-
memory.add({ key: 'build-command', fact: scripts.build, category: 'commands', date: today() });
|
|
30
|
-
}
|
|
31
|
-
if (scripts?.lint) {
|
|
32
|
-
memory.add({ key: 'lint-command', fact: scripts.lint, category: 'commands', date: today() });
|
|
33
|
-
}
|
|
34
|
-
const deps = {
|
|
35
|
-
...pkg.dependencies,
|
|
36
|
-
...pkg.devDependencies,
|
|
37
|
-
};
|
|
38
|
-
if (deps.react)
|
|
39
|
-
memory.add({ key: 'ui-framework', fact: `React ${deps.react}`, category: 'tech-stack', date: today() });
|
|
40
|
-
if (deps.vitest)
|
|
41
|
-
memory.add({ key: 'test-framework', fact: 'Vitest', category: 'tech-stack', date: today() });
|
|
42
|
-
if (deps.typescript)
|
|
43
|
-
memory.add({ key: 'language', fact: `TypeScript ${deps.typescript}`, category: 'tech-stack', date: today() });
|
|
44
|
-
if (deps.ink)
|
|
45
|
-
memory.add({ key: 'tui-framework', fact: `Ink ${deps.ink}`, category: 'tech-stack', date: today() });
|
|
46
|
-
}
|
|
47
|
-
// Read tsconfig for TS settings
|
|
48
|
-
const tsconfig = await readJsonSafe(path.join(projectRoot, 'tsconfig.json'));
|
|
49
|
-
if (tsconfig) {
|
|
50
|
-
const compilerOptions = tsconfig.compilerOptions;
|
|
51
|
-
if (compilerOptions?.strict) {
|
|
52
|
-
memory.add({ key: 'ts-strict-mode', fact: 'enabled', category: 'conventions', date: today() });
|
|
53
|
-
}
|
|
54
|
-
if (compilerOptions?.module?.toString().toLowerCase().includes('nodenext')) {
|
|
55
|
-
memory.add({ key: 'module-system', fact: 'ESM (NodeNext)', category: 'conventions', date: today() });
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=hooks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/knowledge/hooks.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD,SAAS,KAAK;IACZ,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAC9C,CAAC;AAED,kEAAkE;AAClE,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,WAAmB;IACnD,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,CAAA;IAEvC,yCAAyC;IACzC,IAAI,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC;QAC/D,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;IAC7F,CAAC;SAAM,IAAI,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,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AM,EAAE,CAAC;YAC5B,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;QAChG,CAAC;QACD,IAAI,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3E,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;QACtG,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enter-plan-mode.d.ts","sourceRoot":"","sources":["../../src/tools/enter-plan-mode.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa,8BAMxB,CAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// @x-code-cli/core — enterPlanMode tool (no execute — handled in agent loop)
|
|
2
|
-
import { tool } from 'ai';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
export const enterPlanMode = tool({
|
|
5
|
-
description: `Enter plan mode for exploring the codebase and designing an implementation plan.
|
|
6
|
-
Use proactively for non-trivial tasks: new features, multi-file changes, architectural decisions, unclear requirements.
|
|
7
|
-
Skip for: single-line fixes, obvious bugs, specific user instructions.`,
|
|
8
|
-
inputSchema: z.object({}),
|
|
9
|
-
// No execute — handled in agent loop (inject plan mode prompt + wait for user consent)
|
|
10
|
-
});
|
|
11
|
-
//# sourceMappingURL=enter-plan-mode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enter-plan-mode.js","sourceRoot":"","sources":["../../src/tools/enter-plan-mode.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AAEzB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;IAChC,WAAW,EAAE;;uEAEwD;IACrE,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACzB,uFAAuF;CACxF,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exit-plan-mode.d.ts","sourceRoot":"","sources":["../../src/tools/exit-plan-mode.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY,8BAKvB,CAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// @x-code-cli/core — exitPlanMode tool (no execute — handled in agent loop)
|
|
2
|
-
import { tool } from 'ai';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
export const exitPlanMode = tool({
|
|
5
|
-
description: 'Signal that the plan is complete and ready for user review. The system will read the plan file and present it to the user.',
|
|
6
|
-
inputSchema: z.object({}),
|
|
7
|
-
// No execute — handled in agent loop (read plan file + present to user)
|
|
8
|
-
});
|
|
9
|
-
//# sourceMappingURL=exit-plan-mode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exit-plan-mode.js","sourceRoot":"","sources":["../../src/tools/exit-plan-mode.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AAEzB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;IAC/B,WAAW,EACT,4HAA4H;IAC9H,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACzB,wEAAwE;CACzE,CAAC,CAAA"}
|