@s_s/agent-kit 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +317 -0
  2. package/build/create-kit.d.ts +16 -0
  3. package/build/create-kit.js +54 -0
  4. package/build/create-kit.js.map +1 -0
  5. package/build/detect.d.ts +13 -0
  6. package/build/detect.js +34 -0
  7. package/build/detect.js.map +1 -0
  8. package/build/hook-capabilities.d.ts +87 -0
  9. package/build/hook-capabilities.js +191 -0
  10. package/build/hook-capabilities.js.map +1 -0
  11. package/build/hook-registry.d.ts +158 -0
  12. package/build/hook-registry.js +223 -0
  13. package/build/hook-registry.js.map +1 -0
  14. package/build/hook-translators/claude-code.d.ts +26 -0
  15. package/build/hook-translators/claude-code.js +351 -0
  16. package/build/hook-translators/claude-code.js.map +1 -0
  17. package/build/hook-translators/index.d.ts +4 -0
  18. package/build/hook-translators/index.js +4 -0
  19. package/build/hook-translators/index.js.map +1 -0
  20. package/build/hook-translators/openclaw.d.ts +25 -0
  21. package/build/hook-translators/openclaw.js +272 -0
  22. package/build/hook-translators/openclaw.js.map +1 -0
  23. package/build/hook-translators/opencode.d.ts +23 -0
  24. package/build/hook-translators/opencode.js +254 -0
  25. package/build/hook-translators/opencode.js.map +1 -0
  26. package/build/hook-translators/types.d.ts +59 -0
  27. package/build/hook-translators/types.js +2 -0
  28. package/build/hook-translators/types.js.map +1 -0
  29. package/build/hook-types.d.ts +155 -0
  30. package/build/hook-types.js +2 -0
  31. package/build/hook-types.js.map +1 -0
  32. package/build/hooks.d.ts +30 -0
  33. package/build/hooks.js +333 -0
  34. package/build/hooks.js.map +1 -0
  35. package/build/index.d.ts +9 -0
  36. package/build/index.js +11 -0
  37. package/build/index.js.map +1 -0
  38. package/build/platform.d.ts +17 -0
  39. package/build/platform.js +79 -0
  40. package/build/platform.js.map +1 -0
  41. package/build/prompt.d.ts +21 -0
  42. package/build/prompt.js +87 -0
  43. package/build/prompt.js.map +1 -0
  44. package/build/register.d.ts +18 -0
  45. package/build/register.js +34 -0
  46. package/build/register.js.map +1 -0
  47. package/build/types.d.ts +111 -0
  48. package/build/types.js +53 -0
  49. package/build/types.js.map +1 -0
  50. package/package.json +42 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;AAEhG;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,MAAyB,EAAE,OAAsB;IACxE,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,QAAQ,CAAC;IAEzC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;QACpF,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,OAAO,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QAC1D,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;IAED,eAAe;IACf,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,WAAW,CAA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MAAM,CAAC;QACL,sCAAsC;IAC1C,CAAC;IAED,sCAAsC;IACtC,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrC,OAAO,IAAI,EAAE,CAAC;QACV,KAAK,MAAM,MAAM,IAAI,oBAAoB,EAAE,CAAC;YACxC,IAAI,CAAC;gBACD,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;gBAC5C,OAAO,OAAO,CAAC;YACnB,CAAC;YAAC,MAAM,CAAC;gBACL,SAAS;YACb,CAAC;QACL,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,MAAM,KAAK,OAAO;YAAE,MAAM;QAC9B,OAAO,GAAG,MAAM,CAAC;IACrB,CAAC;IAED,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { AgentType, ScopeOptions } from './types.js';
