Skip to content
Merged
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
3 changes: 3 additions & 0 deletions plug/src/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { findPackage, findAllPackages } from '../utils/registry.js';
import { downloadFile } from '../utils/fetcher.js';
import { trackInstall, isInstalled, getInstalled, addDependents } from '../utils/tracker.js';
import { getClaudeSkillsDir, getClaudeAgentsDir, getClaudeDirForType, ensureDir } from '../utils/paths.js';
import { invalidateCommunityIndexCache } from '../utils/community-index.js';
import { createSpinner } from '../utils/ui.js';
import { ctx, verbose } from '../utils/context.js';
import { pkgVersion } from '../utils/pkg-version.js';
Expand Down Expand Up @@ -34,6 +35,8 @@ export function registerInstall(program) {
export async function runInstall(name, options = {}) {
const isGlobal = options.global || false;

await invalidateCommunityIndexCache();

// Parse vault prefix (vault/name)
let vaultName = null;
let pkgName = name;
Expand Down
27 changes: 0 additions & 27 deletions plug/src/tui/components/package-detail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,33 +75,6 @@ export default function PackageDetail({ pkg, onBack, onInstall, installedNames =
</Box>
</Box>

{pkg.dependencies?.length > 0 && (
<Box flexDirection="column" marginBottom={1}>
<Text bold>Dependencies:</Text>
{pkg.dependencies.map(dep => (
<Box key={dep.name} paddingLeft={2}>
<Text dimColor>{dep.required ? '•' : '○'} </Text>
<Text>{dep.name}</Text>
<Text dimColor> ({dep.vault})</Text>
{installedNames.has(dep.name)
? <Text color="green"> ✓ installed</Text>
: <Text dimColor> not installed</Text>}
</Box>
))}
{pkg.dependencies.filter(d => d.required && !installedNames.has(d.name)).length > 0 && (
<Box marginTop={1}>
<Text dimColor>Installing this will also install: </Text>
<Text>
{pkg.dependencies
.filter(d => d.required && !installedNames.has(d.name))
.map(d => d.name)
.join(', ')}
</Text>
</Box>
)}
</Box>
)}

{/* Usage hint */}
{isInstalled ? (
<Box marginBottom={1}>
Expand Down
7 changes: 1 addition & 6 deletions plug/src/tui/components/package-item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default function PackageItem({
isCursor,
isToggled,
isInstalled = false,
showDeps = false,
mode = 'discover',
terminalWidth = 80,
}) {
Expand All @@ -43,14 +42,10 @@ export default function PackageItem({
? ` → v${item.latestVersion} ⬆`
: '';

const depStr = item.depCount > 0
? ` · ★ ${item.depCount} dep${item.depCount === 1 ? '' : 's'}`
: ' · no deps';

// Prefix: "[ ] > " = 6 chars
const prefixLen = 6;
const suffixLen = (typeLabel ? typeLabel.length + 1 : 0) + (scopeLabel ? scopeLabel.length + 1 : 0);
const nameLine = `${item.name} · ${item.vault}${versionStr ? ` · ${versionStr}` : ''}${updateStr}${showDeps ? depStr : ''}`;
const nameLine = `${item.name} · ${item.vault}${versionStr ? ` · ${versionStr}` : ''}${updateStr}`;
const maxNameLen = terminalWidth - prefixLen - suffixLen - 2;
const truncatedName = nameLine.length > maxNameLen
? nameLine.slice(0, maxNameLen - 1) + '…'
Expand Down
3 changes: 0 additions & 3 deletions plug/src/tui/components/package-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { useTerminalSize } from '../hooks/use-terminal-size.js';
* toggled?: Set<number>,
* onToggle?: (index: number) => void,
* installedNames?: Set<string>,
* showDeps?: boolean,
* mode?: 'discover'|'installed',
* emptyMessage?: string,
* }} props
Expand All @@ -29,7 +28,6 @@ export default function PackageList({
toggled: externalToggled,
onToggle,
installedNames,
showDeps = false,
mode = 'discover',
emptyMessage = 'No packages found.',
}) {
Expand Down Expand Up @@ -119,7 +117,6 @@ export default function PackageList({
isCursor={index === cursor}
isToggled={toggled.has(index)}
isInstalled={installedNames?.has(item.name) ?? false}
showDeps={showDeps}
mode={mode}
terminalWidth={terminalWidth}
/>
Expand Down
21 changes: 16 additions & 5 deletions plug/src/tui/hooks/use-installed.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { useState, useEffect, useCallback } from 'react';
import os from 'os';
import path from 'path';
import { getInstalled } from '../../utils/tracker.js';
import { findPackage } from '../../utils/registry.js';
import { compareSemver } from '../../commands/update.js';

const globalClaudeDir = path.resolve(os.homedir(), '.claude');

/**
* Loads installed packages from both local and global scopes.
* Enriches each record with scope label, update-available info.
Expand Down Expand Up @@ -45,15 +49,22 @@ export function useInstalled() {
]);

const merged = [];
const localPaths = new Map();
const seen = new Map();

function inferScope(record) {
if (!record.path) return 'local';
return path.resolve(record.path).startsWith(globalClaudeDir) ? 'global' : 'local';
}

for (const [name, record] of Object.entries(localData.installed || {})) {
merged.push({ name, ...record, scope: 'local', hasUpdate: false, latestVersion: null });
localPaths.set(name, record.path);
const scope = inferScope(record);
merged.push({ name, ...record, scope, hasUpdate: false, latestVersion: null });
seen.set(name, record.path);
}
for (const [name, record] of Object.entries(globalData.installed || {})) {
if (localPaths.has(name) && localPaths.get(name) === record.path) continue;
merged.push({ name, ...record, scope: 'global', hasUpdate: false, latestVersion: null });
if (seen.has(name) && seen.get(name) === record.path) continue;
const scope = inferScope(record);
merged.push({ name, ...record, scope, hasUpdate: false, latestVersion: null });
}

// Sort by name then scope
Expand Down
1 change: 0 additions & 1 deletion plug/src/tui/screens/discover.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ export default function DiscoverScreen({ onInputCapture }) {
toggled={toggled}
onToggle={handleToggle}
installedNames={installedNames}
showDeps={true}
emptyMessage={emptyMessage}
/>

Expand Down
9 changes: 9 additions & 0 deletions plug/src/utils/community-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ export async function cacheCommunityIndex(data) {
await fs.writeFile(cachePath, JSON.stringify(data, null, 2), 'utf8');
}

/**
* Deletes the community index cache so the next fetch hits the network.
*/
export async function invalidateCommunityIndexCache() {
try {
await fs.unlink(getCacheFilePath());
} catch { /* ignore if missing */ }
}

/**
* Returns cached community index data regardless of age (offline/stale fallback).
*/
Expand Down
Loading