chiefwiggum 1.3.12 → 1.3.13
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.cjs +144 -16
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -95,6 +95,108 @@ async function multilineText(options) {
|
|
|
95
95
|
});
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
|
+
async function searchSelect(options) {
|
|
99
|
+
const { message, items, placeholder = "Type to filter...", maxVisible = 10 } = options;
|
|
100
|
+
const readline = await import("readline");
|
|
101
|
+
return new Promise((resolve) => {
|
|
102
|
+
let query = "";
|
|
103
|
+
let selectedIndex = 0;
|
|
104
|
+
let filtered = items.slice(0, maxVisible);
|
|
105
|
+
const filterItems = () => {
|
|
106
|
+
if (!query) {
|
|
107
|
+
filtered = items.slice(0, maxVisible);
|
|
108
|
+
} else {
|
|
109
|
+
const lower = query.toLowerCase();
|
|
110
|
+
filtered = items.filter((item) => item.toLowerCase().includes(lower)).slice(0, maxVisible);
|
|
111
|
+
}
|
|
112
|
+
if (selectedIndex >= filtered.length) {
|
|
113
|
+
selectedIndex = Math.max(0, filtered.length - 1);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const render = () => {
|
|
117
|
+
process.stdout.write("\x1B[?25l");
|
|
118
|
+
let output = "";
|
|
119
|
+
output += `${import_picocolors.default.cyan("?")} ${import_picocolors.default.bold(message)}
|
|
120
|
+
`;
|
|
121
|
+
output += `${import_picocolors.default.dim("\u203A")} ${query || import_picocolors.default.dim(placeholder)}
|
|
122
|
+
`;
|
|
123
|
+
output += "\n";
|
|
124
|
+
if (filtered.length === 0) {
|
|
125
|
+
output += import_picocolors.default.dim(" No matches found\n");
|
|
126
|
+
} else {
|
|
127
|
+
for (let i = 0; i < filtered.length; i++) {
|
|
128
|
+
const isSelected = i === selectedIndex;
|
|
129
|
+
const prefix = isSelected ? import_picocolors.default.cyan("\u276F") : " ";
|
|
130
|
+
const text3 = isSelected ? import_picocolors.default.cyan(filtered[i]) : filtered[i];
|
|
131
|
+
output += `${prefix} ${text3}
|
|
132
|
+
`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
output += `
|
|
136
|
+
${import_picocolors.default.dim("\u2191/\u2193 navigate \u2022 enter select \u2022 esc cancel")}`;
|
|
137
|
+
process.stdout.write(output);
|
|
138
|
+
};
|
|
139
|
+
const clearOutput = () => {
|
|
140
|
+
const lineCount = filtered.length + 5;
|
|
141
|
+
process.stdout.write(`\x1B[${lineCount}A\x1B[0J`);
|
|
142
|
+
};
|
|
143
|
+
const cleanup2 = () => {
|
|
144
|
+
process.stdout.write("\x1B[?25h");
|
|
145
|
+
process.stdin.setRawMode(false);
|
|
146
|
+
process.stdin.removeListener("data", onKeypress);
|
|
147
|
+
};
|
|
148
|
+
const onKeypress = (key) => {
|
|
149
|
+
const str = key.toString();
|
|
150
|
+
if (str === "\x1B" || str === "") {
|
|
151
|
+
clearOutput();
|
|
152
|
+
cleanup2();
|
|
153
|
+
p.cancel("Operation cancelled.");
|
|
154
|
+
process.exit(0);
|
|
155
|
+
}
|
|
156
|
+
if (str === "\r" || str === "\n") {
|
|
157
|
+
clearOutput();
|
|
158
|
+
cleanup2();
|
|
159
|
+
if (filtered.length > 0) {
|
|
160
|
+
console.log(`${import_picocolors.default.green("\u2713")} ${import_picocolors.default.bold(message)} ${import_picocolors.default.dim("\xB7")} ${filtered[selectedIndex]}`);
|
|
161
|
+
resolve(filtered[selectedIndex]);
|
|
162
|
+
} else {
|
|
163
|
+
resolve(null);
|
|
164
|
+
}
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (str === "\x1B[A") {
|
|
168
|
+
clearOutput();
|
|
169
|
+
selectedIndex = Math.max(0, selectedIndex - 1);
|
|
170
|
+
render();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (str === "\x1B[B") {
|
|
174
|
+
clearOutput();
|
|
175
|
+
selectedIndex = Math.min(filtered.length - 1, selectedIndex + 1);
|
|
176
|
+
render();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (str === "\x7F" || str === "\b") {
|
|
180
|
+
clearOutput();
|
|
181
|
+
query = query.slice(0, -1);
|
|
182
|
+
filterItems();
|
|
183
|
+
render();
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (str.length === 1 && str >= " ") {
|
|
187
|
+
clearOutput();
|
|
188
|
+
query += str;
|
|
189
|
+
filterItems();
|
|
190
|
+
render();
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
filterItems();
|
|
194
|
+
render();
|
|
195
|
+
process.stdin.setRawMode(true);
|
|
196
|
+
process.stdin.resume();
|
|
197
|
+
process.stdin.on("data", onKeypress);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
98
200
|
|
|
99
201
|
// src/utils/banner.ts
|
|
100
202
|
var BANNER = `
|
|
@@ -524,6 +626,34 @@ var __dirname = (0, import_node_path2.dirname)((0, import_node_url.fileURLToPath
|
|
|
524
626
|
var LOCAL_TEMPLATES_DIR = ".chiefwiggum/templates";
|
|
525
627
|
var CONFIG_FILE = ".chiefwiggum/CLAUDE.md";
|
|
526
628
|
var BUNDLED_TEMPLATES_DIR = (0, import_node_path2.join)(__dirname, "..", "templates");
|
|
629
|
+
var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
630
|
+
"node_modules",
|
|
631
|
+
".git",
|
|
632
|
+
".chiefwiggum",
|
|
633
|
+
"dist",
|
|
634
|
+
"build",
|
|
635
|
+
".next",
|
|
636
|
+
"vendor",
|
|
637
|
+
"coverage"
|
|
638
|
+
]);
|
|
639
|
+
function findMarkdownFiles(dir, basePath = "") {
|
|
640
|
+
const results = [];
|
|
641
|
+
try {
|
|
642
|
+
const entries = (0, import_node_fs3.readdirSync)(dir, { withFileTypes: true });
|
|
643
|
+
for (const entry of entries) {
|
|
644
|
+
const relativePath = basePath ? `${basePath}/${entry.name}` : entry.name;
|
|
645
|
+
if (entry.isDirectory()) {
|
|
646
|
+
if (!SKIP_DIRS.has(entry.name) && !entry.name.startsWith(".")) {
|
|
647
|
+
results.push(...findMarkdownFiles((0, import_node_path2.join)(dir, entry.name), relativePath));
|
|
648
|
+
}
|
|
649
|
+
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
650
|
+
results.push(relativePath);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
} catch {
|
|
654
|
+
}
|
|
655
|
+
return results;
|
|
656
|
+
}
|
|
527
657
|
async function cmdNew(planFile) {
|
|
528
658
|
console.log(import_picocolors7.default.bold("Project Setup"));
|
|
529
659
|
console.log();
|
|
@@ -550,24 +680,22 @@ async function cmdNew(planFile) {
|
|
|
550
680
|
});
|
|
551
681
|
switch (setupChoice) {
|
|
552
682
|
case "plan": {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
for (const f of plans) {
|
|
559
|
-
console.log(` ${import_picocolors7.default.cyan(`plans/${f}`)}`);
|
|
560
|
-
}
|
|
561
|
-
console.log();
|
|
562
|
-
}
|
|
683
|
+
const mdFiles = findMarkdownFiles(process.cwd());
|
|
684
|
+
if (mdFiles.length === 0) {
|
|
685
|
+
console.log(import_picocolors7.default.yellow("No markdown files found in project."));
|
|
686
|
+
console.log(import_picocolors7.default.dim("Create a plan file first, e.g., plans/plan.md"));
|
|
687
|
+
process.exit(1);
|
|
563
688
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
689
|
+
console.log();
|
|
690
|
+
const planPath = await searchSelect({
|
|
691
|
+
message: "Select a plan file",
|
|
692
|
+
items: mdFiles,
|
|
693
|
+
placeholder: "Type to filter...",
|
|
694
|
+
maxVisible: 15
|
|
567
695
|
});
|
|
568
|
-
if (!
|
|
569
|
-
console.log(import_picocolors7.default.
|
|
570
|
-
process.exit(
|
|
696
|
+
if (!planPath) {
|
|
697
|
+
console.log(import_picocolors7.default.yellow("No plan selected."));
|
|
698
|
+
process.exit(0);
|
|
571
699
|
}
|
|
572
700
|
await checkExistingFiles();
|
|
573
701
|
await generateFromPlan(planPath);
|