Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions test/test-installation-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -1400,6 +1400,67 @@ async function runTests() {

console.log('');

// ============================================================
// Suite 28b: Polytoken Native Skills
// ============================================================
console.log(`${colors.yellow}Test Suite 28b: Polytoken Native Skills${colors.reset}\n`);

let tempProjectDir28b;
let installedBmadDir28b;
try {
clearCache();
const platformCodes28b = await loadPlatformCodes();
const polytokenInstaller = platformCodes28b.platforms.polytoken?.installer;

assert(polytokenInstaller?.target_dir === '.agents/skills', 'Polytoken target_dir uses the shared project-local skills path');
assert(!polytokenInstaller?.global_target_dir, 'Polytoken does not claim an undocumented global skills path');

tempProjectDir28b = await fs.mkdtemp(path.join(os.tmpdir(), 'bmad-polytoken-test-'));
installedBmadDir28b = await createTestBmadFixture();

const ideManager28b = new IdeManager();
await ideManager28b.ensureInitialized();

assert(
ideManager28b.getAvailableIdes().some((ide) => ide.value === 'polytoken'),
'Polytoken appears in available IDEs list',
);

const detectedBefore28b = await ideManager28b.detectInstalledIdes(tempProjectDir28b);
assert(!detectedBefore28b.includes('polytoken'), 'Polytoken is not detected before install');

const result28b = await ideManager28b.setup('polytoken', tempProjectDir28b, installedBmadDir28b, {
silent: true,
selectedModules: ['bmm'],
});
assert(result28b.success === true, 'Polytoken setup succeeds against temp project');

const detectedAfter28b = await ideManager28b.detectInstalledIdes(tempProjectDir28b);
assert(detectedAfter28b.includes('polytoken'), 'Polytoken is detected after install');

const skillFile28b = path.join(tempProjectDir28b, '.agents', 'skills', 'bmad-master', 'SKILL.md');
assert(await fs.pathExists(skillFile28b), 'Polytoken install writes SKILL.md directory output');

const skillContent28b = await fs.readFile(skillFile28b, 'utf8');
const frontmatter28b = skillContent28b.match(/^---\n([\s\S]*?)\n---\n?/);
assert(frontmatter28b, 'Polytoken SKILL.md contains valid frontmatter delimiters');
assert(/^description:\s*\S.+$/m.test(frontmatter28b?.[1] || ''), 'Polytoken skill has a non-empty description');
assert(skillContent28b.includes('agent-activation'), 'Polytoken skill preserves its activation instructions');

const reinstall28b = await ideManager28b.setup('polytoken', tempProjectDir28b, installedBmadDir28b, {
silent: true,
selectedModules: ['bmm'],
});
assert(reinstall28b.success === true, 'Polytoken reinstall succeeds over existing skills');
} catch (error) {
assert(false, 'Polytoken native skills test succeeds', error.message);
} finally {
if (tempProjectDir28b) await fs.remove(tempProjectDir28b).catch(() => {});
if (installedBmadDir28b) await fs.remove(path.dirname(installedBmadDir28b)).catch(() => {});
}

console.log('');

// ============================================================
// Suite 29: Unified Skill Scanner — collectSkills
// ============================================================
Expand Down
6 changes: 6 additions & 0 deletions tools/installer/ide/platform-codes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@ platforms:
target_dir: .agents/skills
global_target_dir: ~/.agents/skills

polytoken:
name: "Polytoken"
preferred: false
installer:
target_dir: .agents/skills

qoder:
name: "Qoder"
preferred: false
Expand Down
48 changes: 46 additions & 2 deletions tools/installer/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,25 @@ async function autocompleteMultiselect(options) {
const filterFn = options.filter ?? defaultAutocompleteFilter;
const lockedSet = new Set(options.lockedValues || []);

if (typeof core.AutocompletePrompt !== 'function') {
const lockedValues = options.lockedValues || [];
const selectableOptions = options.options.filter((option) => !lockedSet.has(option.value));
const initialValues = [...new Set(options.initialValues || [])].filter((value) => !lockedSet.has(value));
const lockedLabels = options.options
.filter((option) => lockedSet.has(option.value))
.map((option) => `${option.label ?? String(option.value ?? '')} (always installed)`);
const message = lockedLabels.length > 0 ? `${options.message} [${lockedLabels.join(', ')}]` : options.message;
const result = await clack.multiselect({
message,
options: selectableOptions,
initialValues: initialValues.length > 0 ? initialValues : undefined,
required: (options.required || false) && lockedValues.length === 0,
maxItems: options.maxItems,
});
await handleCancel(result);
return [...new Set([...result, ...lockedValues])];
}
Comment on lines +269 to +286

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Locked values can be deselected in the fallback multiselect UI.

In the primary path (lines 366-376), locked values are prevented from being toggled off via a custom toggleSelected override. In this fallback, the user can freely deselect locked values in the clack.multiselect UI. While the return on line 279 re-adds them so the final result is correct, two issues arise:

  1. UX confusion: The user deselects an item marked as selected, submits, and it silently reappears in the result.
  2. Submission block: If required is true and the user deselects all items (including locked ones), clack.multiselect blocks submission — whereas the primary path always allows submitting with just locked values.

Consider adding a hint to locked options so users understand they are always installed, which partially mitigates the confusion:

💡 Suggested improvement
     const result = await clack.multiselect({
       message: options.message,
-      options: options.options,
+      options: options.options.map((opt) =>
+        lockedSet.has(opt.value)
+          ? { ...opt, hint: opt.hint ?? 'always installed' }
+          : opt
+      ),
       initialValues: initialValues.length > 0 ? initialValues : undefined,
       required: options.required || false,
       maxItems: options.maxItems,
     });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/installer/prompts.js` around lines 269 - 280, Update the fallback
multiselect path around clack.multiselect so locked values cannot be deselected,
matching the primary AutocompletePrompt behavior. Mark locked options with a
clear “always installed” hint and ensure required validation allows submission
when only locked values remain selected. Preserve the existing deduplication and
locked-value re-addition in the returned result.


const prompt = new core.AutocompletePrompt({
options: options.options,
multiple: true,
Expand Down Expand Up @@ -558,7 +577,17 @@ async function cancel(message = 'Operation cancelled') {
*/
async function box(content, title, options) {
const clack = await getClack();
clack.box(content, title, options);

// @clack/prompts does not currently expose box(), despite some versions of
// its documentation and ecosystem examples referring to one. Keep the
// wrapper forward-compatible while falling back to Clack's supported boxed
// note renderer for current releases.
if (typeof clack.box === 'function') {
clack.box(content, title, options);
return;
}

clack.note(content, title);
}

/**
Expand All @@ -573,7 +602,8 @@ async function box(content, title, options) {
*/
async function autocomplete(options) {
const clack = await getClack();
const result = await clack.autocomplete(options);
const prompt = typeof clack.autocomplete === 'function' ? clack.autocomplete : clack.select;
const result = await prompt(options);
await handleCancel(result);
return result;
}
Expand Down Expand Up @@ -654,6 +684,20 @@ function listDirectoryOptions(input, options) {
*/
async function directory(options) {
const core = await getClackCore();

if (typeof core.AutocompletePrompt !== 'function') {
const clack = await getClack();
const result = await clack.text({
message: options.message,
placeholder: options.placeholder,
initialValue: options.default,
defaultValue: options.default,
validate: options.validate,
});
await handleCancel(result);
return result;
}

const color = await getPicocolors();
const tabCompletion = {
prefix: '',
Expand Down
Loading