am-i-vibing 0.0.4 → 0.1.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.
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/{detector-BEnp3d4c.js → detector-LEsE74_L.js} +23 -11
- package/dist/detector-LEsE74_L.js.map +1 -0
- package/dist/index.d.ts +12 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +4 -4
- package/dist/detector-BEnp3d4c.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { detectAgenticEnvironment, isAgent, isHybrid, isInteractive } from "./detector-
|
|
2
|
+
import { detectAgenticEnvironment, isAgent, isHybrid, isInteractive } from "./detector-LEsE74_L.js";
|
|
3
3
|
import { parseArgs } from "node:util";
|
|
4
4
|
import { getProcessAncestry } from "process-ancestry";
|
|
5
5
|
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":["checkType: string","result: ReturnType<typeof detectAgenticEnvironment>","options: CliOptions","processAncestry: any[]"],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { parseArgs } from \"node:util\";\nimport { getProcessAncestry } from \"process-ancestry\";\nimport {\n detectAgenticEnvironment,\n isAgent,\n isInteractive,\n isHybrid,\n} from \"./detector.js\";\n\ninterface CliOptions {\n format?: \"json\" | \"text\";\n check?: \"agent\" | \"interactive\" | \"hybrid\";\n quiet?: boolean;\n help?: boolean;\n debug?: boolean;\n}\n\nfunction parseCliArgs(): CliOptions {\n const { values } = parseArgs({\n args: process.argv.slice(2),\n options: {\n format: {\n type: \"string\",\n short: \"f\",\n default: \"text\",\n },\n check: {\n type: \"string\",\n short: \"c\",\n },\n quiet: {\n type: \"boolean\",\n short: \"q\",\n default: false,\n },\n help: {\n type: \"boolean\",\n short: \"h\",\n default: false,\n },\n debug: {\n type: \"boolean\",\n short: \"d\",\n default: false,\n },\n },\n allowPositionals: false,\n });\n\n // Validate format option\n if (values.format && ![\"json\", \"text\"].includes(values.format)) {\n console.error(\n `Error: Invalid format '${values.format}'. Must be 'json' or 'text'.`,\n );\n process.exit(1);\n }\n\n // Validate check option\n if (values.check && ![\"agent\", \"interactive\", \"hybrid\"].includes(values.check)) {\n console.error(\n `Error: Invalid check type '${values.check}'. Must be 'agent', 'interactive', or 'hybrid'.`,\n );\n process.exit(1);\n }\n\n return {\n format: values.format as \"json\" | \"text\",\n check: values.check as \"agent\" | \"interactive\" | \"hybrid\",\n quiet: values.quiet,\n help: values.help,\n debug: values.debug,\n };\n}\n\nfunction showHelp(): void {\n console.log(`\nam-i-vibing - Detect agentic coding environments\n\nUSAGE:\n npx am-i-vibing [OPTIONS]\n\nOPTIONS:\n -f, --format <json|text> Output format (default: text)\n -c, --check <agent|interactive|hybrid> Check for specific environment type\n -q, --quiet Only output result, no labels\n -d, --debug Debug output with environment and process info\n -h, --help Show this help message\n\nEXAMPLES:\n npx am-i-vibing # Detect current environment\n npx am-i-vibing --format json # JSON output\n npx am-i-vibing --check agent # Check if running under agent\n npx am-i-vibing --check hybrid # Check if running under hybrid\n npx am-i-vibing --quiet # Minimal output\n npx am-i-vibing --debug # Debug with full environment info\n\nEXIT CODES:\n 0 Agentic environment detected (or specific check passed)\n 1 No agentic environment detected (or specific check failed)\n`);\n}\n\nfunction checkEnvironmentType(checkType: string): boolean {\n switch (checkType) {\n case \"agent\":\n return isAgent();\n case \"interactive\":\n return isInteractive();\n case \"hybrid\":\n return isHybrid();\n default:\n return false;\n }\n}\n\nfunction formatOutput(\n result: ReturnType<typeof detectAgenticEnvironment>,\n options: CliOptions,\n): string {\n if (options.debug) {\n let processAncestry: any[] = [];\n try {\n processAncestry = getProcessAncestry();\n } catch (error) {\n processAncestry = [{ error: \"Failed to get process ancestry\" }];\n }\n\n const debugOutput = {\n detection: result,\n environment: process.env,\n processAncestry,\n };\n return JSON.stringify(debugOutput, null, 2);\n }\n\n if (options.format === \"json\") {\n return JSON.stringify(result, null, 2);\n }\n\n if (options.quiet) {\n if (options.check) {\n return checkEnvironmentType(options.check) ? \"true\" : \"false\";\n }\n return result.isAgentic ? `${result.name}` : \"none\";\n }\n\n if (options.check) {\n const matches = checkEnvironmentType(options.check);\n return matches\n ? `✓ Running in ${options.check} environment: ${result.name}`\n : `✗ Not running in ${options.check} environment`;\n }\n\n if (!result.isAgentic) {\n return \"✗ No agentic environment detected\";\n }\n\n return `✓ Detected: [${result.id}] ${result.name} (${result.type})`;\n}\n\nfunction main(): void {\n const options = parseCliArgs();\n\n if (options.help) {\n showHelp();\n process.exit(0);\n }\n\n const result = detectAgenticEnvironment();\n let exitCode = 1;\n\n if (options.check) {\n exitCode = checkEnvironmentType(options.check) ? 0 : 1;\n } else {\n exitCode = result.isAgentic ? 0 : 1;\n }\n\n const output = formatOutput(result, options);\n console.log(output);\n\n process.exit(exitCode);\n}\n\nmain();\n"],"mappings":";;;;;;AAmBA,SAAS,eAA2B;CAClC,MAAM,EAAE,QAAQ,GAAG,UAAU;EAC3B,MAAM,QAAQ,KAAK,MAAM,EAAE;EAC3B,SAAS;GACP,QAAQ;IACN,MAAM;IACN,OAAO;IACP,SAAS;GACV;GACD,OAAO;IACL,MAAM;IACN,OAAO;GACR;GACD,OAAO;IACL,MAAM;IACN,OAAO;IACP,SAAS;GACV;GACD,MAAM;IACJ,MAAM;IACN,OAAO;IACP,SAAS;GACV;GACD,OAAO;IACL,MAAM;IACN,OAAO;IACP,SAAS;GACV;EACF;EACD,kBAAkB;CACnB,EAAC;AAGF,KAAI,OAAO,
|
|
1
|
+
{"version":3,"file":"cli.js","names":["checkType: string","result: ReturnType<typeof detectAgenticEnvironment>","options: CliOptions","processAncestry: any[]"],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { parseArgs } from \"node:util\";\nimport { getProcessAncestry } from \"process-ancestry\";\nimport {\n detectAgenticEnvironment,\n isAgent,\n isInteractive,\n isHybrid,\n} from \"./detector.js\";\n\ninterface CliOptions {\n format?: \"json\" | \"text\";\n check?: \"agent\" | \"interactive\" | \"hybrid\";\n quiet?: boolean;\n help?: boolean;\n debug?: boolean;\n}\n\nfunction parseCliArgs(): CliOptions {\n const { values } = parseArgs({\n args: process.argv.slice(2),\n options: {\n format: {\n type: \"string\",\n short: \"f\",\n default: \"text\",\n },\n check: {\n type: \"string\",\n short: \"c\",\n },\n quiet: {\n type: \"boolean\",\n short: \"q\",\n default: false,\n },\n help: {\n type: \"boolean\",\n short: \"h\",\n default: false,\n },\n debug: {\n type: \"boolean\",\n short: \"d\",\n default: false,\n },\n },\n allowPositionals: false,\n });\n\n // Validate format option\n if (values.format && ![\"json\", \"text\"].includes(values.format)) {\n console.error(\n `Error: Invalid format '${values.format}'. Must be 'json' or 'text'.`,\n );\n process.exit(1);\n }\n\n // Validate check option\n if (values.check && ![\"agent\", \"interactive\", \"hybrid\"].includes(values.check)) {\n console.error(\n `Error: Invalid check type '${values.check}'. Must be 'agent', 'interactive', or 'hybrid'.`,\n );\n process.exit(1);\n }\n\n return {\n format: values.format as \"json\" | \"text\",\n check: values.check as \"agent\" | \"interactive\" | \"hybrid\",\n quiet: values.quiet,\n help: values.help,\n debug: values.debug,\n };\n}\n\nfunction showHelp(): void {\n console.log(`\nam-i-vibing - Detect agentic coding environments\n\nUSAGE:\n npx am-i-vibing [OPTIONS]\n\nOPTIONS:\n -f, --format <json|text> Output format (default: text)\n -c, --check <agent|interactive|hybrid> Check for specific environment type\n -q, --quiet Only output result, no labels\n -d, --debug Debug output with environment and process info\n -h, --help Show this help message\n\nEXAMPLES:\n npx am-i-vibing # Detect current environment\n npx am-i-vibing --format json # JSON output\n npx am-i-vibing --check agent # Check if running under agent\n npx am-i-vibing --check hybrid # Check if running under hybrid\n npx am-i-vibing --quiet # Minimal output\n npx am-i-vibing --debug # Debug with full environment info\n\nEXIT CODES:\n 0 Agentic environment detected (or specific check passed)\n 1 No agentic environment detected (or specific check failed)\n`);\n}\n\nfunction checkEnvironmentType(checkType: string): boolean {\n switch (checkType) {\n case \"agent\":\n return isAgent();\n case \"interactive\":\n return isInteractive();\n case \"hybrid\":\n return isHybrid();\n default:\n return false;\n }\n}\n\nfunction formatOutput(\n result: ReturnType<typeof detectAgenticEnvironment>,\n options: CliOptions,\n): string {\n if (options.debug) {\n let processAncestry: any[] = [];\n try {\n processAncestry = getProcessAncestry();\n } catch (error) {\n processAncestry = [{ error: \"Failed to get process ancestry\" }];\n }\n\n const debugOutput = {\n detection: result,\n environment: process.env,\n processAncestry,\n };\n return JSON.stringify(debugOutput, null, 2);\n }\n\n if (options.format === \"json\") {\n return JSON.stringify(result, null, 2);\n }\n\n if (options.quiet) {\n if (options.check) {\n return checkEnvironmentType(options.check) ? \"true\" : \"false\";\n }\n return result.isAgentic ? `${result.name}` : \"none\";\n }\n\n if (options.check) {\n const matches = checkEnvironmentType(options.check);\n return matches\n ? `✓ Running in ${options.check} environment: ${result.name}`\n : `✗ Not running in ${options.check} environment`;\n }\n\n if (!result.isAgentic) {\n return \"✗ No agentic environment detected\";\n }\n\n return `✓ Detected: [${result.id}] ${result.name} (${result.type})`;\n}\n\nfunction main(): void {\n const options = parseCliArgs();\n\n if (options.help) {\n showHelp();\n process.exit(0);\n }\n\n const result = detectAgenticEnvironment();\n let exitCode = 1;\n\n if (options.check) {\n exitCode = checkEnvironmentType(options.check) ? 0 : 1;\n } else {\n exitCode = result.isAgentic ? 0 : 1;\n }\n\n const output = formatOutput(result, options);\n console.log(output);\n\n process.exit(exitCode);\n}\n\nmain();\n"],"mappings":";;;;;;AAmBA,SAAS,eAA2B;CAClC,MAAM,EAAE,QAAQ,GAAG,UAAU;EAC3B,MAAM,QAAQ,KAAK,MAAM,EAAE;EAC3B,SAAS;GACP,QAAQ;IACN,MAAM;IACN,OAAO;IACP,SAAS;GACV;GACD,OAAO;IACL,MAAM;IACN,OAAO;GACR;GACD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AK,UAAU,QAAQ,MAAM,EAAE;AAGxC,KAAI,QAAQ,OAAO;AACjB,MAAI,QAAQ,MACV,QAAO,qBAAqB,QAAQ,MAAM,GAAG,SAAS;AAExD,SAAO,OAAO,YAAY,GAAG,OAAO,MAAM,GAAG;CAC9C;AAED,KAAI,QAAQ,OAAO;EACjB,MAAM,UAAU,qBAAqB,QAAQ,MAAM;AACnD,SAAO,UACH,CAAC,aAAa,EAAE,QAAQ,MAAM,cAAc,EAAE,OAAO,MAAM,GAC3D,CAAC,iBAAiB,EAAE,QAAQ,MAAM,YAAY,CAAC;CACpD;AAED,KAAI,CAAC,OAAO,UACV,QAAO;AAGT,QAAO,CAAC,aAAa,EAAE,OAAO,GAAG,EAAE,EAAE,OAAO,KAAK,EAAE,EAAE,OAAO,KAAK,CAAC,CAAC;AACpE;AAED,SAAS,OAAa;CACpB,MAAM,UAAU,cAAc;AAE9B,KAAI,QAAQ,MAAM;EAChB,UAAU;EACV,QAAQ,KAAK,EAAE;CAChB;CAED,MAAM,SAAS,0BAA0B;CACzC,IAAI,WAAW;AAEf,KAAI,QAAQ,OACV,WAAW,qBAAqB,QAAQ,MAAM,GAAG,IAAI;MAErD,WAAW,OAAO,YAAY,IAAI;CAGpC,MAAM,SAAS,aAAa,QAAQ,QAAQ;CAC5C,QAAQ,IAAI,OAAO;CAEnB,QAAQ,KAAK,SAAS;AACvB;AAED,MAAM"}
|
|
@@ -116,6 +116,12 @@ const providers = [
|
|
|
116
116
|
type: "agent",
|
|
117
117
|
envVars: ["CODEIUM_EDITOR_APP_ROOT"]
|
|
118
118
|
},
|
|
119
|
+
{
|
|
120
|
+
id: "crush",
|
|
121
|
+
name: "Crush",
|
|
122
|
+
type: "agent",
|
|
123
|
+
processChecks: ["crush"]
|
|
124
|
+
},
|
|
119
125
|
{
|
|
120
126
|
id: "vscode-copilot-agent",
|
|
121
127
|
name: "GitHub Copilot in VS Code",
|
|
@@ -127,6 +133,12 @@ const providers = [
|
|
|
127
133
|
name: "Warp Terminal",
|
|
128
134
|
type: "hybrid",
|
|
129
135
|
envVars: [{ all: [["TERM_PROGRAM", "WarpTerminal"]] }]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: "octofriend",
|
|
139
|
+
name: "Octofriend",
|
|
140
|
+
type: "agent",
|
|
141
|
+
processChecks: ["octofriend"]
|
|
130
142
|
}
|
|
131
143
|
];
|
|
132
144
|
/**
|
|
@@ -155,9 +167,9 @@ function checkEnvVar(envVarDef, env = process.env) {
|
|
|
155
167
|
/**
|
|
156
168
|
* Check if a process is running in the process tree
|
|
157
169
|
*/
|
|
158
|
-
function checkProcess(processName) {
|
|
170
|
+
function checkProcess(processName, processAncestry) {
|
|
159
171
|
try {
|
|
160
|
-
const ancestry = getProcessAncestry();
|
|
172
|
+
const ancestry = processAncestry ?? getProcessAncestry();
|
|
161
173
|
for (const ancestorProcess of ancestry) if (ancestorProcess.command?.includes(processName)) return true;
|
|
162
174
|
} catch (error) {}
|
|
163
175
|
return false;
|
|
@@ -199,10 +211,10 @@ function createDetectedResult(provider) {
|
|
|
199
211
|
/**
|
|
200
212
|
* Detect agentic coding environment
|
|
201
213
|
*/
|
|
202
|
-
function detectAgenticEnvironment(env = process.env) {
|
|
214
|
+
function detectAgenticEnvironment(env = process.env, processAncestry) {
|
|
203
215
|
for (const provider of providers) {
|
|
204
216
|
if (provider.envVars?.some((group) => checkEnvVars(group, env))) return createDetectedResult(provider);
|
|
205
|
-
if (provider.processChecks?.some(checkProcess)) return createDetectedResult(provider);
|
|
217
|
+
if (provider.processChecks?.some((processName) => checkProcess(processName, processAncestry))) return createDetectedResult(provider);
|
|
206
218
|
if (runCustomDetectors(provider)) return createDetectedResult(provider);
|
|
207
219
|
}
|
|
208
220
|
return {
|
|
@@ -215,25 +227,25 @@ function detectAgenticEnvironment(env = process.env) {
|
|
|
215
227
|
/**
|
|
216
228
|
* Check if currently running in any agent environment
|
|
217
229
|
*/
|
|
218
|
-
function isAgent(env = process.env) {
|
|
219
|
-
const result = detectAgenticEnvironment(env);
|
|
230
|
+
function isAgent(env = process.env, processAncestry) {
|
|
231
|
+
const result = detectAgenticEnvironment(env, processAncestry);
|
|
220
232
|
return result.type === "agent" || result.type === "hybrid";
|
|
221
233
|
}
|
|
222
234
|
/**
|
|
223
235
|
* Check if currently running in any interactive AI environment
|
|
224
236
|
*/
|
|
225
|
-
function isInteractive(env = process.env) {
|
|
226
|
-
const result = detectAgenticEnvironment(env);
|
|
237
|
+
function isInteractive(env = process.env, processAncestry) {
|
|
238
|
+
const result = detectAgenticEnvironment(env, processAncestry);
|
|
227
239
|
return result.type === "interactive" || result.type === "hybrid";
|
|
228
240
|
}
|
|
229
241
|
/**
|
|
230
242
|
* Check if currently running in any hybrid AI environment
|
|
231
243
|
*/
|
|
232
|
-
function isHybrid(env = process.env) {
|
|
233
|
-
const result = detectAgenticEnvironment(env);
|
|
244
|
+
function isHybrid(env = process.env, processAncestry) {
|
|
245
|
+
const result = detectAgenticEnvironment(env, processAncestry);
|
|
234
246
|
return result.type === "hybrid";
|
|
235
247
|
}
|
|
236
248
|
|
|
237
249
|
//#endregion
|
|
238
250
|
export { detectAgenticEnvironment, getProvider, getProvidersByType, isAgent, isHybrid, isInteractive, providers };
|
|
239
|
-
//# sourceMappingURL=detector-
|
|
251
|
+
//# sourceMappingURL=detector-LEsE74_L.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detector-LEsE74_L.js","names":["providers: ProviderConfig[]","name: string","type: \"agent\" | \"interactive\" | \"hybrid\"","envVarDef: EnvVarDefinition","env: Record<string, string | undefined>","processName: string","processAncestry?: Array<{ command?: string }>","definition: EnvVarGroup | EnvVarDefinition","provider: ProviderConfig"],"sources":["../src/providers.ts","../src/detector.ts"],"sourcesContent":["import type { ProviderConfig } from \"./types.js\";\n\n/**\n * Provider configurations for major AI coding tools\n */\nexport const providers: ProviderConfig[] = [\n {\n id: \"sst-opencode\",\n name: \"SST OpenCode\",\n type: \"agent\",\n envVars: [\n {\n any: [\n \"OPENCODE_BIN_PATH\",\n \"OPENCODE_SERVER\",\n \"OPENCODE_APP_INFO\",\n \"OPENCODE_MODES\",\n ],\n },\n ],\n },\n {\n id: \"jules\",\n name: \"Jules\",\n type: \"agent\",\n envVars: [{ all: [[\"HOME\", \"/home/jules\"], [\"USER\", \"swebot\"]] }],\n },\n {\n id: \"claude-code\",\n name: \"Claude Code\",\n type: \"agent\",\n envVars: [\"CLAUDECODE\"],\n },\n {\n id: \"cursor-agent\",\n name: \"Cursor Agent\",\n type: \"agent\",\n envVars: [\n {\n all: [\"CURSOR_TRACE_ID\", [\"PAGER\", \"head -n 10000 | cat\"]],\n },\n ],\n },\n {\n id: \"cursor\",\n name: \"Cursor\",\n type: \"interactive\",\n envVars: [\"CURSOR_TRACE_ID\"],\n },\n {\n id: \"gemini-agent\",\n name: \"Gemini Agent\",\n type: \"agent\",\n processChecks: [\"gemini\"],\n },\n {\n id: \"codex\",\n name: \"OpenAI Codex\",\n type: \"agent\",\n processChecks: [\"codex\"],\n },\n {\n id: \"replit\",\n name: \"Replit\",\n type: \"agent\",\n envVars: [\"REPL_ID\"],\n },\n {\n id: \"aider\",\n name: \"Aider\",\n type: \"agent\",\n envVars: [\"AIDER_API_KEY\"],\n processChecks: [\"aider\"],\n },\n {\n id: \"bolt-agent\",\n name: \"Bolt.new Agent\",\n type: \"agent\",\n envVars: [\n {\n all: [[\"SHELL\", \"/bin/jsh\"], \"npm_config_yes\"],\n },\n ],\n },\n {\n id: \"bolt\",\n name: \"Bolt.new\",\n type: \"interactive\",\n envVars: [\n {\n all: [[\"SHELL\", \"/bin/jsh\"]],\n none: [\"npm_config_yes\"],\n },\n ],\n },\n {\n id: \"zed-agent\",\n name: \"Zed Agent\",\n type: \"agent\",\n envVars: [\n {\n all: [\n [\"TERM_PROGRAM\", \"zed\"],\n [\"PAGER\", \"cat\"],\n ],\n },\n ],\n },\n {\n id: \"zed\",\n name: \"Zed\",\n type: \"interactive\",\n envVars: [\n {\n all: [[\"TERM_PROGRAM\", \"zed\"]],\n none: [[\"PAGER\", \"cat\"]],\n },\n ],\n },\n {\n id: \"replit-assistant\",\n name: \"Replit Assistant\",\n type: \"agent\",\n envVars: [\n {\n all: [\"REPL_ID\", [\"REPLIT_MODE\", \"assistant\"]],\n },\n ],\n },\n {\n id: \"replit\",\n name: \"Replit\",\n type: \"interactive\",\n envVars: [\n {\n all: [\"REPL_ID\"],\n none: [[\"REPLIT_MODE\", \"assistant\"]],\n },\n ],\n },\n {\n id: \"windsurf\",\n name: \"Windsurf\",\n type: \"agent\",\n envVars: [\"CODEIUM_EDITOR_APP_ROOT\"],\n },\n {\n id: \"crush\",\n name: \"Crush\",\n type: \"agent\",\n processChecks: [\"crush\"],\n },\n {\n id: \"vscode-copilot-agent\",\n name: \"GitHub Copilot in VS Code\",\n type: \"agent\",\n envVars: [\n {\n all: [\n [\"TERM_PROGRAM\", \"vscode\"],\n [\"GIT_PAGER\", \"cat\"],\n ],\n },\n ],\n },\n {\n id: \"warp\",\n name: \"Warp Terminal\",\n type: \"hybrid\",\n envVars: [\n {\n all: [\n [\"TERM_PROGRAM\", \"WarpTerminal\"],\n ],\n },\n ],\n },\n {\n id: \"octofriend\",\n name: \"Octofriend\",\n type: \"agent\",\n processChecks: [\"octofriend\"],\n },\n];\n\n/**\n * Get provider configuration by name\n */\nexport function getProvider(name: string): ProviderConfig | undefined {\n return providers.find((p) => p.name === name);\n}\n\n/**\n * Get all providers of a specific type\n */\nexport function getProvidersByType(\n type: \"agent\" | \"interactive\" | \"hybrid\",\n): ProviderConfig[] {\n return providers.filter((p) => p.type === type);\n}\n","import type {\n DetectionResult,\n ProviderConfig,\n EnvVarDefinition,\n EnvVarGroup,\n} from \"./types.js\";\nimport { providers } from \"./providers.js\";\nimport { getProcessAncestry } from \"process-ancestry\";\n\n/**\n * Check if a specific environment variable exists (handles both strings and tuples)\n */\nfunction checkEnvVar(\n envVarDef: EnvVarDefinition,\n env: Record<string, string | undefined> = process.env,\n): boolean {\n const [envVar, expectedValue] =\n typeof envVarDef === \"string\" ? [envVarDef, undefined] : envVarDef;\n\n const actualValue = env[envVar];\n return Boolean(\n actualValue && (!expectedValue || actualValue === expectedValue),\n );\n}\n\n/**\n * Check if a process is running in the process tree\n */\nfunction checkProcess(\n processName: string,\n processAncestry?: Array<{ command?: string }>,\n): boolean {\n try {\n const ancestry = processAncestry ?? getProcessAncestry();\n for (const ancestorProcess of ancestry) {\n if (ancestorProcess.command?.includes(processName)) {\n return true;\n }\n }\n } catch (error) {\n // Ignore process check errors\n }\n return false;\n}\n\n/**\n * Check if an environment variable group matches based on its properties\n */\nfunction checkEnvVars(\n definition: EnvVarGroup | EnvVarDefinition,\n env: Record<string, string | undefined> = process.env,\n): boolean {\n if (typeof definition === \"string\" || Array.isArray(definition)) {\n return checkEnvVar(definition, env);\n }\n\n const { any, all, none } = definition;\n\n // Check ANY conditions (OR logic) - at least one must pass\n const anyResult =\n !any?.length || any.some((envVar) => checkEnvVar(envVar, env));\n\n // Check ALL conditions (AND logic) - all must pass\n const allResult =\n !all?.length || all.every((envVar) => checkEnvVar(envVar, env));\n\n // Check NONE conditions (NOT logic) - none should pass\n const noneResult =\n !none?.length || !none.some((envVar) => checkEnvVar(envVar, env));\n\n return anyResult && allResult && noneResult;\n}\n\n/**\n * Run custom detectors for a provider\n */\nfunction runCustomDetectors(provider: ProviderConfig): boolean {\n return (\n provider.customDetectors?.some((detector) => {\n try {\n return detector();\n } catch {\n return false;\n }\n }) ?? false\n );\n}\n\n/**\n * Create a positive detection result\n */\nfunction createDetectedResult(provider: ProviderConfig): DetectionResult {\n return {\n isAgentic: true,\n id: provider.id,\n name: provider.name,\n type: provider.type,\n };\n}\n\n/**\n * Detect agentic coding environment\n */\nexport function detectAgenticEnvironment(\n env: Record<string, string | undefined> = process.env,\n processAncestry?: Array<{ command?: string }>,\n): DetectionResult {\n for (const provider of providers) {\n // Check environment variables\n if (provider.envVars?.some((group) => checkEnvVars(group, env))) {\n return createDetectedResult(provider);\n }\n\n // Check processes\n if (provider.processChecks?.some((processName) => checkProcess(processName, processAncestry))) {\n return createDetectedResult(provider);\n }\n\n // Run custom detectors\n if (runCustomDetectors(provider)) {\n return createDetectedResult(provider);\n }\n }\n\n // No provider detected\n return {\n isAgentic: false,\n id: null,\n name: null,\n type: null,\n };\n}\n\n/**\n * Check if currently running in a specific provider\n */\nexport function isProvider(\n providerName: string,\n env: Record<string, string | undefined> = process.env,\n processAncestry?: Array<{ command?: string }>,\n): boolean {\n const result = detectAgenticEnvironment(env, processAncestry);\n return result.name === providerName;\n}\n\n/**\n * Check if currently running in any agent environment\n */\nexport function isAgent(\n env: Record<string, string | undefined> = process.env,\n processAncestry?: Array<{ command?: string }>,\n): boolean {\n const result = detectAgenticEnvironment(env, processAncestry);\n return result.type === \"agent\" || result.type === \"hybrid\";\n}\n\n/**\n * Check if currently running in any interactive AI environment\n */\nexport function isInteractive(\n env: Record<string, string | undefined> = process.env,\n processAncestry?: Array<{ command?: string }>,\n): boolean {\n const result = detectAgenticEnvironment(env, processAncestry);\n return result.type === \"interactive\" || result.type === \"hybrid\";\n}\n\n/**\n * Check if currently running in any hybrid AI environment\n */\nexport function isHybrid(\n env: Record<string, string | undefined> = process.env,\n processAncestry?: Array<{ command?: string }>,\n): boolean {\n const result = detectAgenticEnvironment(env, processAncestry);\n return result.type === \"hybrid\";\n}\n"],"mappings":";;;;;;AAKA,MAAaA,YAA8B;CACzC;EACE,IAAI;EACJ,MAAM;EACN,MAAM;EACN,SAAS,CACP,EACE,KAAK;GACH;GACA;GACA;GACA;EACD,EACF,CACF;CACF;CACD;EACE,IAAI;EACJ,MAAM;EACN,MAAM;EACN,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC,QAAQ,aAAc,GAAE,CAAC,QAAQ,QAAS,CAAC,EAAE,CAAC;CAClE;CACD;EACE,IAAI;EACJ,MAAM;EACN,MAAM;EACN,SAAS,CAAC,YAAa;CACxB;CACD;EACE,IAAI;EACJ,MAA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,gBAAgB;AAC7D,QAAO,OAAO,SAAS,iBAAiB,OAAO,SAAS;AACzD;;;;AAKD,SAAgB,SACdF,MAA0C,QAAQ,KAClDE,iBACS;CACT,MAAM,SAAS,yBAAyB,KAAK,gBAAgB;AAC7D,QAAO,OAAO,SAAS;AACxB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -48,7 +48,6 @@ interface DetectionResult {
|
|
|
48
48
|
/** Type of agentic environment, if detected */
|
|
49
49
|
type: AgenticType | null;
|
|
50
50
|
}
|
|
51
|
-
//# sourceMappingURL=types.d.ts.map
|
|
52
51
|
//#endregion
|
|
53
52
|
//#region src/providers.d.ts
|
|
54
53
|
/**
|
|
@@ -63,13 +62,14 @@ declare function getProvider(name: string): ProviderConfig | undefined;
|
|
|
63
62
|
* Get all providers of a specific type
|
|
64
63
|
*/
|
|
65
64
|
declare function getProvidersByType(type: "agent" | "interactive" | "hybrid"): ProviderConfig[];
|
|
66
|
-
//# sourceMappingURL=providers.d.ts.map
|
|
67
65
|
//#endregion
|
|
68
66
|
//#region src/detector.d.ts
|
|
69
67
|
/**
|
|
70
68
|
* Detect agentic coding environment
|
|
71
69
|
*/
|
|
72
|
-
declare function detectAgenticEnvironment(env?: Record<string, string | undefined
|
|
70
|
+
declare function detectAgenticEnvironment(env?: Record<string, string | undefined>, processAncestry?: Array<{
|
|
71
|
+
command?: string;
|
|
72
|
+
}>): DetectionResult;
|
|
73
73
|
/**
|
|
74
74
|
* Check if currently running in a specific provider
|
|
75
75
|
*/
|
|
@@ -77,17 +77,21 @@ declare function detectAgenticEnvironment(env?: Record<string, string | undefine
|
|
|
77
77
|
/**
|
|
78
78
|
* Check if currently running in any agent environment
|
|
79
79
|
*/
|
|
80
|
-
declare function isAgent(env?: Record<string, string | undefined
|
|
80
|
+
declare function isAgent(env?: Record<string, string | undefined>, processAncestry?: Array<{
|
|
81
|
+
command?: string;
|
|
82
|
+
}>): boolean;
|
|
81
83
|
/**
|
|
82
84
|
* Check if currently running in any interactive AI environment
|
|
83
85
|
*/
|
|
84
|
-
declare function isInteractive(env?: Record<string, string | undefined
|
|
86
|
+
declare function isInteractive(env?: Record<string, string | undefined>, processAncestry?: Array<{
|
|
87
|
+
command?: string;
|
|
88
|
+
}>): boolean;
|
|
85
89
|
/**
|
|
86
90
|
* Check if currently running in any hybrid AI environment
|
|
87
91
|
*/
|
|
88
|
-
declare function isHybrid(env?: Record<string, string | undefined
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
declare function isHybrid(env?: Record<string, string | undefined>, processAncestry?: Array<{
|
|
93
|
+
command?: string;
|
|
94
|
+
}>): boolean;
|
|
91
95
|
//#endregion
|
|
92
96
|
export { type AgenticType, type DetectionResult, type ProviderConfig, detectAgenticEnvironment as default, detectAgenticEnvironment, getProvider, getProvidersByType, isAgent, isHybrid, isInteractive, providers };
|
|
93
97
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/providers.ts","../src/detector.ts"],"sourcesContent":[],"mappings":";;AAGA;AAKA;AAKiB,KAVL,WAAA,GAUgB,OAAA,GAAA,aAAA,GAAA,QAAA;;;;AAQnB,KAbG,gBAAA,GAaH,MAAA,GAAA,CAAA,MAAA,EAAA,MAAA,CAAA;AAAgB;AAMzB;;AAQQ,UAtBS,WAAA,CAsBT;EAAW;EAGU,GAAG,CAAA,EAvBxB,gBAuBwB,EAAA;EAAgB;EAA/B,GAAA,CAAA,EApBT,gBAoBS,EAAA;EAYA;SA7BR;;;AChBT;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/providers.ts","../src/detector.ts"],"sourcesContent":[],"mappings":";;AAGA;AAKA;AAKiB,KAVL,WAAA,GAUgB,OAAA,GAAA,aAAA,GAAA,QAAA;;;;AAQnB,KAbG,gBAAA,GAaH,MAAA,GAAA,CAAA,MAAA,EAAA,MAAA,CAAA;A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FC,KFzFD,CAAA;;;;ACxDnB;AAuLA;AAOgB,iBCpCA,aAAA,CDsCb,GAAc,CAAd,ECrCI,MDqCU,CAAA,MAAA,EAAA,MAAA,GAAA,SAAA,CAAA,EAAA,gBAAA,ECpCG,KDoCH,CAAA;;;;AC9FjB;;AACO,iBAkES,QAAA,CAlET,GAAA,CAAA,EAmEA,MAnEA,CAAA,MAAA,EAAA,MAAA,GAAA,SAAA,CAAA,EAAA,eACkB,CADlB,EAoEa,KApEb,CAAA;EAAM,OACO,CAAA,EAAA,MAAA;CAAK,CAAA,CAAA,EAAA,OACtB"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { detectAgenticEnvironment, getProvider, getProvidersByType, isAgent, isHybrid, isInteractive, providers } from "./detector-
|
|
1
|
+
import { detectAgenticEnvironment, getProvider, getProvidersByType, isAgent, isHybrid, isInteractive, providers } from "./detector-LEsE74_L.js";
|
|
2
2
|
|
|
3
3
|
//#region src/index.ts
|
|
4
4
|
var src_default = detectAgenticEnvironment;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "am-i-vibing",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Detect agentic coding environments and AI assistant tools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
18
|
-
"@types/node": "^22.
|
|
18
|
+
"@types/node": "^22.17.0",
|
|
19
19
|
"publint": "^0.3.12",
|
|
20
|
-
"tsdown": "^0.
|
|
21
|
-
"typescript": "^5.
|
|
20
|
+
"tsdown": "^0.13.3",
|
|
21
|
+
"typescript": "^5.9.2",
|
|
22
22
|
"vitest": "^3.2.4"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detector-BEnp3d4c.js","names":["providers: ProviderConfig[]","name: string","type: \"agent\" | \"interactive\" | \"hybrid\"","envVarDef: EnvVarDefinition","env: Record<string, string | undefined>","processName: string","definition: EnvVarGroup | EnvVarDefinition","provider: ProviderConfig"],"sources":["../src/providers.ts","../src/detector.ts"],"sourcesContent":["import type { ProviderConfig } from \"./types.js\";\n\n/**\n * Provider configurations for major AI coding tools\n */\nexport const providers: ProviderConfig[] = [\n {\n id: \"sst-opencode\",\n name: \"SST OpenCode\",\n type: \"agent\",\n envVars: [\n {\n any: [\n \"OPENCODE_BIN_PATH\",\n \"OPENCODE_SERVER\",\n \"OPENCODE_APP_INFO\",\n \"OPENCODE_MODES\",\n ],\n },\n ],\n },\n {\n id: \"jules\",\n name: \"Jules\",\n type: \"agent\",\n envVars: [{ all: [[\"HOME\", \"/home/jules\"], [\"USER\", \"swebot\"]] }],\n },\n {\n id: \"claude-code\",\n name: \"Claude Code\",\n type: \"agent\",\n envVars: [\"CLAUDECODE\"],\n },\n {\n id: \"cursor-agent\",\n name: \"Cursor Agent\",\n type: \"agent\",\n envVars: [\n {\n all: [\"CURSOR_TRACE_ID\", [\"PAGER\", \"head -n 10000 | cat\"]],\n },\n ],\n },\n {\n id: \"cursor\",\n name: \"Cursor\",\n type: \"interactive\",\n envVars: [\"CURSOR_TRACE_ID\"],\n },\n {\n id: \"gemini-agent\",\n name: \"Gemini Agent\",\n type: \"agent\",\n processChecks: [\"gemini\"],\n },\n {\n id: \"codex\",\n name: \"OpenAI Codex\",\n type: \"agent\",\n processChecks: [\"codex\"],\n },\n {\n id: \"replit\",\n name: \"Replit\",\n type: \"agent\",\n envVars: [\"REPL_ID\"],\n },\n {\n id: \"aider\",\n name: \"Aider\",\n type: \"agent\",\n envVars: [\"AIDER_API_KEY\"],\n processChecks: [\"aider\"],\n },\n {\n id: \"bolt-agent\",\n name: \"Bolt.new Agent\",\n type: \"agent\",\n envVars: [\n {\n all: [[\"SHELL\", \"/bin/jsh\"], \"npm_config_yes\"],\n },\n ],\n },\n {\n id: \"bolt\",\n name: \"Bolt.new\",\n type: \"interactive\",\n envVars: [\n {\n all: [[\"SHELL\", \"/bin/jsh\"]],\n none: [\"npm_config_yes\"],\n },\n ],\n },\n {\n id: \"zed-agent\",\n name: \"Zed Agent\",\n type: \"agent\",\n envVars: [\n {\n all: [\n [\"TERM_PROGRAM\", \"zed\"],\n [\"PAGER\", \"cat\"],\n ],\n },\n ],\n },\n {\n id: \"zed\",\n name: \"Zed\",\n type: \"interactive\",\n envVars: [\n {\n all: [[\"TERM_PROGRAM\", \"zed\"]],\n none: [[\"PAGER\", \"cat\"]],\n },\n ],\n },\n {\n id: \"replit-assistant\",\n name: \"Replit Assistant\",\n type: \"agent\",\n envVars: [\n {\n all: [\"REPL_ID\", [\"REPLIT_MODE\", \"assistant\"]],\n },\n ],\n },\n {\n id: \"replit\",\n name: \"Replit\",\n type: \"interactive\",\n envVars: [\n {\n all: [\"REPL_ID\"],\n none: [[\"REPLIT_MODE\", \"assistant\"]],\n },\n ],\n },\n {\n id: \"windsurf\",\n name: \"Windsurf\",\n type: \"agent\",\n envVars: [\"CODEIUM_EDITOR_APP_ROOT\"],\n },\n {\n id: \"vscode-copilot-agent\",\n name: \"GitHub Copilot in VS Code\",\n type: \"agent\",\n envVars: [\n {\n all: [\n [\"TERM_PROGRAM\", \"vscode\"],\n [\"GIT_PAGER\", \"cat\"],\n ],\n },\n ],\n },\n {\n id: \"warp\",\n name: \"Warp Terminal\",\n type: \"hybrid\",\n envVars: [\n {\n all: [\n [\"TERM_PROGRAM\", \"WarpTerminal\"],\n ],\n },\n ],\n },\n];\n\n/**\n * Get provider configuration by name\n */\nexport function getProvider(name: string): ProviderConfig | undefined {\n return providers.find((p) => p.name === name);\n}\n\n/**\n * Get all providers of a specific type\n */\nexport function getProvidersByType(\n type: \"agent\" | \"interactive\" | \"hybrid\",\n): ProviderConfig[] {\n return providers.filter((p) => p.type === type);\n}\n","import type {\n DetectionResult,\n ProviderConfig,\n EnvVarDefinition,\n EnvVarGroup,\n} from \"./types.js\";\nimport { providers } from \"./providers.js\";\nimport { getProcessAncestry } from \"process-ancestry\";\n\n/**\n * Check if a specific environment variable exists (handles both strings and tuples)\n */\nfunction checkEnvVar(\n envVarDef: EnvVarDefinition,\n env: Record<string, string | undefined> = process.env,\n): boolean {\n const [envVar, expectedValue] =\n typeof envVarDef === \"string\" ? [envVarDef, undefined] : envVarDef;\n\n const actualValue = env[envVar];\n return Boolean(\n actualValue && (!expectedValue || actualValue === expectedValue),\n );\n}\n\n/**\n * Check if a process is running in the process tree\n */\nfunction checkProcess(processName: string): boolean {\n try {\n const ancestry = getProcessAncestry();\n for (const ancestorProcess of ancestry) {\n if (ancestorProcess.command?.includes(processName)) {\n return true;\n }\n }\n } catch (error) {\n // Ignore process check errors\n }\n return false;\n}\n\n/**\n * Check if an environment variable group matches based on its properties\n */\nfunction checkEnvVars(\n definition: EnvVarGroup | EnvVarDefinition,\n env: Record<string, string | undefined> = process.env,\n): boolean {\n if (typeof definition === \"string\" || Array.isArray(definition)) {\n return checkEnvVar(definition, env);\n }\n\n const { any, all, none } = definition;\n\n // Check ANY conditions (OR logic) - at least one must pass\n const anyResult =\n !any?.length || any.some((envVar) => checkEnvVar(envVar, env));\n\n // Check ALL conditions (AND logic) - all must pass\n const allResult =\n !all?.length || all.every((envVar) => checkEnvVar(envVar, env));\n\n // Check NONE conditions (NOT logic) - none should pass\n const noneResult =\n !none?.length || !none.some((envVar) => checkEnvVar(envVar, env));\n\n return anyResult && allResult && noneResult;\n}\n\n/**\n * Run custom detectors for a provider\n */\nfunction runCustomDetectors(provider: ProviderConfig): boolean {\n return (\n provider.customDetectors?.some((detector) => {\n try {\n return detector();\n } catch {\n return false;\n }\n }) ?? false\n );\n}\n\n/**\n * Create a positive detection result\n */\nfunction createDetectedResult(provider: ProviderConfig): DetectionResult {\n return {\n isAgentic: true,\n id: provider.id,\n name: provider.name,\n type: provider.type,\n };\n}\n\n/**\n * Detect agentic coding environment\n */\nexport function detectAgenticEnvironment(\n env: Record<string, string | undefined> = process.env,\n): DetectionResult {\n for (const provider of providers) {\n // Check environment variables\n if (provider.envVars?.some((group) => checkEnvVars(group, env))) {\n return createDetectedResult(provider);\n }\n\n // Check processes\n if (provider.processChecks?.some(checkProcess)) {\n return createDetectedResult(provider);\n }\n\n // Run custom detectors\n if (runCustomDetectors(provider)) {\n return createDetectedResult(provider);\n }\n }\n\n // No provider detected\n return {\n isAgentic: false,\n id: null,\n name: null,\n type: null,\n };\n}\n\n/**\n * Check if currently running in a specific provider\n */\nexport function isProvider(\n providerName: string,\n env: Record<string, string | undefined> = process.env,\n): boolean {\n const result = detectAgenticEnvironment(env);\n return result.name === providerName;\n}\n\n/**\n * Check if currently running in any agent environment\n */\nexport function isAgent(\n env: Record<string, string | undefined> = process.env,\n): boolean {\n const result = detectAgenticEnvironment(env);\n return result.type === \"agent\" || result.type === \"hybrid\";\n}\n\n/**\n * Check if currently running in any interactive AI environment\n */\nexport function isInteractive(\n env: Record<string, string | undefined> = process.env,\n): boolean {\n const result = detectAgenticEnvironment(env);\n return result.type === \"interactive\" || result.type === \"hybrid\";\n}\n\n/**\n * Check if currently running in any hybrid AI environment\n */\nexport function isHybrid(\n env: Record<string, string | undefined> = process.env,\n): boolean {\n const result = detectAgenticEnvironment(env);\n return result.type === \"hybrid\";\n}\n"],"mappings":";;;;;;AAKA,MAAaA,YAA8B;CACzC;EACE,IAAI;EACJ,MAAM;EACN,MAAM;EACN,SAAS,CACP,EACE,KAAK;GACH;GACA;GACA;GACA;EACD,EACF,CACF;CACF;CACD;EACE,IAAI;EACJ,MAAM;EACN,MAAM;EACN,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC,QAAQ,aAAc,GAAE,CAAC,QAAQ,QAAS,CAAC,EAAE,CAAC;CAClE;CACD;EACE,IAAI;EACJ,MAAM;EACN,MAAM;EACN,SAAS,CAAC,YAAa;CACxB;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