@aexol/opencode-wizard 0.3.9 → 0.3.11

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.
@@ -6,7 +6,7 @@ import { resolveStoredAuthState, toAuthState, writeAuthState } from './auth-stor
6
6
  import { resolveConfig } from './config.js';
7
7
  export { resolveConfig } from './config.js';
8
8
  import { createPluginSession, openBrowser, startLoginFlow } from './auth-flow.js';
9
- import { fetchPublishedSkillDetail, fetchPublishedSkillsCatalog, fetchPublishedSkillsGraphQl, fetchWizardArtifactDetail, fetchWizardArtifactsCatalog, maybePersistWorkspaceSlugFromCatalog } from './client.js';
9
+ import { fetchPublishedSkillDetail, fetchPublishedSkillsCatalog, fetchPublishedSkillsGraphQl, fetchWizardArtifactDetail, fetchWizardArtifactsCatalog, hydrateStoredAuthStateRole, maybePersistWorkspaceSlugFromCatalog } from './client.js';
10
10
  import { normalizeAbsolutePath } from './path-utils.js';
11
11
  import { emitPluginActionEvent, emitPresenceEvent } from './presence.js';
12
12
  import { normalizeDirectoryArg, normalizeRepositoryPath, resolveWorkspace, toWorkspaceResolutionMetadata, toWorkspaceResolutionOutput } from './workspace.js';
@@ -130,7 +130,13 @@ export const OpencodeWizardSkillsPlugin = async input => {
130
130
  const wizardArtifactDetailCache = new Map();
131
131
  const detailInflight = new Map();
132
132
  const wizardArtifactDetailInflight = new Map();
133
- const initialAuthState = await resolveStoredAuthState(input.worktree, config);
133
+ const initialAuthState = await hydrateStoredAuthStateRole({
134
+ worktree: input.worktree,
135
+ config,
136
+ signal: AbortSignal.timeout(5_000),
137
+ onAuthStateChanged: clearPublishedSkillState
138
+ });
139
+ const registeredTools = resolveAvailableTools(initialAuthState?.role ?? null);
134
140
  const loginBootstrap = {
135
141
  promise: null,
136
142
  snapshot: createIdleLoginBootstrapSnapshot()
@@ -220,14 +226,14 @@ export const OpencodeWizardSkillsPlugin = async input => {
220
226
  continue;
221
227
  }
222
228
  }
223
- const clearPublishedSkillState = () => {
229
+ function clearPublishedSkillState() {
224
230
  cache.clear();
225
231
  catalogInflight.clear();
226
232
  detailCache.clear();
227
233
  wizardArtifactDetailCache.clear();
228
234
  detailInflight.clear();
229
235
  wizardArtifactDetailInflight.clear();
230
- };
236
+ }
231
237
  const persistAuthState = async session => {
232
238
  const authState = toAuthState(session);
233
239
  await writeAuthState(config.authStatePath, authState);
@@ -578,11 +584,7 @@ export const OpencodeWizardSkillsPlugin = async input => {
578
584
  const selection = selectPublishedSkills(filteredPublishedSkillsResult.fetchResult.payload, requestedSkills);
579
585
  const isSingleRequest = requestedSkills.length === 1;
580
586
  if (requestedSkills.length === 0) {
581
- const authState = await resolveStoredAuthState(input.worktree, config);
582
- const catalog = {
583
- ...toPublishedSkillCatalog(filteredPublishedSkillsResult.fetchResult.payload),
584
- availableTools: resolveAvailableTools(authState?.role ?? null)
585
- };
587
+ const catalog = toPublishedSkillCatalog(filteredPublishedSkillsResult.fetchResult.payload, registeredTools);
586
588
  context.metadata({
587
589
  title: `opencode-wizard published skills catalog: ${catalog.publishedSkillCount} active`,
588
590
  metadata: {
@@ -781,10 +783,9 @@ export const OpencodeWizardSkillsPlugin = async input => {
781
783
  }
782
784
  };
783
785
  }
784
- const authState = await resolveStoredAuthState(input.worktree, config);
785
786
  const catalog = toWizardArtifactCatalog(fetchResult.payload, {
786
787
  pluginId: PLUGIN_ID,
787
- availableTools: resolveAvailableTools(authState?.role ?? null)
788
+ availableTools: registeredTools
788
789
  });
789
790
  const cacheCursor = getWizardArtifactCatalogCursor(fetchResult.payload.artifacts, toWizardArtifactCatalogCursorItems(fetchResult.payload.catalogArtifacts));
790
791
  return {
@@ -865,10 +866,9 @@ export const OpencodeWizardSkillsPlugin = async input => {
865
866
  }
866
867
  const selection = selectWizardArtifacts(fetchResult.payload.artifacts, requestedArtifacts);
867
868
  if (requestedArtifacts.length === 0) {
868
- const authState = await resolveStoredAuthState(input.worktree, config);
869
869
  const catalog = toWizardArtifactCatalog(fetchResult.payload, {
870
870
  pluginId: PLUGIN_ID,
871
- availableTools: resolveAvailableTools(authState?.role ?? null)
871
+ availableTools: registeredTools
872
872
  });
873
873
  const cacheCursor = getWizardArtifactCatalogCursor(fetchResult.payload.artifacts, toWizardArtifactCatalogCursorItems(fetchResult.payload.catalogArtifacts));
874
874
  return {
@@ -992,7 +992,8 @@ export const OpencodeWizardSkillsPlugin = async input => {
992
992
  let snapshot = await resolvePluginStatusSnapshot({
993
993
  worktree: input.worktree,
994
994
  directory: requestedDirectory,
995
- signal: context.abort
995
+ signal: context.abort,
996
+ registeredTools
996
997
  });
997
998
  if (snapshot.status === 'missing_auth') {
998
999
  try {
@@ -1002,7 +1003,8 @@ export const OpencodeWizardSkillsPlugin = async input => {
1002
1003
  snapshot = await resolvePluginStatusSnapshot({
1003
1004
  worktree: input.worktree,
1004
1005
  directory: requestedDirectory,
1005
- signal: context.abort
1006
+ signal: context.abort,
1007
+ registeredTools
1006
1008
  });
1007
1009
  } catch {
1008
1010
  // Keep returning the safe missing-auth snapshot when interactive login is cancelled or fails.
@@ -1554,7 +1556,7 @@ export const OpencodeWizardSkillsPlugin = async input => {
1554
1556
  })
1555
1557
  });
1556
1558
  return {
1557
- tool: initialAuthState?.role === 'EDITOR' ? {
1559
+ tool: registeredTools.includes('opencode_wizard_editor_create_or_update_skill') ? {
1558
1560
  ...sharedTools,
1559
1561
  ...editorOnlyTools
1560
1562
  } : sharedTools,