@codemieai/code 0.0.43 → 0.0.45

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 (32) hide show
  1. package/dist/agents/core/BaseAgentAdapter.d.ts +9 -1
  2. package/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
  3. package/dist/agents/core/BaseAgentAdapter.js +11 -0
  4. package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
  5. package/dist/agents/core/types.d.ts +83 -0
  6. package/dist/agents/core/types.d.ts.map +1 -1
  7. package/dist/agents/plugins/claude/claude.plugin.d.ts.map +1 -1
  8. package/dist/agents/plugins/claude/claude.plugin.js +9 -0
  9. package/dist/agents/plugins/claude/claude.plugin.js.map +1 -1
  10. package/dist/agents/plugins/claude/plugin/.claude-plugin/plugin.json +1 -1
  11. package/dist/agents/plugins/claude/plugin/hooks/hooks.json +6 -1
  12. package/dist/agents/plugins/gemini/gemini.plugin.d.ts.map +1 -1
  13. package/dist/agents/plugins/gemini/gemini.plugin.js +10 -0
  14. package/dist/agents/plugins/gemini/gemini.plugin.js.map +1 -1
  15. package/dist/cli/commands/hook.d.ts.map +1 -1
  16. package/dist/cli/commands/hook.js +21 -5
  17. package/dist/cli/commands/hook.js.map +1 -1
  18. package/dist/providers/plugins/sso/session/processors/metrics/metrics-api-client.d.ts +3 -2
  19. package/dist/providers/plugins/sso/session/processors/metrics/metrics-api-client.d.ts.map +1 -1
  20. package/dist/providers/plugins/sso/session/processors/metrics/metrics-api-client.js +32 -1
  21. package/dist/providers/plugins/sso/session/processors/metrics/metrics-api-client.js.map +1 -1
  22. package/dist/providers/plugins/sso/session/processors/metrics/metrics-types.d.ts +25 -0
  23. package/dist/providers/plugins/sso/session/processors/metrics/metrics-types.d.ts.map +1 -1
  24. package/dist/providers/plugins/sso/sso.http-client.d.ts +1 -0
  25. package/dist/providers/plugins/sso/sso.http-client.d.ts.map +1 -1
  26. package/dist/providers/plugins/sso/sso.http-client.js +5 -0
  27. package/dist/providers/plugins/sso/sso.http-client.js.map +1 -1
  28. package/dist/utils/extensions-scan.d.ts +27 -0
  29. package/dist/utils/extensions-scan.d.ts.map +1 -0
  30. package/dist/utils/extensions-scan.js +182 -0
  31. package/dist/utils/extensions-scan.js.map +1 -0
  32. package/package.json +1 -1
