@indy2kro/agentenv 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.
Files changed (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +320 -0
  3. package/dist/adapters/base.d.ts +58 -0
  4. package/dist/adapters/base.d.ts.map +1 -0
  5. package/dist/adapters/base.js +16 -0
  6. package/dist/adapters/base.js.map +1 -0
  7. package/dist/adapters/claude.d.ts +21 -0
  8. package/dist/adapters/claude.d.ts.map +1 -0
  9. package/dist/adapters/claude.js +198 -0
  10. package/dist/adapters/claude.js.map +1 -0
  11. package/dist/adapters/codex.d.ts +23 -0
  12. package/dist/adapters/codex.d.ts.map +1 -0
  13. package/dist/adapters/codex.js +134 -0
  14. package/dist/adapters/codex.js.map +1 -0
  15. package/dist/adapters/copilot.d.ts +21 -0
  16. package/dist/adapters/copilot.d.ts.map +1 -0
  17. package/dist/adapters/copilot.js +111 -0
  18. package/dist/adapters/copilot.js.map +1 -0
  19. package/dist/adapters/detect.d.ts +23 -0
  20. package/dist/adapters/detect.d.ts.map +1 -0
  21. package/dist/adapters/detect.js +80 -0
  22. package/dist/adapters/detect.js.map +1 -0
  23. package/dist/adapters/index.d.ts +12 -0
  24. package/dist/adapters/index.d.ts.map +1 -0
  25. package/dist/adapters/index.js +11 -0
  26. package/dist/adapters/index.js.map +1 -0
  27. package/dist/adapters/opencode.d.ts +19 -0
  28. package/dist/adapters/opencode.d.ts.map +1 -0
  29. package/dist/adapters/opencode.js +107 -0
  30. package/dist/adapters/opencode.js.map +1 -0
  31. package/dist/commands/apply.d.ts +21 -0
  32. package/dist/commands/apply.d.ts.map +1 -0
  33. package/dist/commands/apply.js +113 -0
  34. package/dist/commands/apply.js.map +1 -0
  35. package/dist/commands/configure.d.ts +13 -0
  36. package/dist/commands/configure.d.ts.map +1 -0
  37. package/dist/commands/configure.js +151 -0
  38. package/dist/commands/configure.js.map +1 -0
  39. package/dist/commands/setup.d.ts +11 -0
  40. package/dist/commands/setup.d.ts.map +1 -0
  41. package/dist/commands/setup.js +78 -0
  42. package/dist/commands/setup.js.map +1 -0
  43. package/dist/commands/status.d.ts +3 -0
  44. package/dist/commands/status.d.ts.map +1 -0
  45. package/dist/commands/status.js +152 -0
  46. package/dist/commands/status.js.map +1 -0
  47. package/dist/config/schema.d.ts +142 -0
  48. package/dist/config/schema.d.ts.map +1 -0
  49. package/dist/config/schema.js +778 -0
  50. package/dist/config/schema.js.map +1 -0
  51. package/dist/config/scopes.d.ts +14 -0
  52. package/dist/config/scopes.d.ts.map +1 -0
  53. package/dist/config/scopes.js +32 -0
  54. package/dist/config/scopes.js.map +1 -0
  55. package/dist/generate/agentsmd.d.ts +44 -0
  56. package/dist/generate/agentsmd.d.ts.map +1 -0
  57. package/dist/generate/agentsmd.js +340 -0
  58. package/dist/generate/agentsmd.js.map +1 -0
  59. package/dist/index.d.ts +7 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.js +24 -0
  62. package/dist/index.js.map +1 -0
  63. package/dist/integrations/base.d.ts +33 -0
  64. package/dist/integrations/base.d.ts.map +1 -0
  65. package/dist/integrations/base.js +9 -0
  66. package/dist/integrations/base.js.map +1 -0
  67. package/dist/integrations/index.d.ts +7 -0
  68. package/dist/integrations/index.d.ts.map +1 -0
  69. package/dist/integrations/index.js +5 -0
  70. package/dist/integrations/index.js.map +1 -0
  71. package/dist/integrations/superpowers.d.ts +48 -0
  72. package/dist/integrations/superpowers.d.ts.map +1 -0
  73. package/dist/integrations/superpowers.js +191 -0
  74. package/dist/integrations/superpowers.js.map +1 -0
  75. package/dist/shell/detector.d.ts +92 -0
  76. package/dist/shell/detector.d.ts.map +1 -0
  77. package/dist/shell/detector.js +714 -0
  78. package/dist/shell/detector.js.map +1 -0
  79. package/dist/toolchain/fallbacks.d.ts +77 -0
  80. package/dist/toolchain/fallbacks.d.ts.map +1 -0
  81. package/dist/toolchain/fallbacks.js +238 -0
  82. package/dist/toolchain/fallbacks.js.map +1 -0
  83. package/dist/toolchain/gh.d.ts +20 -0
  84. package/dist/toolchain/gh.d.ts.map +1 -0
  85. package/dist/toolchain/gh.js +36 -0
  86. package/dist/toolchain/gh.js.map +1 -0
  87. package/dist/toolchain/mise.d.ts +92 -0
  88. package/dist/toolchain/mise.d.ts.map +1 -0
  89. package/dist/toolchain/mise.js +346 -0
  90. package/dist/toolchain/mise.js.map +1 -0
  91. package/dist/toolchain/rtk.d.ts +27 -0
  92. package/dist/toolchain/rtk.d.ts.map +1 -0
  93. package/dist/toolchain/rtk.js +76 -0
  94. package/dist/toolchain/rtk.js.map +1 -0
  95. package/dist/wizard/build.d.ts +24 -0
  96. package/dist/wizard/build.d.ts.map +1 -0
  97. package/dist/wizard/build.js +64 -0
  98. package/dist/wizard/build.js.map +1 -0
  99. package/package.json +80 -0
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Codex CLI Adapter
3
+ * Handles Codex CLI-specific configuration and hook setup.
4
+ * Hook wiring delegates to `rtk init --codex` (verified against rtk 0.42.4),
5
+ * which writes RTK.md + AGENTS.md instead of a hand-rolled hooks.json.
6
+ */
7
+ import { BaseAdapter, AdapterConfig, AdapterResult } from './base.js';
8
+ export declare class CodexCliAdapter extends BaseAdapter {
9
+ private configDir;
10
+ constructor(config: AdapterConfig);
11
+ getName(): string;
12
+ getConfigDir(): string;
13
+ isInstalled(): boolean;
14
+ initialize(): Promise<AdapterResult>;
15
+ configureHooks(): Promise<AdapterResult>;
16
+ cleanup(): Promise<AdapterResult>;
17
+ getEnvVars(): Record<string, string>;
18
+ /**
19
+ * Generate config.toml with hooks enabled
20
+ */
21
+ private generateConfigToml;
22
+ }
23
+ //# sourceMappingURL=codex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/adapters/codex.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAItE,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,OAAO,CAAC,SAAS,CAAS;gBAEd,MAAM,EAAE,aAAa;IAMjC,OAAO,IAAI,MAAM;IAIjB,YAAY,IAAI,MAAM;IAItB,WAAW,IAAI,OAAO;IAIhB,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC;IAwDpC,cAAc,IAAI,OAAO,CAAC,aAAa,CAAC;IA+BxC,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;IAWvC,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAWpC;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAQ3B"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Codex CLI Adapter
3
+ * Handles Codex CLI-specific configuration and hook setup.
4
+ * Hook wiring delegates to `rtk init --codex` (verified against rtk 0.42.4),
5
+ * which writes RTK.md + AGENTS.md instead of a hand-rolled hooks.json.
6
+ */
7
+ import * as fs from 'fs';
8
+ import * as path from 'path';
9
+ import { BaseAdapter } from './base.js';
10
+ import { isAgentInstalled } from './detect.js';
11
+ import { RTK_INIT_FLAGS, resolveRtkInit, rtkMessage } from '../toolchain/rtk.js';
12
+ export class CodexCliAdapter extends BaseAdapter {
13
+ constructor(config) {
14
+ super(config);
15
+ const home = process.env.HOME || process.env.USERPROFILE || '';
16
+ this.configDir = path.join(home, '.codex');
17
+ }
18
+ getName() {
19
+ return 'Codex CLI';
20
+ }
21
+ getConfigDir() {
22
+ return this.configDir;
23
+ }
24
+ isInstalled() {
25
+ return isAgentInstalled('codex_cli');
26
+ }
27
+ async initialize() {
28
+ const result = {
29
+ success: true,
30
+ message: '',
31
+ filesCreated: [],
32
+ filesModified: [],
33
+ errors: [],
34
+ };
35
+ if (!this.config.enabled) {
36
+ result.message = 'Codex CLI adapter not enabled';
37
+ return result;
38
+ }
39
+ // Create config directory if it doesn't exist
40
+ try {
41
+ if (!fs.existsSync(this.configDir)) {
42
+ fs.mkdirSync(this.configDir, { recursive: true });
43
+ result.filesCreated.push(this.configDir);
44
+ }
45
+ }
46
+ catch (err) {
47
+ result.success = false;
48
+ result.errors.push(`Failed to create config directory: ${err instanceof Error ? err.message : String(err)}`);
49
+ }
50
+ // Create config.toml when missing (baseline; never clobber user content)
51
+ const configPath = path.join(this.configDir, 'config.toml');
52
+ try {
53
+ if (!fs.existsSync(configPath)) {
54
+ fs.writeFileSync(configPath, this.generateConfigToml());
55
+ result.filesCreated.push(configPath);
56
+ }
57
+ }
58
+ catch (err) {
59
+ result.errors.push(`Failed to create config.toml: ${err instanceof Error ? err.message : String(err)}`);
60
+ }
61
+ // Configure hooks if RTK is enabled
62
+ if (this.config.rtkEnabled) {
63
+ const hookResult = await this.configureHooks();
64
+ if (hookResult.success) {
65
+ result.filesCreated.push(...hookResult.filesCreated);
66
+ result.filesModified.push(...hookResult.filesModified);
67
+ }
68
+ else {
69
+ result.success = false;
70
+ result.errors.push(...hookResult.errors);
71
+ }
72
+ }
73
+ result.message = 'Codex CLI adapter initialized';
74
+ return result;
75
+ }
76
+ async configureHooks() {
77
+ const result = {
78
+ success: true,
79
+ message: '',
80
+ filesCreated: [],
81
+ filesModified: [],
82
+ errors: [],
83
+ };
84
+ if (!this.config.enabled) {
85
+ result.message = 'Codex CLI adapter not enabled';
86
+ return result;
87
+ }
88
+ // rtk init --codex writes RTK.md and patches AGENTS.md in the project dir.
89
+ const flags = RTK_INIT_FLAGS.codex_cli;
90
+ const rtkMdPath = path.join(this.config.baseDir, 'RTK.md');
91
+ const existed = fs.existsSync(rtkMdPath);
92
+ const run = resolveRtkInit(this.config.rtkInit)(flags, this.config.baseDir);
93
+ if (run.success) {
94
+ if (!existed && fs.existsSync(rtkMdPath))
95
+ result.filesCreated.push(rtkMdPath);
96
+ result.message = rtkMessage(run);
97
+ }
98
+ else {
99
+ result.success = false;
100
+ result.errors.push(run.message + (run.stderr ? `: ${run.stderr.trim()}` : ''));
101
+ }
102
+ return result;
103
+ }
104
+ async cleanup() {
105
+ // RTK.md/AGENTS.md are owned by rtk; nothing to remove on our side.
106
+ return {
107
+ success: true,
108
+ message: 'Codex CLI adapter cleaned up',
109
+ filesCreated: [],
110
+ filesModified: [],
111
+ errors: [],
112
+ };
113
+ }
114
+ getEnvVars() {
115
+ const env = {};
116
+ // Codex CLI respects SHELL environment variable
117
+ if (process.platform === 'win32' && this.config.rtkEnabled) {
118
+ env.SHELL = 'bash.exe';
119
+ }
120
+ return env;
121
+ }
122
+ /**
123
+ * Generate config.toml with hooks enabled
124
+ */
125
+ generateConfigToml() {
126
+ return `[features]
127
+ hooks = true
128
+
129
+ [tools]
130
+ # Tools will be provided by rtk and mise
131
+ `;
132
+ }
133
+ }
134
+ //# sourceMappingURL=codex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/adapters/codex.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAgC,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjF,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAG9C,YAAY,MAAqB;QAC/B,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC;QAC/D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO;QACL,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,WA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AC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;OAEG;IACK,kBAAkB;QACxB,OAAO;;;;;CAKV,CAAC;IACA,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * GitHub Copilot Adapter
3
+ * Handles GitHub Copilot-specific configuration and hook setup.
4
+ * Hook wiring delegates to `rtk init --copilot`, which (verified against rtk
5
+ * 0.42.4) writes .github/copilot-instructions.md + .github/hooks/rtk-rewrite.json.
6
+ */
7
+ import { BaseAdapter, AdapterConfig, AdapterResult } from './base.js';
8
+ export declare class CopilotAdapter extends BaseAdapter {
9
+ private configDir;
10
+ constructor(config: AdapterConfig);
11
+ getName(): string;
12
+ getConfigDir(): string;
13
+ isInstalled(): boolean;
14
+ initialize(): Promise<AdapterResult>;
15
+ configureHooks(): Promise<AdapterResult>;
16
+ cleanup(): Promise<AdapterResult>;
17
+ getEnvVars(): Record<string, string>;
18
+ private outputPaths;
19
+ private outputFilesPresent;
20
+ }
21
+ //# sourceMappingURL=copilot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copilot.d.ts","sourceRoot":"","sources":["../../src/adapters/copilot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAItE,qBAAa,cAAe,SAAQ,WAAW;IAC7C,OAAO,CAAC,SAAS,CAAS;gBAEd,MAAM,EAAE,aAAa;IAMjC,OAAO,IAAI,MAAM;IAIjB,YAAY,IAAI,MAAM;IAItB,WAAW,IAAI,OAAO;IAIhB,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC;IAgCpC,cAAc,IAAI,OAAO,CAAC,aAAa,CAAC;IA+BxC,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;IAWvC,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAUpC,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,kBAAkB;CAG3B"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * GitHub Copilot Adapter
3
+ * Handles GitHub Copilot-specific configuration and hook setup.
4
+ * Hook wiring delegates to `rtk init --copilot`, which (verified against rtk
5
+ * 0.42.4) writes .github/copilot-instructions.md + .github/hooks/rtk-rewrite.json.
6
+ */
7
+ import * as fs from 'fs';
8
+ import * as path from 'path';
9
+ import { BaseAdapter } from './base.js';
10
+ import { isAgentInstalled } from './detect.js';
11
+ import { RTK_INIT_FLAGS, resolveRtkInit, rtkMessage } from '../toolchain/rtk.js';
12
+ export class CopilotAdapter extends BaseAdapter {
13
+ constructor(config) {
14
+ super(config);
15
+ const home = process.env.HOME || process.env.USERPROFILE || '';
16
+ this.configDir = path.join(home, '.config', 'github-copilot');
17
+ }
18
+ getName() {
19
+ return 'GitHub Copilot';
20
+ }
21
+ getConfigDir() {
22
+ return this.configDir;
23
+ }
24
+ isInstalled() {
25
+ return isAgentInstalled('copilot');
26
+ }
27
+ async initialize() {
28
+ const result = {
29
+ success: true,
30
+ message: '',
31
+ filesCreated: [],
32
+ filesModified: [],
33
+ errors: [],
34
+ };
35
+ if (!this.config.enabled) {
36
+ result.message = 'GitHub Copilot adapter not enabled';
37
+ return result;
38
+ }
39
+ // Configure hooks if RTK is enabled (delegates to `rtk init --copilot`)
40
+ if (this.config.rtkEnabled) {
41
+ const hookResult = await this.configureHooks();
42
+ if (hookResult.success) {
43
+ result.filesCreated.push(...hookResult.filesCreated);
44
+ result.filesModified.push(...hookResult.filesModified);
45
+ result.message = hookResult.message;
46
+ }
47
+ else {
48
+ result.success = false;
49
+ result.errors.push(...hookResult.errors);
50
+ }
51
+ }
52
+ else {
53
+ result.message = 'RTK disabled; no Copilot hooks configured';
54
+ }
55
+ return result;
56
+ }
57
+ async configureHooks() {
58
+ const result = {
59
+ success: true,
60
+ message: '',
61
+ filesCreated: [],
62
+ filesModified: [],
63
+ errors: [],
64
+ };
65
+ if (!this.config.enabled) {
66
+ result.message = 'GitHub Copilot adapter not enabled';
67
+ return result;
68
+ }
69
+ const flags = RTK_INIT_FLAGS.copilot;
70
+ const before = this.outputFilesPresent();
71
+ const run = resolveRtkInit(this.config.rtkInit)(flags, this.config.baseDir);
72
+ if (run.success) {
73
+ if (this.outputFilesPresent() && !before) {
74
+ result.filesCreated.push(...this.outputPaths());
75
+ }
76
+ result.message = rtkMessage(run);
77
+ }
78
+ else {
79
+ result.success = false;
80
+ result.errors.push(run.message + (run.stderr ? `: ${run.stderr.trim()}` : ''));
81
+ }
82
+ return result;
83
+ }
84
+ async cleanup() {
85
+ // rtk owns the .github hook files; nothing to remove on our side.
86
+ return {
87
+ success: true,
88
+ message: 'GitHub Copilot adapter cleaned up',
89
+ filesCreated: [],
90
+ filesModified: [],
91
+ errors: [],
92
+ };
93
+ }
94
+ getEnvVars() {
95
+ const env = {};
96
+ if (process.platform === 'win32' && this.config.rtkEnabled) {
97
+ env.SHELL = 'bash.exe';
98
+ }
99
+ return env;
100
+ }
101
+ outputPaths() {
102
+ return [
103
+ path.join(this.config.baseDir, '.github', 'copilot-instructions.md'),
104
+ path.join(this.config.baseDir, '.github', 'hooks', 'rtk-rewrite.json'),
105
+ ];
106
+ }
107
+ outputFilesPresent() {
108
+ return this.outputPaths().some((f) => fs.existsSync(f));
109
+ }
110
+ }
111
+ //# sourceMappingURL=copilot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copilot.js","sourceRoot":"","sources":["../../src/adapters/copilot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAgC,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjF,MAAM,OAAO,cAAe,SAAQ,WAAW;I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E,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACjF,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,OAAO;QACX,kEAAkE;QAClE,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,mCAAmC;YAC5C,YAAY,EAAE,EAAE;YAChB,aAAa,EAAE,EAAE;YACjB,MAAM,EAAE,EAAE;SACX,CAAC;IACJ,CAAC;IAED,UAAU;QACR,MAAM,GAAG,GAA2B,EAAE,CAAC;QAEvC,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YAC3D,GAAG,CAAC,KAAK,GAAG,UAAU,CAAC;QACzB,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IAEO,WAAW;QACjB,OAAO;YACL,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,yBAAyB,CAAC;YACpE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,CAAC;SACvE,CAAC;IACJ,CAAC;IAEO,kBAAkB;QACxB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC;CACF"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Agent Installation Detection
3
+ * Determines which of the four v1 agents are installed, based on their CLI
4
+ * binaries being resolvable on the machine (PATH lookup), which is what the
5
+ * interactive wizard's pre-checked defaults depend on.
6
+ */
7
+ import type { AgentKey } from '../config/schema.js';
8
+ export declare const AGENT_COMMANDS: Record<AgentKey, string[]>;
9
+ export type DetectFn = (command: string) => boolean;
10
+ /**
11
+ * Return the list of installed agent ids (e.g. ['claude_code', 'codex_cli']).
12
+ */
13
+ export declare function detectInstalledAgents(detect?: DetectFn): AgentKey[];
14
+ /**
15
+ * Check whether a single agent's CLI binary is resolvable.
16
+ */
17
+ export declare function isAgentInstalled(agent: AgentKey, detect?: DetectFn): boolean;
18
+ /**
19
+ * Resolve the first PATH hit for a binary, or null when it is not on PATH.
20
+ * Used by `agentenv status` to surface tool drift.
21
+ */
22
+ export declare function resolveBinary(command: string): string | null;
23
+ //# sourceMappingURL=detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../src/adapters/detect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAIpD,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,CAKrD,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;AAcpD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,GAAE,QAAwB,GAAG,QAAQ,EAAE,CAQlF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAE,QAAwB,GAAG,OAAO,CAE3F;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA4B5D"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Agent Installation Detection
3
+ * Determines which of the four v1 agents are installed, based on their CLI
4
+ * binaries being resolvable on the machine (PATH lookup), which is what the
5
+ * interactive wizard's pre-checked defaults depend on.
6
+ */
7
+ import * as fs from 'node:fs';
8
+ import * as child_process from 'child_process';
9
+ import { AGENT_KEYS } from '../config/schema.js';
10
+ // The binary(ies) that indicate an agent is installed. An agent counts as
11
+ // present when at least one listed command resolves. Copilot rides on `gh`.
12
+ export const AGENT_COMMANDS = {
13
+ claude_code: ['claude'],
14
+ codex_cli: ['codex'],
15
+ copilot: ['gh'],
16
+ opencode: ['opencode'],
17
+ };
18
+ const defaultDetect = (command) => {
19
+ try {
20
+ if (command.includes('/') || command.includes('\\') || command.includes(' ')) {
21
+ return fs.existsSync(command);
22
+ }
23
+ child_process.execFileSync(command, ['--version'], { stdio: 'ignore' });
24
+ return true;
25
+ }
26
+ catch {
27
+ return false;
28
+ }
29
+ };
30
+ /**
31
+ * Return the list of installed agent ids (e.g. ['claude_code', 'codex_cli']).
32
+ */
33
+ export function detectInstalledAgents(detect = defaultDetect) {
34
+ const found = [];
35
+ for (const agent of AGENT_KEYS) {
36
+ if (isAgentInstalled(agent, detect)) {
37
+ found.push(agent);
38
+ }
39
+ }
40
+ return found;
41
+ }
42
+ /**
43
+ * Check whether a single agent's CLI binary is resolvable.
44
+ */
45
+ export function isAgentInstalled(agent, detect = defaultDetect) {
46
+ return AGENT_COMMANDS[agent].some(detect);
47
+ }
48
+ /**
49
+ * Resolve the first PATH hit for a binary, or null when it is not on PATH.
50
+ * Used by `agentenv status` to surface tool drift.
51
+ */
52
+ export function resolveBinary(command) {
53
+ // Direct path inputs (including paths with spaces) should be checked locally
54
+ // before using `where`/`which`; those lookup tools interpret a spaced path as a
55
+ // glob/pattern instead of a literal path.
56
+ if (command.includes('/') || command.includes('\\') || command.includes(' ')) {
57
+ try {
58
+ return fs.existsSync(command) ? command : null;
59
+ }
60
+ catch {
61
+ return null;
62
+ }
63
+ }
64
+ const look = process.platform === 'win32' ? 'where.exe' : 'which';
65
+ try {
66
+ const result = child_process.spawnSync(look, [command], {
67
+ encoding: 'utf8',
68
+ stdio: ['ignore', 'pipe', 'ignore'],
69
+ });
70
+ const out = result.stdout ?? '';
71
+ return (out
72
+ .split(/\r?\n/)
73
+ .map((line) => line.trim())
74
+ .find((line) => line.length > 0) ?? null);
75
+ }
76
+ catch {
77
+ return null;
78
+ }
79
+ }
80
+ //# sourceMappingURL=detect.js.map
@@ -0,0 +1 @@
1
+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AAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Agent Adapters Index
3
+ * Exports all agent adapters for use by the CLI
4
+ */
5
+ export { BaseAdapter, AdapterConfig, AdapterResult, HookConfig } from './base.js';
6
+ export { AGENT_COMMANDS, detectInstalledAgents } from './detect.js';
7
+ export type { DetectFn } from './detect.js';
8
+ export { ClaudeCodeAdapter } from './claude.js';
9
+ export { CodexCliAdapter } from './codex.js';
10
+ export { CopilotAdapter } from './copilot.js';
11
+ export { OpenCodeAdapter } from './opencode.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Agent Adapters Index
3
+ * Exports all agent adapters for use by the CLI
4
+ */
5
+ export { BaseAdapter } from './base.js';
6
+ export { AGENT_COMMANDS, detectInstalledAgents } from './detect.js';
7
+ export { ClaudeCodeAdapter } from './claude.js';
8
+ export { CodexCliAdapter } from './codex.js';
9
+ export { CopilotAdapter } from './copilot.js';
10
+ export { OpenCodeAdapter } from './opencode.js';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAA4C,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * OpenCode Adapter
3
+ * Handles OpenCode-specific configuration and plugin setup.
4
+ * Plugin wiring delegates to `rtk init -g --opencode` (global-only), which
5
+ * (verified against rtk 0.42.4) writes ~/.config/opencode/plugins/rtk.ts.
6
+ */
7
+ import { BaseAdapter, AdapterConfig, AdapterResult } from './base.js';
8
+ export declare class OpenCodeAdapter extends BaseAdapter {
9
+ private configDir;
10
+ constructor(config: AdapterConfig);
11
+ getName(): string;
12
+ getConfigDir(): string;
13
+ isInstalled(): boolean;
14
+ initialize(): Promise<AdapterResult>;
15
+ configureHooks(): Promise<AdapterResult>;
16
+ cleanup(): Promise<AdapterResult>;
17
+ getEnvVars(): Record<string, string>;
18
+ }
19
+ //# sourceMappingURL=opencode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode.d.ts","sourceRoot":"","sources":["../../src/adapters/opencode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAItE,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,OAAO,CAAC,SAAS,CAAS;gBAEd,MAAM,EAAE,aAAa;IAMjC,OAAO,IAAI,MAAM;IAIjB,YAAY,IAAI,MAAM;IAItB,WAAW,IAAI,OAAO;IAIhB,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC;IAgCpC,cAAc,IAAI,OAAO,CAAC,aAAa,CAAC;IAkCxC,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;IAWvC,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CASrC"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * OpenCode Adapter
3
+ * Handles OpenCode-specific configuration and plugin setup.
4
+ * Plugin wiring delegates to `rtk init -g --opencode` (global-only), which
5
+ * (verified against rtk 0.42.4) writes ~/.config/opencode/plugins/rtk.ts.
6
+ */
7
+ import * as fs from 'fs';
8
+ import * as path from 'path';
9
+ import { BaseAdapter } from './base.js';
10
+ import { isAgentInstalled } from './detect.js';
11
+ import { RTK_INIT_FLAGS, resolveRtkInit, rtkMessage } from '../toolchain/rtk.js';
12
+ export class OpenCodeAdapter extends BaseAdapter {
13
+ constructor(config) {
14
+ super(config);
15
+ const home = process.env.HOME || process.env.USERPROFILE || '';
16
+ this.configDir = path.join(home, '.config', 'opencode');
17
+ }
18
+ getName() {
19
+ return 'OpenCode';
20
+ }
21
+ getConfigDir() {
22
+ return this.configDir;
23
+ }
24
+ isInstalled() {
25
+ return isAgentInstalled('opencode');
26
+ }
27
+ async initialize() {
28
+ const result = {
29
+ success: true,
30
+ message: '',
31
+ filesCreated: [],
32
+ filesModified: [],
33
+ errors: [],
34
+ };
35
+ if (!this.config.enabled) {
36
+ result.message = 'OpenCode adapter not enabled';
37
+ return result;
38
+ }
39
+ // Configure plugin if RTK is enabled (delegates to `rtk init -g --opencode`)
40
+ if (this.config.rtkEnabled) {
41
+ const hookResult = await this.configureHooks();
42
+ if (hookResult.success) {
43
+ result.filesCreated.push(...hookResult.filesCreated);
44
+ result.filesModified.push(...hookResult.filesModified);
45
+ result.message = hookResult.message;
46
+ }
47
+ else {
48
+ result.success = false;
49
+ result.errors.push(...hookResult.errors);
50
+ }
51
+ }
52
+ else {
53
+ result.message = 'RTK disabled; no OpenCode plugin configured';
54
+ }
55
+ return result;
56
+ }
57
+ async configureHooks() {
58
+ const result = {
59
+ success: true,
60
+ message: '',
61
+ filesCreated: [],
62
+ filesModified: [],
63
+ errors: [],
64
+ };
65
+ if (!this.config.enabled) {
66
+ result.message = 'OpenCode adapter not enabled';
67
+ return result;
68
+ }
69
+ const flags = RTK_INIT_FLAGS.opencode;
70
+ const pluginPath = path.join(this.configDir, 'plugins', 'rtk.ts');
71
+ const existed = fs.existsSync(pluginPath);
72
+ const run = resolveRtkInit(this.config.rtkInit)(flags, this.config.baseDir);
73
+ if (run.success) {
74
+ if (run.stdout.includes('already up to date')) {
75
+ result.message = 'OpenCode rtk plugin already up to date';
76
+ }
77
+ else {
78
+ if (!existed && fs.existsSync(pluginPath))
79
+ result.filesCreated.push(pluginPath);
80
+ result.message = rtkMessage(run);
81
+ }
82
+ }
83
+ else {
84
+ result.success = false;
85
+ result.errors.push(run.message + (run.stderr ? `: ${run.stderr.trim()}` : ''));
86
+ }
87
+ return result;
88
+ }
89
+ async cleanup() {
90
+ // plugins/rtk.ts is owned by rtk; nothing to remove on our side.
91
+ return {
92
+ success: true,
93
+ message: 'OpenCode adapter cleaned up',
94
+ filesCreated: [],
95
+ filesModified: [],
96
+ errors: [],
97
+ };
98
+ }
99
+ getEnvVars() {
100
+ const env = {};
101
+ if (process.platform === 'win32' && this.config.rtkEnabled) {
102
+ env.SHELL = 'bash.exe';
103
+ }
104
+ return env;
105
+ }
106
+ }
107
+ //# sourceMappingURL=opencode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode.js","sourceRoot":"","sources":["../../src/adapters/opencode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAgC,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C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AAE,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAChF,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;YACvB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACjF,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,OAAO;QACX,iEAAiE;QACjE,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,6BAA6B;YACtC,YAAY,EAAE,EAAE;YAChB,aAAa,EAAE,EAAE;YACjB,MAAM,EAAE,EAAE;SACX,CAAC;IACJ,CAAC;IAED,UAAU;QACR,MAAM,GAAG,GAA2B,EAAE,CAAC;QAEvC,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YAC3D,GAAG,CAAC,KAAK,GAAG,UAAU,CAAC;QACzB,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ import { Command } from 'commander';
2
+ import type { AgentenvConfig } from '../config/schema.js';
3
+ import type { RtkInitFn } from '../toolchain/rtk.js';
4
+ export interface ApplyResult {
5
+ success: boolean;
6
+ messages: string[];
7
+ errors: string[];
8
+ }
9
+ export interface ApplyOptions {
10
+ /**
11
+ * Skip ensuring/installing via mise. Used by tests and any caller that
12
+ * only wants file generation (e.g. CI too fast, or a dry-run apply).
13
+ */
14
+ skipMiseInstall?: boolean;
15
+ /** Injectable `rtk init` runner (tests pass a stub). */
16
+ rtkInit?: RtkInitFn;
17
+ }
18
+ /** Apply a validated configuration and return structured results for the CLI. */
19
+ export declare function applyConfiguration(config: AgentenvConfig, baseDir: string, options?: ApplyOptions): Promise<ApplyResult>;
20
+ export declare const applyCommand: Command;
21
+ //# sourceMappingURL=apply.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/commands/apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAQrD,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,wDAAwD;IACxD,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAqBD,iFAAiF;AACjF,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,WAAW,CAAC,CAyDtB;AAED,eAAO,MAAM,YAAY,SA6BrB,CAAC"}