2
+ /**
3
+ * Inject or update prompt into the agent's config file.
4
+ *
5
+ * Uses `<!-- {name}:start -->` / `<!-- {name}:end -->` markers.
6
+ * First call appends to end of file; subsequent calls replace the existing block.
7
+ *
8
+ * @internal — called by the Kit object returned from createKit().
9
+ */
10
+ export declare function injectPrompt(name: string, prompt: string, agent: AgentType, options?: ScopeOptions): Promise<void>;
11
+ /**
12
+ * Check if prompt has already been injected into the agent's config file.
13
+ *
14
+ * @internal — called by the Kit object returned from createKit().
15
+ */
16
+ export declare function hasPromptInjected(name: string, agent: AgentType, options?: ScopeOptions): Promise<boolean>;
17
+ /**
18
+ * Pure function: apply prompt injection to a string.
19
+ * @internal — exported for testing.
20
+ */
21
+ export declare function applyPromptInjection(existingContent: string, name: string, promptContent: string): string;
@@ -0,0 +1,87 @@
1
+ import fs from 'node:fs/promises';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+ import { AGENT_REGISTRY } from './types.js';
5
+ /**
6
+ * Inject or update prompt into the agent's config file.
7
+ *
8
+ * Uses `<!-- {name}:start -->` / `<!-- {name}:end -->` markers.
9
+ * First call appends to end of file; subsequent calls replace the existing block.
10
+ *
11
+ * @internal — called by the Kit object returned from createKit().
12
+ */
13
+ export async function injectPrompt(name, prompt, agent, options) {
14
+ const targetPath = resolveConfigPath(agent, options);
15
+ // Read existing content
16
+ let existingContent = '';
17
+ try {
18
+ existingContent = await fs.readFile(targetPath, 'utf-8');
19
+ }
20
+ catch {
21
+ // File doesn't exist yet
22
+ }
23
+ const updated = applyPromptInjection(existingContent, name, prompt);
24
+ // Ensure parent directory exists
25
+ await fs.mkdir(path.dirname(targetPath), { recursive: true });
26
+ await fs.writeFile(targetPath, updated, 'utf-8');
27
+ }
28
+ /**
29
+ * Check if prompt has already been injected into the agent's config file.
30
+ *
31
+ * @internal — called by the Kit object returned from createKit().
32
+ */
33
+ export async function hasPromptInjected(name, agent, options) {
34
+ const targetPath = resolveConfigPath(agent, options);
35
+ try {
36
+ const content = await fs.readFile(targetPath, 'utf-8');
37
+ return content.includes(markerStart(name));
38
+ }
39
+ catch {
40
+ return false;
41
+ }
42
+ }
43
+ // ---------------------------------------------------------------------------
44
+ // Internal helpers
45
+ // ---------------------------------------------------------------------------
46
+ function markerStart(name) {
47
+ return `<!-- ${name}:start -->`;
48
+ }
49
+ function markerEnd(name) {
50
+ return `<!-- ${name}:end -->`;
51
+ }
52
+ function escapeRegex(str) {
53
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
54
+ }
55
+ /**
56
+ * Pure function: apply prompt injection to a string.
57
+ * @internal — exported for testing.
58
+ */
59
+ export function applyPromptInjection(existingContent, name, promptContent) {
60
+ const start = markerStart(name);
61
+ const end = markerEnd(name);
62
+ const block = `${start}\n${promptContent}\n${end}`;
63
+ if (existingContent.includes(start)) {
64
+ // Replace existing block
65
+ const regex = new RegExp(`${escapeRegex(start)}[\\s\\S]*?${escapeRegex(end)}`, 'g');
66
+ return existingContent.replace(regex, block);
67
+ }
68
+ // Append to end
69
+ const separator = existingContent.trim() ? '\n\n' : '';
70
+ return existingContent.trimEnd() + separator + block + '\n';
71
+ }
72
+ /**
73
+ * Resolve the target config file path for an agent + scope.
74
+ */
75
+ function resolveConfigPath(agent, options) {
76
+ const entry = AGENT_REGISTRY[agent];
77
+ const scope = options?.scope ?? 'global';
78
+ const home = os.homedir();
79
+ if (scope === 'project') {
80
+ if (!options?.projectRoot) {
81
+ throw new Error('injectPrompt: projectRoot is required when scope is "project".');
82
+ }
83
+ return entry.projectConfigPath(options.projectRoot);
84
+ }
85
+ return entry.globalConfigPath(home);
86
+ }
87
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAC9B,IAAY,EACZ,MAAc,EACd,KAAgB,EAChB,OAAsB;IAEtB,MAAM,UAAU,GAAG,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAErD,wBAAwB;IACxB,IAAI,eAAe,GAAG,EAAE,CAAC;IACzB,IAAI,CAAC;QACD,eAAe,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAAC,MAAM,CAAC;QACL,yBAAyB;IAC7B,CAAC;IAED,MAAM,OAAO,GAAG,oBAAoB,CAAC,eAAe,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAEpE,iCAAiC;IACjC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CA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KAAK,GAAG,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,WAAW,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QACpF,OAAO,eAAe,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACjD,CAAC;IAED,gBAAgB;IAChB,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACvD,OAAO,eAAe,CAAC,OAAO,EAAE,GAAG,SAAS,GAAG,KAAK,GAAG,IAAI,CAAC;AAChE,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAC,KAAgB,EAAE,OAAsB;IAC/D,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,QAAQ,CAAC;IACzC,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;IAE1B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;QACtF,CAAC;QACD,OAAO,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { ToolConfig } from './types.js';
2
+ /**
3
+ * Register tool configuration. Must be called once before using
4
+ * config-dependent functions (injectPrompt, installHooks, getDataDir, etc.).
5
+ *
6
+ * Calling register() again replaces the previous configuration.
7
+ */
8
+ export declare function register(config: ToolConfig): void;
9
+ /**
10
+ * Get the registered config. Throws if register() has not been called.
11
+ * @internal
12
+ */
13
+ export declare function getConfig(): ToolConfig;
14
+ /**
15
+ * Reset registration state. Intended for testing only.
16
+ * @internal
17
+ */
18
+ export declare function _resetForTesting(): void;
@@ -0,0 +1,34 @@
1
+ let _config = null;
2
+ /**
3
+ * Register tool configuration. Must be called once before using
4
+ * config-dependent functions (injectPrompt, installHooks, getDataDir, etc.).
5
+ *
6
+ * Calling register() again replaces the previous configuration.
7
+ */
8
+ export function register(config) {
9
+ if (!config.name || !config.name.trim()) {
10
+ throw new Error('register: name is required and cannot be empty.');
11
+ }
12
+ if (!config.prompt || !config.prompt.trim()) {
13
+ throw new Error('register: prompt is required and cannot be empty.');
14
+ }
15
+ _config = { ...config };
16
+ }
17
+ /**
18
+ * Get the registered config. Throws if register() has not been called.
19
+ * @internal
20
+ */
21
+ export function getConfig() {
22
+ if (!_config) {
23
+ throw new Error('No tool registered. Call register() first.');
24
+ }
25
+ return _config;
26
+ }
27
+ /**
28
+ * Reset registration state. Intended for testing only.
29
+ * @internal
30
+ */
31
+ export function _resetForTesting() {
32
+ _config = null;
33
+ }
34
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAEA,IAAI,OAAO,GAAsB,IAAI,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAkB;IACvC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACvE,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS;IACrB,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC5B,OAAO,GAAG,IAAI,CAAC;AACnB,CAAC"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Supported agent types (hardcoded, not extensible).
3
+ */
4
+ export declare const AGENT_TYPES: readonly ["opencode", "claude-code", "openclaw", "codex"];
5
+ export type AgentType = (typeof AGENT_TYPES)[number];
6
+ export type StorageScope = 'global' | 'project';
7
+ /**
8
+ * Scope options for operations that support global/project level.
9
+ */
10
+ export interface ScopeOptions {
11
+ scope?: StorageScope;
12
+ projectRoot?: string;
13
+ }
14
+ /**
15
+ * Options for createKit(). Everything except name is optional.
16
+ */
17
+ export interface KitOptions {
18
+ /** Override data directory names. Defaults: global = name, project = `.${name}` */
19
+ dirs?: {
20
+ global?: string;
21
+ project?: string;
22
+ };
23
+ /** Environment variable name to override the global data directory path. */
24
+ envOverride?: string;
25
+ }
26
+ /**
27
+ * Internal resolved config derived from createKit() arguments.
28
+ * @internal
29
+ */
30
+ export interface ResolvedKitConfig {
31
+ name: string;
32
+ dirs?: {
33
+ global?: string;
34
+ project?: string;
35
+ };
36
+ envOverride?: string;
37
+ }
38
+ /**
39
+ * The object returned by createKit(). Provides all kit functions bound to the tool name.
40
+ */
41
+ export interface Kit {
42
+ /** The tool name this kit is bound to. */
43
+ readonly name: string;
44
+ /** Inject prompt into agent config file. */
45
+ injectPrompt(agent: AgentType, prompt: string, options?: ScopeOptions): Promise<void>;
46
+ /** Check if prompt has been injected. */
47
+ hasPromptInjected(agent: AgentType, options?: ScopeOptions): Promise<boolean>;
48
+ /** Install hooks for the given agent. */
49
+ installHooks(agent: AgentType): Promise<HookInstallResult>;
50
+ /** Uninstall hooks for the given agent. */
51
+ uninstallHooks(agent: AgentType): Promise<{
52
+ success: boolean;
53
+ removed: string[];
54
+ error?: string;
55
+ }>;
56
+ /** Check if hooks are installed for the given agent. */
57
+ hasHooksInstalled(agent: AgentType): Promise<boolean>;
58
+ /** Get platform-appropriate data directory path. */
59
+ getDataDir(options?: ScopeOptions): string;
60
+ }
61
+ /**
62
+ * Describes an intent that was skipped during hook installation.
63
+ */
64
+ export interface SkippedIntent {
65
+ /** The intent type that was skipped (e.g. 'onPermission'). */
66
+ intent: string;
67
+ /** The agent for which it was skipped. */
68
+ agent: string;
69
+ /** Human-readable reason for skipping. */
70
+ reason: string;
71
+ }
72
+ /**
73
+ * Result of hook installation.
74
+ */
75
+ export interface HookInstallResult {
76
+ success: boolean;
77
+ hookDir: string;
78
+ filesWritten: string[];
79
+ settingsUpdated: boolean;
80
+ notes: string[];
81
+ /** Degradation and conflict warnings (e.g. raw overrides, partial support). */
82
+ warnings: string[];
83
+ /** Intents that were completely skipped for this agent. */
84
+ skipped: SkippedIntent[];
85
+ error?: string;
86
+ }
87
+ /**
88
+ * Internal agent registry entry — config file paths, hook dirs, detection paths.
89
+ */
90
+ export interface AgentRegistryEntry {
91
+ /** Agent config file name (e.g. 'AGENTS.md', 'CLAUDE.md') */
92
+ configFileName: string;
93
+ /** Global config file path */
94
+ globalConfigPath: (home: string) => string;
95
+ /** Project-level config file path */
96
+ projectConfigPath: (projectRoot: string) => string;
97
+ /** Hook directory path (parameterized by tool name) */
98
+ getHookDir: (home: string, toolName: string) => string;
99
+ /** Settings.json path for agents that need hook config merged */
100
+ getSettingsPath?: (home: string) => string;
101
+ /** File paths to check for agent detection */
102
+ detectionPaths: (cwd: string, home: string) => string[];
103
+ }
104
+ /**
105
+ * Map from MCP clientInfo.name to AgentType.
106
+ */
107
+ export declare const CLIENT_NAME_MAP: Record<string, AgentType>;
108
+ /**
109
+ * Internal agent registry — unified data source for all agent-specific paths.
110
+ */
111
+ export declare const AGENT_REGISTRY: Record<AgentType, AgentRegistryEntry>;
package/build/types.js ADDED
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Supported agent types (hardcoded, not extensible).
3
+ */
4
+ export const AGENT_TYPES = ['opencode', 'claude-code', 'openclaw', 'codex'];
5
+ /**
6
+ * Map from MCP clientInfo.name to AgentType.
7
+ */
8
+ export const CLIENT_NAME_MAP = {
9
+ opencode: 'opencode',
10
+ 'claude-code': 'claude-code',
11
+ 'openclaw-acp-client': 'openclaw',
12
+ 'codex-mcp-client': 'codex',
13
+ };
14
+ /**
15
+ * Internal agent registry — unified data source for all agent-specific paths.
16
+ */
17
+ export const AGENT_REGISTRY = {
18
+ opencode: {
19
+ configFileName: 'AGENTS.md',
20
+ globalConfigPath: (home) => `${home}/.config/opencode/AGENTS.md`,
21
+ projectConfigPath: (cwd) => `${cwd}/AGENTS.md`,
22
+ getHookDir: (home, _toolName) => `${home}/.config/opencode/plugins`,
23
+ detectionPaths: (cwd, home) => [
24
+ `${cwd}/opencode.json`,
25
+ `${cwd}/opencode.jsonc`,
26
+ `${home}/.config/opencode/opencode.json`,
27
+ ],
28
+ },
29
+ 'claude-code': {
30
+ configFileName: 'CLAUDE.md',
31
+ globalConfigPath: (home) => `${home}/.claude/CLAUDE.md`,
32
+ projectConfigPath: (cwd) => `${cwd}/CLAUDE.md`,
33
+ getHookDir: (home, toolName) => `${home}/.claude/hooks/${toolName}`,
34
+ getSettingsPath: (home) => `${home}/.claude/settings.json`,
35
+ detectionPaths: (cwd, home) => [`${cwd}/CLAUDE.md`, `${home}/.claude/CLAUDE.md`],
36
+ },
37
+ openclaw: {
38
+ configFileName: 'AGENTS.md',
39
+ globalConfigPath: (home) => `${home}/.openclaw/workspace/AGENTS.md`,
40
+ projectConfigPath: (cwd) => `${cwd}/AGENTS.md`,
41
+ getHookDir: (home, toolName) => `${home}/.openclaw/hooks/${toolName}`,
42
+ detectionPaths: (_cwd, home) => [`${home}/.openclaw/openclaw.json`],
43
+ },
44
+ codex: {
45
+ configFileName: 'AGENTS.md',
46
+ globalConfigPath: (home) => `${home}/.codex/AGENTS.md`,
47
+ projectConfigPath: (cwd) => `${cwd}/AGENTS.md`,
48
+ getHookDir: (home, toolName) => `${home}/.codex/hooks/${toolName}`,
49
+ getSettingsPath: (home) => `${home}/.codex/settings.json`,
50
+ detectionPaths: (cwd, home) => [`${cwd}/.codex/config.toml`, `${home}/.codex/config.toml`],
51
+ },
52
+ };
53
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,CAAU,CAAC;AA6GrF;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAA8B;IACtD,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,aAAa;IAC5B,qBAAqB,EAAE,UAAU;IACjC,kBAAkB,EAAE,OAAO;CAC9B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAA0C;IACjE,QAAQ,EAAE;QACN,cAAc,EAAE,WAAW;QAC3B,gBAAgB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,6BAA6B;QAChE,iBAAiB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,YAAY;QAC9C,UAAU,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,GAAG,IAAI,2BAA2B;QACnE,cAAc,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC;YAC3B,GAAG,GAAG,gBAAgB;YACtB,GAAG,GAAG,iBAAiB;YACvB,GAAG,IAAI,iCAAiC;SAC3C;KACJ;IACD,aAAa,EAAE;QACX,cAAc,EAAE,WAAW;QAC3B,gBAAgB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,oBAAoB;QACvD,iBAAiB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,YAAY;QAC9C,UAAU,EA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P Server 与 Skill 开发的 Agent 适配工具包",
5
+ "type": "module",
6
+ "main": "./build/index.js",
7
+ "types": "./build/index.d.ts",
8
+ "files": [
9
+ "build"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "dev": "tsc --watch",
14
+ "prettier": "prettier --check \"**/*\"",
15
+ "prettier:fix": "prettier -c --write \"**/*\"",
16
+ "prettier:staged": "prettier --write",
17
+ "test": "vitest run",
18
+ "test:watch": "vitest",
19
+ "release": "bash scripts/release.sh",
20
+ "prepare": "husky"
21
+ },
22
+ "keywords": [
23
+ "mcp",
24
+ "agent",
25
+ "hooks",
26
+ "prompt-injection",
27
+ "toolkit"
28
+ ],
29
+ "author": "",
30
+ "license": "MIT",
31
+ "devDependencies": {
32
+ "@types/node": "^25.3.3",
33
+ "husky": "^9.1.7",
34
+ "lint-staged": "^16.3.2",
35
+ "prettier": "^3.8.1",
36
+ "typescript": "^5.9.3",
37
+ "vitest": "^4.0.18"
38
+ },
39
+ "lint-staged": {
40
+ "**/*.{js,ts,md}": "npm run prettier:staged --"
41
+ }
42
+ }