conductor-4-all 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # Conductor for All
2
+
3
+ **Conductor for All** is a standalone command-line tool designed to bring the [Conductor](https://github.com/google/labs-prototypes/tree/main/gemini-cli) spec-driven development methodology to *any* coding environment.
4
+
5
+ Originally tied to the Gemini CLI extension, this project aims to decouple the methodology, allowing developers to install and initialize Conductor workflows in their projects so they can be leveraged by **any** AI Coding Agent (e.g., Claude Code, Cline, Cursor, Windsurf) or IDE.
6
+
7
+ ## 🎯 Goals
8
+
9
+ - **Universal Compatibility:** Enable the Conductor methodology outside of the Gemini CLI ecosystem.
10
+ - **Agent-Agnostic Setup:** Provide a mechanism to "install" Conductor commands and templates into a project, effectively "enabling" it for consumption by multiple different coding agents.
11
+ - **Standardization:** Create a unified interface for project orchestration that bridges the gap between human intent and AI execution.
12
+
13
+ ## 🚀 Usage
14
+
15
+ ### 1. Installation
16
+
17
+ #### Global Installation via npm (Recommended)
18
+
19
+ ```bash
20
+ npm install -g conductor-4-all
21
+ ```
22
+
23
+ #### From Source
24
+
25
+ ```bash
26
+ npm install
27
+ npm run build
28
+ ```
29
+
30
+ ### 2. Setup Conductor in Your Project
31
+
32
+ Run the `install` command in the root of your project:
33
+
34
+ ```bash
35
+ # If installed globally:
36
+ conductor install
37
+
38
+ # If built from source:
39
+ node dist/index.js install
40
+ ```
41
+
42
+ You will be prompted to select your AI Coding Agent:
43
+ - **Opencode**
44
+ - **Claude Code**
45
+
46
+ This will verify the environment and install the necessary Conductor files:
47
+ - **Commands:** Agent-specific prompt files (e.g., `.opencode/commands/conductor:setup.md`) that your agent can execute.
48
+ - **Templates:** Workflow guides and style guides (e.g., `.opencode/conductor/templates/`).
49
+
50
+ ### 3. Using Conductor with Your Agent
51
+
52
+ Once installed, you can instruct your AI Agent to perform Conductor tasks using the installed commands. For example:
53
+
54
+ - `@agent /conductor:setup` - Initialize the project structure.
55
+ - `@agent /conductor:newTrack` - Start a new feature or bug fix track.
56
+ - `@agent /conductor:implement` - Implement the selected track.
57
+ - `@agent /conductor:status` - Check the status of current tracks.
58
+
59
+ *Note: The exact invocation syntax depends on your specific agent's slash command or file context capabilities.*
60
+
61
+ ## 🛠️ Contribution Guide
62
+
63
+ We follow a strict spec-driven development workflow ourselves!
64
+
65
+ - **Workflow:** Please read [`conductor/workflow.md`](./conductor/workflow.md) for our detailed development protocols (Tasks, TDD, Commits).
66
+ - **Tech Stack:** Check [`conductor/tech-stack.md`](./conductor/tech-stack.md) for approved technologies (TypeScript/Node.js).
67
+ - **Product Guidelines:** See [`conductor/product-guidelines.md`](./conductor/product-guidelines.md) for design philosophy.
68
+
69
+ To start contributing:
70
+ 1. Read the docs above.
71
+ 2. Pick a task from `conductor/tracks.md` (or propose one).
72
+ 3. Follow the **Conductor Workflow** to implement it.
73
+
74
+ ## 🙏 Acknowledgements
75
+
76
+ This project is inspired by and based on the **Conductor** methodology originally developed for the **Gemini CLI**. We aim to extend its benefits to the broader developer ecosystem.
package/dist/index.cjs ADDED
@@ -0,0 +1,187 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+
26
+ // node_modules/tsup/assets/cjs_shims.js
27
+ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
28
+ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
29
+
30
+ // src/cli/index.ts
31
+ var import_yargs = __toESM(require("yargs"), 1);
32
+ var import_helpers = require("yargs/helpers");
33
+
34
+ // src/cli/prompt.ts
35
+ var import_select = __toESM(require("@inquirer/select"), 1);
36
+ async function promptForAgent() {
37
+ const answer = await (0, import_select.default)({
38
+ message: "Select your coding agent:",
39
+ choices: [
40
+ {
41
+ name: "OpenCode",
42
+ value: "opencode",
43
+ description: "Gemini-based coding assistant"
44
+ },
45
+ {
46
+ name: "Claude Code",
47
+ value: "claude-code",
48
+ description: "Anthropic-based coding assistant"
49
+ }
50
+ ],
51
+ default: "opencode"
52
+ });
53
+ return answer;
54
+ }
55
+
56
+ // src/utils/install.ts
57
+ var import_fs_extra = __toESM(require("fs-extra"), 1);
58
+ var import_path2 = require("path");
59
+ var import_smol_toml = require("smol-toml");
60
+
61
+ // src/utils/template.ts
62
+ var import_promises = require("fs/promises");
63
+ var import_path = require("path");
64
+ var import_url = require("url");
65
+ var __dirname = (0, import_url.fileURLToPath)(new URL(".", importMetaUrl));
66
+ function substituteVariables(template, variables) {
67
+ return template.replace(/\{(\w+)\}/g, (match, key) => {
68
+ if (Object.prototype.hasOwnProperty.call(variables, key)) {
69
+ return variables[key];
70
+ }
71
+ return match;
72
+ });
73
+ }
74
+ async function getTemplateRoot() {
75
+ const candidates = [
76
+ (0, import_path.join)(__dirname, "templates"),
77
+ (0, import_path.join)(__dirname, "../templates"),
78
+ (0, import_path.join)(__dirname, "../../gemini-conductor-codebase")
79
+ ];
80
+ for (const path of candidates) {
81
+ try {
82
+ if ((await (0, import_promises.stat)(path)).isDirectory()) {
83
+ return path;
84
+ }
85
+ } catch {
86
+ continue;
87
+ }
88
+ }
89
+ throw new Error(`Template directory not found. Searched in: ${candidates.join(", ")}`);
90
+ }
91
+ async function loadTemplate(templatePath) {
92
+ const rootDir = await getTemplateRoot();
93
+ const fullPath = (0, import_path.join)(rootDir, templatePath);
94
+ return (0, import_promises.readFile)(fullPath, "utf-8");
95
+ }
96
+
97
+ // src/utils/install.ts
98
+ var { existsSync, ensureDir, writeFile, copy } = import_fs_extra.default;
99
+ async function validateProjectDirectory(targetDir) {
100
+ if (!existsSync(targetDir)) {
101
+ throw new Error(`Target directory does not exist: ${targetDir}`);
102
+ }
103
+ const conductorDir = (0, import_path2.join)(targetDir, "conductor");
104
+ if (existsSync(conductorDir)) {
105
+ throw new Error(`Conductor is already installed in: ${targetDir}`);
106
+ }
107
+ return targetDir;
108
+ }
109
+ async function createConductorDirectories(targetDir, agentType) {
110
+ const agentDir = agentType === "claude-code" ? ".claude" : ".opencode";
111
+ const agentPath = (0, import_path2.join)(targetDir, agentDir);
112
+ await ensureDir((0, import_path2.join)(agentPath, "commands"));
113
+ await ensureDir((0, import_path2.join)(agentPath, "conductor"));
114
+ }
115
+ async function copyTemplateFiles(targetDir, agentType) {
116
+ const commands = ["setup", "newTrack", "implement", "status", "revert"];
117
+ const agentDir = agentType === "claude-code" ? ".claude" : ".opencode";
118
+ const agentPath = (0, import_path2.join)(targetDir, agentDir);
119
+ const commandsDir = (0, import_path2.join)(agentPath, "commands");
120
+ const templateRoot = await getTemplateRoot();
121
+ const installPath = (0, import_path2.join)(targetDir, agentDir, "conductor");
122
+ try {
123
+ const templateSource = (0, import_path2.join)(templateRoot, "templates");
124
+ const templateDest = (0, import_path2.join)(agentPath, "conductor", "templates");
125
+ await copy(templateSource, templateDest);
126
+ } catch (e) {
127
+ console.warn("Failed to copy templates directory:", e);
128
+ }
129
+ for (const cmd of commands) {
130
+ try {
131
+ const tomlContent = await loadTemplate(`commands/${cmd}.toml`);
132
+ const parsed = (0, import_smol_toml.parse)(tomlContent);
133
+ if (!parsed.prompt) {
134
+ console.warn(`Warning: No prompt found in ${cmd}.toml`);
135
+ continue;
136
+ }
137
+ let prompt = parsed.prompt;
138
+ prompt = prompt.replace(/__\$\$CODE_AGENT_INSTALL_PATH\$\$__/g, installPath);
139
+ const finalPrompt = substituteVariables(prompt, { agent_type: agentType });
140
+ await writeFile((0, import_path2.join)(commandsDir, `conductor:${cmd}.md`), finalPrompt);
141
+ } catch (e) {
142
+ console.warn(`Failed to process ${cmd}:`, e);
143
+ }
144
+ }
145
+ }
146
+
147
+ // src/commands/install.ts
148
+ var import_path3 = require("path");
149
+ async function installHandler(argv) {
150
+ const targetDir = (0, import_path3.resolve)(process.cwd(), argv.path);
151
+ try {
152
+ console.log(`Initializing Conductor in: ${targetDir}`);
153
+ console.log("Step 1: Validating project directory...");
154
+ const validatedPath = await validateProjectDirectory(targetDir);
155
+ console.log(`\u2714 Validation complete: ${validatedPath}`);
156
+ console.log("\nStep 2: Prompting for agent selection...");
157
+ const agent = await promptForAgent();
158
+ console.log(`\u2714 Selected agent: ${agent}`);
159
+ console.log("\nStep 3: Creating Conductor directories...");
160
+ await createConductorDirectories(validatedPath, agent);
161
+ console.log("\u2714 Directories created");
162
+ console.log("\nStep 4: Copying template files...");
163
+ await copyTemplateFiles(validatedPath, agent);
164
+ console.log("\u2714 Templates copied");
165
+ console.log("\n\u2714 Conductor initialized successfully!");
166
+ } catch (err) {
167
+ console.error("\n\u2718 Installation failed:", err instanceof Error ? err.message : err);
168
+ process.exit(1);
169
+ }
170
+ }
171
+
172
+ // src/cli/index.ts
173
+ var cli = (0, import_yargs.default)((0, import_helpers.hideBin)(process.argv)).scriptName("conductor").usage("$0 <cmd> [args]").command(
174
+ "install [path]",
175
+ "Install Conductor in the specified directory",
176
+ (yargs2) => {
177
+ return yargs2.positional("path", {
178
+ describe: "Directory to install Conductor",
179
+ default: ".",
180
+ type: "string"
181
+ });
182
+ },
183
+ installHandler
184
+ ).help();
185
+
186
+ // src/index.ts
187
+ cli.parse();
package/dist/index.js ADDED
@@ -0,0 +1,160 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli/index.ts
4
+ import yargs from "yargs";
5
+ import { hideBin } from "yargs/helpers";
6
+
7
+ // src/cli/prompt.ts
8
+ import select from "@inquirer/select";
9
+ async function promptForAgent() {
10
+ const answer = await select({
11
+ message: "Select your coding agent:",
12
+ choices: [
13
+ {
14
+ name: "OpenCode",
15
+ value: "opencode",
16
+ description: "Gemini-based coding assistant"
17
+ },
18
+ {
19
+ name: "Claude Code",
20
+ value: "claude-code",
21
+ description: "Anthropic-based coding assistant"
22
+ }
23
+ ],
24
+ default: "opencode"
25
+ });
26
+ return answer;
27
+ }
28
+
29
+ // src/utils/install.ts
30
+ import fs from "fs-extra";
31
+ import { join as join2 } from "path";
32
+ import { parse } from "smol-toml";
33
+
34
+ // src/utils/template.ts
35
+ import { readFile, stat } from "fs/promises";
36
+ import { join } from "path";
37
+ import { fileURLToPath } from "url";
38
+ var __dirname2 = fileURLToPath(new URL(".", import.meta.url));
39
+ function substituteVariables(template, variables) {
40
+ return template.replace(/\{(\w+)\}/g, (match, key) => {
41
+ if (Object.prototype.hasOwnProperty.call(variables, key)) {
42
+ return variables[key];
43
+ }
44
+ return match;
45
+ });
46
+ }
47
+ async function getTemplateRoot() {
48
+ const candidates = [
49
+ join(__dirname2, "templates"),
50
+ join(__dirname2, "../templates"),
51
+ join(__dirname2, "../../gemini-conductor-codebase")
52
+ ];
53
+ for (const path of candidates) {
54
+ try {
55
+ if ((await stat(path)).isDirectory()) {
56
+ return path;
57
+ }
58
+ } catch {
59
+ continue;
60
+ }
61
+ }
62
+ throw new Error(`Template directory not found. Searched in: ${candidates.join(", ")}`);
63
+ }
64
+ async function loadTemplate(templatePath) {
65
+ const rootDir = await getTemplateRoot();
66
+ const fullPath = join(rootDir, templatePath);
67
+ return readFile(fullPath, "utf-8");
68
+ }
69
+
70
+ // src/utils/install.ts
71
+ var { existsSync, ensureDir, writeFile, copy } = fs;
72
+ async function validateProjectDirectory(targetDir) {
73
+ if (!existsSync(targetDir)) {
74
+ throw new Error(`Target directory does not exist: ${targetDir}`);
75
+ }
76
+ const conductorDir = join2(targetDir, "conductor");
77
+ if (existsSync(conductorDir)) {
78
+ throw new Error(`Conductor is already installed in: ${targetDir}`);
79
+ }
80
+ return targetDir;
81
+ }
82
+ async function createConductorDirectories(targetDir, agentType) {
83
+ const agentDir = agentType === "claude-code" ? ".claude" : ".opencode";
84
+ const agentPath = join2(targetDir, agentDir);
85
+ await ensureDir(join2(agentPath, "commands"));
86
+ await ensureDir(join2(agentPath, "conductor"));
87
+ }
88
+ async function copyTemplateFiles(targetDir, agentType) {
89
+ const commands = ["setup", "newTrack", "implement", "status", "revert"];
90
+ const agentDir = agentType === "claude-code" ? ".claude" : ".opencode";
91
+ const agentPath = join2(targetDir, agentDir);
92
+ const commandsDir = join2(agentPath, "commands");
93
+ const templateRoot = await getTemplateRoot();
94
+ const installPath = join2(targetDir, agentDir, "conductor");
95
+ try {
96
+ const templateSource = join2(templateRoot, "templates");
97
+ const templateDest = join2(agentPath, "conductor", "templates");
98
+ await copy(templateSource, templateDest);
99
+ } catch (e) {
100
+ console.warn("Failed to copy templates directory:", e);
101
+ }
102
+ for (const cmd of commands) {
103
+ try {
104
+ const tomlContent = await loadTemplate(`commands/${cmd}.toml`);
105
+ const parsed = parse(tomlContent);
106
+ if (!parsed.prompt) {
107
+ console.warn(`Warning: No prompt found in ${cmd}.toml`);
108
+ continue;
109
+ }
110
+ let prompt = parsed.prompt;
111
+ prompt = prompt.replace(/__\$\$CODE_AGENT_INSTALL_PATH\$\$__/g, installPath);
112
+ const finalPrompt = substituteVariables(prompt, { agent_type: agentType });
113
+ await writeFile(join2(commandsDir, `conductor:${cmd}.md`), finalPrompt);
114
+ } catch (e) {
115
+ console.warn(`Failed to process ${cmd}:`, e);
116
+ }
117
+ }
118
+ }
119
+
120
+ // src/commands/install.ts
121
+ import { resolve as resolve2 } from "path";
122
+ async function installHandler(argv) {
123
+ const targetDir = resolve2(process.cwd(), argv.path);
124
+ try {
125
+ console.log(`Initializing Conductor in: ${targetDir}`);
126
+ console.log("Step 1: Validating project directory...");
127
+ const validatedPath = await validateProjectDirectory(targetDir);
128
+ console.log(`\u2714 Validation complete: ${validatedPath}`);
129
+ console.log("\nStep 2: Prompting for agent selection...");
130
+ const agent = await promptForAgent();
131
+ console.log(`\u2714 Selected agent: ${agent}`);
132
+ console.log("\nStep 3: Creating Conductor directories...");
133
+ await createConductorDirectories(validatedPath, agent);
134
+ console.log("\u2714 Directories created");
135
+ console.log("\nStep 4: Copying template files...");
136
+ await copyTemplateFiles(validatedPath, agent);
137
+ console.log("\u2714 Templates copied");
138
+ console.log("\n\u2714 Conductor initialized successfully!");
139
+ } catch (err) {
140
+ console.error("\n\u2718 Installation failed:", err instanceof Error ? err.message : err);
141
+ process.exit(1);
142
+ }
143
+ }
144
+
145
+ // src/cli/index.ts
146
+ var cli = yargs(hideBin(process.argv)).scriptName("conductor").usage("$0 <cmd> [args]").command(
147
+ "install [path]",
148
+ "Install Conductor in the specified directory",
149
+ (yargs2) => {
150
+ return yargs2.positional("path", {
151
+ describe: "Directory to install Conductor",
152
+ default: ".",
153
+ type: "string"
154
+ });
155
+ },
156
+ installHandler
157
+ ).help();
158
+
159
+ // src/index.ts
160
+ cli.parse();