@@ -0,0 +1,182 @@
1
+ /**
2
+ * Extensions Scan Utilities
3
+ *
4
+ * Scans agent extension directories at project and global levels.
5
+ * Reports counts and names of agents, commands, skills, hooks, and rules installed.
6
+ *
7
+ * Agent-agnostic: each agent declares its own directory paths via AgentExtensionsConfig.
8
+ *
9
+ * Security Notes:
10
+ * - ONLY counts/names files, never reads their contents
11
+ * - All failures return zero counts and empty name arrays (graceful degradation)
12
+ */
13
+ import { readdir } from 'fs/promises';
14
+ import path from 'path';
15
+ import { homedir } from 'os';
16
+ import { logger } from './logger.js';
17
+ // ============================================================================
18
+ // Constants
19
+ // ============================================================================
20
+ const SCRIPT_EXTENSIONS = new Set(['.sh', '.js', '.py', '.ts']);
21
+ // ============================================================================
22
+ // Path Resolution
23
+ // ============================================================================
24
+ /**
25
+ * Resolve extensions base directory path
26
+ * Handles '~/' prefix (home-relative) and relative paths from cwd
27
+ */
28
+ function resolveExtensionsPath(dirPath, cwd) {
29
+ if (dirPath.startsWith('~/')) {
30
+ return path.join(homedir(), dirPath.slice(2));
31
+ }
32
+ if (path.isAbsolute(dirPath)) {
33
+ return dirPath;
34
+ }
35
+ return path.join(cwd, dirPath);
36
+ }
37
+ // ============================================================================
38
+ // File Listing
39
+ // ============================================================================
40
+ /**
41
+ * List markdown files recursively in a directory, returning their names.
42
+ *
43
+ * @param dirPath - Directory to scan
44
+ * @param exactName - If provided, only match files with this exact name (case-insensitive).
45
+ * When set (e.g. 'SKILL.md'), the returned name is the parent directory
46
+ * name — i.e. the skill's directory name, not the entry file itself.
47
+ * When unset, the name is the filename without the .md extension.
48
+ */
49
+ async function listMdFiles(dirPath, exactName) {
50
+ try {
51
+ const entries = await readdir(dirPath, { recursive: true, withFileTypes: true });
52
+ const names = [];
53
+ for (const e of entries) {
54
+ if (!e.isFile())
55
+ continue;
56
+ const lowerName = e.name.toLowerCase();
57
+ if (exactName) {
58
+ // Skill-directory pattern: SKILL.md lives inside a named skill subdirectory.
59
+ // The meaningful name is the parent directory (the skill name), not the file.
60
+ if (lowerName === exactName.toLowerCase()) {
61
+ names.push(path.basename(e.parentPath));
62
+ }
63
+ }
64
+ else {
65
+ if (lowerName.endsWith('.md') && lowerName !== 'readme.md') {
66
+ names.push(e.name.slice(0, -3)); // strip .md extension
67
+ }
68
+ }
69
+ }
70
+ return names;
71
+ }
72
+ catch {
73
+ return [];
74
+ }
75
+ }
76
+ /**
77
+ * List script files (.sh, .js, .py, .ts) recursively in a directory
78
+ * Used for hooks directory
79
+ */
80
+ async function listScriptFiles(dirPath) {
81
+ try {
82
+ const entries = await readdir(dirPath, { recursive: true, withFileTypes: true });
83
+ return entries
84
+ .filter(e => e.isFile() && SCRIPT_EXTENSIONS.has(path.extname(e.name).toLowerCase()))
85
+ .map(e => e.name);
86
+ }
87
+ catch {
88
+ return [];
89
+ }
90
+ }
91
+ // ============================================================================
92
+ // Directory Scanning
93
+ // ============================================================================
94
+ /**
95
+ * Scan an agent's extension base directory and return counts and names per category.
96
+ * Each subdirectory (agents/, commands/, skills/, hooks/, rules/) is scanned independently.
97
+ *
98
+ * @param baseDir - Resolved absolute path to the agent's extensions base directory
99
+ * @param skillsEntryFile - If set, only count/name skills files with this exact name (e.g. 'SKILL.md')
100
+ */
101
+ async function scanExtensionsDir(baseDir, skillsEntryFile) {
102
+ const [agents, commands, skills, hooks, rules] = await Promise.all([
103
+ listMdFiles(path.join(baseDir, 'agents')),
104
+ listMdFiles(path.join(baseDir, 'commands')),
105
+ listMdFiles(path.join(baseDir, 'skills'), skillsEntryFile),
106
+ listScriptFiles(path.join(baseDir, 'hooks')),
107
+ listMdFiles(path.join(baseDir, 'rules')),
108
+ ]);
109
+ return {
110
+ counts: {
111
+ agents: agents.length,
112
+ commands: commands.length,
113
+ skills: skills.length,
114
+ hooks: hooks.length,
115
+ rules: rules.length,
116
+ },
117
+ names: {
118
+ agents: agents.sort(),
119
+ commands: commands.sort(),
120
+ skills: skills.sort(),
121
+ hooks: hooks.sort(),
122
+ rules: rules.sort(),
123
+ },
124
+ };
125
+ }
126
+ // ============================================================================
127
+ // Public API
128
+ // ============================================================================
129
+ /**
130
+ * Scan agent extension directories at project and global levels
131
+ *
132
+ * Main entry point for metrics integration.
133
+ * Uses agent-declared paths from AgentExtensionsConfig (set in agent metadata).
134
+ * Returns empty counts and empty name arrays for any scope not declared by the agent.
135
+ *
136
+ * @param extensionsConfig - Agent's extensions directory config (from metadata)
137
+ * @param cwd - Current working directory (for resolving relative project paths)
138
+ * @returns ExtensionsScanSummary with counts and names per scope
139
+ */
140
+ export async function getExtensionsScanSummary(extensionsConfig, cwd) {
141
+ const emptyCount = { agents: 0, commands: 0, skills: 0, hooks: 0, rules: 0 };
142
+ const emptyNames = { agents: [], commands: [], skills: [], hooks: [], rules: [] };
143
+ if (!extensionsConfig) {
144
+ return {
145
+ project: { ...emptyCount },
146
+ global: { ...emptyCount },
147
+ projectNames: { ...emptyNames },
148
+ globalNames: { ...emptyNames },
149
+ };
150
+ }
151
+ try {
152
+ const { skillsEntryFile } = extensionsConfig;
153
+ const [projectResult, globalResult] = await Promise.all([
154
+ extensionsConfig.project
155
+ ? scanExtensionsDir(resolveExtensionsPath(extensionsConfig.project, cwd), skillsEntryFile)
156
+ : Promise.resolve({ counts: { ...emptyCount }, names: { ...emptyNames } }),
157
+ extensionsConfig.global
158
+ ? scanExtensionsDir(resolveExtensionsPath(extensionsConfig.global, cwd), skillsEntryFile)
159
+ : Promise.resolve({ counts: { ...emptyCount }, names: { ...emptyNames } }),
160
+ ]);
161
+ logger.debug('[extensions-scan] Scan complete', {
162
+ project: projectResult.counts,
163
+ global: globalResult.counts,
164
+ });
165
+ return {
166
+ project: projectResult.counts,
167
+ global: globalResult.counts,
168
+ projectNames: projectResult.names,
169
+ globalNames: globalResult.names,
170
+ };
171
+ }
172
+ catch (error) {
173
+ logger.debug('[extensions-scan] Unexpected error:', error);
174
+ return {
175
+ project: { ...emptyCount },
176
+ global: { ...emptyCount },
177
+ projectNames: { ...emptyNames },
178
+ globalNames: { ...emptyNames },
179
+ };
180
+ }
181
+ }
182
+ //# sourceMappingURL=extensions-scan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensions-scan.js","sourceRoot":"","sources":["../../src/utils/extensions-scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAMrC,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAEhE,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E;;;GAGG;AACH,SAAS,qBAAqB,CAAC,OAAe,EAAE,GAAW;IACzD,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC;AAED,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E;;;;;;;;GAQG;AACH,KA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,GAAG,UAAU,EAAE,EAAE,CAAC;YAC5E,gBAAgB,CAAC,MAAM;gBACrB,CAAC,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,eAAe,CAAC;gBACzF,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,UAAU,EAAE,EAAE,CAAC;SAC7E,CAAC,CAAC;QAEH,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE;YAC9C,OAAO,EAAE,aAAa,CAAC,MAAM;YAC7B,MAAM,EAAE,YAAY,CAAC,MAAM;SAC5B,CAAC,CAAC;QAEH,OAAO;YACL,OAAO,EAAE,aAAa,CAAC,MAAM;YAC7B,MAAM,EAAE,YAAY,CAAC,MAAM;YAC3B,YAAY,EAAE,aAAa,CAAC,KAAK;YACjC,WAAW,EAAE,YAAY,CAAC,KAAK;SAChC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;QAC3D,OAAO;YACL,OAAO,EAAE,EAAE,GAAG,UAAU,EAAE;YAC1B,MAAM,EAAE,EAAE,GAAG,UAAU,EAAE;YACzB,YAAY,EAAE,EAAE,GAAG,UAAU,EAAE;YAC/B,WAAW,EAAE,EAAE,GAAG,UAAU,EAAE;SAC/B,CAAC;IACJ,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemieai/code",
3
- "version": "0.0.43",
3
+ "version": "0.0.45",
4
4
  "description": "Unified AI coding assistant CLI - Manage Claude Code, Gemini & custom agents. Multi-provider support (OpenAI, Azure, LiteLLM, SSO). Built-in LangGraph agent with file operations & git integration.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",