@aexol/opencode-wizard 0.3.5 → 0.3.7
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/README.md +6 -4
- package/dist/graphql-operations.d.ts +1 -0
- package/dist/graphql-operations.js +12 -0
- package/dist/graphql-operations.js.map +1 -1
- package/dist/plugin-tools.d.ts +11 -0
- package/dist/plugin-tools.js +16 -1
- package/dist/plugin-tools.js.map +1 -1
- package/dist/server/import-sources.d.ts +27 -0
- package/dist/server/import-sources.js +164 -0
- package/dist/server/import-sources.js.map +1 -0
- package/dist/server/runtime.js +121 -1
- package/dist/server/runtime.js.map +1 -1
- package/dist/server/types.d.ts +12 -0
- package/dist/server/types.js.map +1 -1
- package/dist/server.d.ts +1 -0
- package/dist/server.js +1 -0
- package/dist/server.js.map +1 -1
- package/dist/tui/components/common.d.ts +0 -1
- package/dist/tui/components/common.js +6 -29
- package/dist/tui/components/common.js.map +1 -1
- package/dist/tui/components/status-content.js +1 -1
- package/dist/tui/components/status-content.js.map +1 -1
- package/dist/tui/constants.d.ts +0 -5
- package/dist/tui/constants.js +0 -5
- package/dist/tui/constants.js.map +1 -1
- package/dist/tui/formatting.d.ts +0 -3
- package/dist/tui/formatting.js +1 -13
- package/dist/tui/formatting.js.map +1 -1
- package/dist/tui/skill-helpers.d.ts +1 -11
- package/dist/tui/skill-helpers.js +0 -42
- package/dist/tui/skill-helpers.js.map +1 -1
- package/dist/tui/slots.d.ts +1 -1
- package/dist/tui/slots.js +1 -24
- package/dist/tui/slots.js.map +1 -1
- package/dist/tui/status.js +2 -2
- package/dist/tui/status.js.map +1 -1
- package/dist/tui/types.d.ts +0 -19
- package/dist/tui/types.js.map +1 -1
- package/package.json +2 -1
- package/dist/tui/components/preference-action-notice-row.d.ts +0 -5
- package/dist/tui/components/preference-action-notice-row.js +0 -17
- package/dist/tui/components/preference-action-notice-row.js.map +0 -1
- package/dist/tui/components/skill-catalog-row.d.ts +0 -8
- package/dist/tui/components/skill-catalog-row.js +0 -125
- package/dist/tui/components/skill-catalog-row.js.map +0 -1
- package/dist/tui/components/wizard-skills-dialog-content.d.ts +0 -9
- package/dist/tui/components/wizard-skills-dialog-content.js +0 -229
- package/dist/tui/components/wizard-skills-dialog-content.js.map +0 -1
- package/dist/tui/components/wizard-skills-dialog.d.ts +0 -7
- package/dist/tui/components/wizard-skills-dialog.js +0 -156
- package/dist/tui/components/wizard-skills-dialog.js.map +0 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
- `./tui` → `dist/tui.js`
|
|
10
10
|
- no generated runtime skill directory is published; the plugin stays fetch-only at runtime
|
|
11
11
|
- native OpenCode `skills.urls` is treated as a public/static registry complement, not as the private wizard delivery authority
|
|
12
|
-
- the TUI
|
|
12
|
+
- the TUI is a minimalist information-only panel showing backend/auth/catalog status without exposing install, ignore, import, publish, or preference actions
|
|
13
13
|
|
|
14
14
|
## Local development
|
|
15
15
|
|
|
@@ -46,9 +46,9 @@ Use `skills.urls` only for public registries that are intentionally cacheable by
|
|
|
46
46
|
|
|
47
47
|
## Catalog discovery and auth bootstrap
|
|
48
48
|
|
|
49
|
-
Catalog discovery uses the backend-issued plugin session token stored at `~/.config/opencode/opencode-wizard.json` (`auth` field); the plugin does not persist or send Microsoft/Entra tokens to GraphQL. If no valid plugin session exists, no-arg `opencode_wizard_catalog_fetch`, compatibility no-arg `opencode_wizard_published_skills_fetch`, explicit `opencode_wizard_status`,
|
|
49
|
+
Catalog discovery uses the backend-issued plugin session token stored at `~/.config/opencode/opencode-wizard.json` (`auth` field); the plugin does not persist or send Microsoft/Entra tokens to GraphQL. If no valid plugin session exists, no-arg `opencode_wizard_catalog_fetch`, compatibility no-arg `opencode_wizard_published_skills_fetch`, explicit `opencode_wizard_status`, and chat/system-context startup may start the browser Entra PKCE flow and exchange the callback for a fresh backend-issued plugin session. The TUI status panel only displays the resulting auth/catalog state.
|
|
50
50
|
|
|
51
|
-
The shared plugin tools `opencode_wizard_catalog_fetch`, `opencode_wizard_artifact_fetch`, `opencode_wizard_artifact_preference_set`, compatibility published-skill tools, and `opencode_wizard_status` are always exposed by the plugin. Missing auth, forbidden role, backend, or catalog problems are reported by tool output/status metadata instead of hiding these shared tools; only `opencode_wizard_editor_publish_skill`
|
|
51
|
+
The shared plugin tools `opencode_wizard_catalog_fetch`, `opencode_wizard_artifact_fetch`, `opencode_wizard_artifact_preference_set`, compatibility published-skill tools, and `opencode_wizard_status` are always exposed by the plugin. Missing auth, forbidden role, backend, or catalog problems are reported by tool output/status metadata instead of hiding these shared tools; only `opencode_wizard_editor_publish_skill` and `opencode_wizard_artifact_import` stay editor-only.
|
|
52
52
|
|
|
53
53
|
Call `opencode_wizard_catalog_fetch` with `artifactKind: SKILL` or compatibility `opencode_wizard_published_skills_fetch` without `skill` or `skills` to manually bootstrap plugin login if needed and return catalog-only discovery output for the current directory scope.
|
|
54
54
|
|
|
@@ -58,7 +58,9 @@ Workspace delivery still follows the backend contract: the plugin sends `workspa
|
|
|
58
58
|
|
|
59
59
|
Published skill fetches still support `refresh: true`, but normal cache entries now self-expire after 30 seconds and fetch/status payloads surface `source`, `workspaceSlug`, and `workspaceSlugSource` so stale-vs-refreshed behavior is visible without relying on manual cache deletion. Try `refresh: true` and report the tool-output auth/catalog/source/cache/workspace-resolution state before deleting `~/.cache/opencode/*`.
|
|
60
60
|
|
|
61
|
-
Use `opencode_wizard_artifact_preference_set` or compatibility `opencode_wizard_published_skill_preference_set` for
|
|
61
|
+
Use `opencode_wizard_artifact_preference_set` or compatibility `opencode_wizard_published_skill_preference_set` for preference actions (`install`, `uninstall`, `ignore`, `unignore`); the TUI panel stays information-only and does not expose those mutations.
|
|
62
|
+
|
|
63
|
+
Editors can import external artifacts without writing project files via `opencode_wizard_artifact_import`: use `source: "npx getdesign@latest add bmw-m"` for a `DESIGN_DOC`, or `source: "https://github.com/vercel-labs/agent-skills --skill react-best-practices"` for a `SKILL`. The plugin import path is a command/raw-source bridge into generic backend artifact persistence: it fetches markdown or a zip-backed `SKILL.md`/`README.md`, sends it to the backend import mutation, records the importing editor in existing created/published actor fields plus source metadata, and the imported backend artifact becomes the runtime authority. The admin Skills Catalog UI can browse Vercel, Skillta, and Design Docs sources and unzip archives in the browser; the plugin keeps generic `artifact` tool naming because the same backend artifact flow supports both `SKILL` and `DESIGN_DOC`.
|
|
62
64
|
|
|
63
65
|
`GLOBAL_CONTEXT` skills are active context skills and are not meant to be installed per project. `PROJECT_INSTALLABLE` skills are gallery/installable skills that may be attached globally or to a workspace/path through assignment records; those assignments remain the source of truth for what is active in a catalog response.
|
|
64
66
|
|
|
@@ -5,3 +5,4 @@ export declare const WIZARD_ARTIFACTS_CATALOG_QUERY = "\n query PluginWizardArt
|
|
|
5
5
|
export declare const WIZARD_ARTIFACT_DETAIL_QUERY = "\n query PluginWizardArtifactVersion($input: WizardArtifactDetailInput!) {\n pluginWizardArtifactVersion(input: $input) {\n id\n artifact {\n id\n kind\n slug\n name\n summary\n whenToUse\n status\n installPolicy\n }\n version\n title\n summary\n status\n frontmatterName\n frontmatterDescription\n markdownBody\n renderedContent\n checksum\n canonicalFilePath\n publishedAt\n fileCount\n files {\n id\n relativePath\n contentType\n content\n checksum\n size\n sortOrder\n }\n }\n }\n";
|
|
6
6
|
export declare const SET_WIZARD_ARTIFACT_PREFERENCE_MUTATION = "\n mutation SetWizardArtifactPreference($input: SetWizardArtifactPreferenceInput!) {\n setWizardArtifactPreference(input: $input) {\n scopeKey\n userKey\n ignoredArtifacts {\n \n assignmentSource\n assignmentType\n scopePath\n includeChildren\n \n artifact {\n id\n kind\n slug\n name\n summary\n whenToUse\n status\n installPolicy\n }\n artifactVersion {\n id\n version\n title\n summary\n status\n frontmatterName\n frontmatterDescription\n checksum\n canonicalFilePath\n publishedAt\n fileCount\n }\n\n\n }\n }\n }\n";
|
|
7
7
|
export declare const CREATE_OR_UPDATE_SKILL_FROM_MARKDOWN_MUTATION = "\n mutation CreateOrUpdateSkillFromMarkdown($markdownContent: String!) {\n createOrUpdateSkillFromMarkdown(markdownContent: $markdownContent) {\n success\n skillSlug\n skillVersionId\n errors\n }\n }\n";
|
|
8
|
+
export declare const IMPORT_WIZARD_ARTIFACT_SNAPSHOT_MUTATION = "\n mutation ImportWizardArtifactSnapshot($input: ImportWizardArtifactSnapshotInput!) {\n importWizardArtifactSnapshot(input: $input) {\n success\n skillSlug\n skillVersionId\n artifactSlug\n artifactVersionId\n errors\n }\n }\n";
|
|
@@ -227,4 +227,16 @@ export const CREATE_OR_UPDATE_SKILL_FROM_MARKDOWN_MUTATION = `
|
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
`;
|
|
230
|
+
export const IMPORT_WIZARD_ARTIFACT_SNAPSHOT_MUTATION = `
|
|
231
|
+
mutation ImportWizardArtifactSnapshot($input: ImportWizardArtifactSnapshotInput!) {
|
|
232
|
+
importWizardArtifactSnapshot(input: $input) {
|
|
233
|
+
success
|
|
234
|
+
skillSlug
|
|
235
|
+
skillVersionId
|
|
236
|
+
artifactSlug
|
|
237
|
+
artifactVersionId
|
|
238
|
+
errors
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
`;
|
|
230
242
|
//# sourceMappingURL=graphql-operations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PUBLISHED_SKILL_CORE_FIELDS","PUBLISHED_SKILL_ASSIGNMENT_FIELDS","PUBLISHED_SKILLS_CATALOG_QUERY","SET_PUBLISHED_SKILL_PREFERENCE_MUTATION","PUBLISHED_SKILL_DETAIL_QUERY","WIZARD_ARTIFACT_CORE_FIELDS","WIZARD_ARTIFACT_ASSIGNMENT_FIELDS","WIZARD_ARTIFACTS_CATALOG_QUERY","WIZARD_ARTIFACT_DETAIL_QUERY","SET_WIZARD_ARTIFACT_PREFERENCE_MUTATION","CREATE_OR_UPDATE_SKILL_FROM_MARKDOWN_MUTATION"],"sources":["../src/graphql-operations.ts"],"sourcesContent":["const PUBLISHED_SKILL_CORE_FIELDS = `\n skill {\n id\n slug\n name\n summary\n whenToUse\n status\n installPolicy\n tags {\n id\n slug\n label\n description\n facet {\n id\n slug\n label\n description\n }\n }\n }\n skillVersion {\n id\n version\n title\n summary\n status\n }\n publishedArtifact {\n id\n frontmatterName\n frontmatterDescription\n checksum\n publishedAt\n fileCount\n }\n`;\n\nconst PUBLISHED_SKILL_ASSIGNMENT_FIELDS = `\n assignmentSource\n assignmentType\n scopePath\n includeChildren\n ${PUBLISHED_SKILL_CORE_FIELDS}\n`;\n\nexport const PUBLISHED_SKILLS_CATALOG_QUERY = `\n query PluginPublishedSkills($input: PublishedSkillsDeliveryInput!) {\n pluginPublishedSkills(input: $input) {\n workspace {\n id\n slug\n name\n repositoryUrl\n defaultBranch\n status\n }\n directoryPath\n skills {\n ${PUBLISHED_SKILL_ASSIGNMENT_FIELDS}\n }\n catalogSkills {\n ${PUBLISHED_SKILL_CORE_FIELDS}\n }\n userPreferences {\n scopeKey\n userKey\n ignoredSkills {\n ${PUBLISHED_SKILL_ASSIGNMENT_FIELDS}\n }\n }\n }\n }\n`;\n\nexport const SET_PUBLISHED_SKILL_PREFERENCE_MUTATION = `\n mutation SetPublishedSkillPreference($input: SetPublishedSkillPreferenceInput!) {\n setPublishedSkillPreference(input: $input) {\n scopeKey\n userKey\n ignoredSkills {\n ${PUBLISHED_SKILL_ASSIGNMENT_FIELDS}\n }\n }\n }\n`;\n\nexport const PUBLISHED_SKILL_DETAIL_QUERY = `\n query PluginPublishedSkillVersionArtifact($input: PublishedSkillArtifactDetailInput!) {\n pluginPublishedSkillVersionArtifact(input: $input) {\n id\n frontmatterName\n frontmatterDescription\n markdownBody\n renderedContent\n checksum\n publishedAt\n fileCount\n files {\n id\n relativePath\n contentType\n content\n checksum\n size\n sortOrder\n }\n }\n }\n`;\n\nconst WIZARD_ARTIFACT_CORE_FIELDS = `\n artifact {\n id\n kind\n slug\n name\n summary\n whenToUse\n status\n installPolicy\n }\n artifactVersion {\n id\n version\n title\n summary\n status\n frontmatterName\n frontmatterDescription\n checksum\n canonicalFilePath\n publishedAt\n fileCount\n }\n`;\n\nconst WIZARD_ARTIFACT_ASSIGNMENT_FIELDS = `\n assignmentSource\n assignmentType\n scopePath\n includeChildren\n ${WIZARD_ARTIFACT_CORE_FIELDS}\n`;\n\nexport const WIZARD_ARTIFACTS_CATALOG_QUERY = `\n query PluginWizardArtifacts($input: WizardArtifactsDeliveryInput!) {\n pluginWizardArtifacts(input: $input) {\n artifactKind\n workspace {\n id\n slug\n name\n repositoryUrl\n defaultBranch\n status\n }\n directoryPath\n artifacts {\n ${WIZARD_ARTIFACT_ASSIGNMENT_FIELDS}\n }\n catalogArtifacts {\n ${WIZARD_ARTIFACT_CORE_FIELDS}\n }\n artifactPreferences {\n scopeKey\n userKey\n ignoredArtifacts {\n ${WIZARD_ARTIFACT_ASSIGNMENT_FIELDS}\n }\n }\n unsupportedReason\n message\n }\n }\n`;\n\nexport const WIZARD_ARTIFACT_DETAIL_QUERY = `\n query PluginWizardArtifactVersion($input: WizardArtifactDetailInput!) {\n pluginWizardArtifactVersion(input: $input) {\n id\n artifact {\n id\n kind\n slug\n name\n summary\n whenToUse\n status\n installPolicy\n }\n version\n title\n summary\n status\n frontmatterName\n frontmatterDescription\n markdownBody\n renderedContent\n checksum\n canonicalFilePath\n publishedAt\n fileCount\n files {\n id\n relativePath\n contentType\n content\n checksum\n size\n sortOrder\n }\n }\n }\n`;\n\nexport const SET_WIZARD_ARTIFACT_PREFERENCE_MUTATION = `\n mutation SetWizardArtifactPreference($input: SetWizardArtifactPreferenceInput!) {\n setWizardArtifactPreference(input: $input) {\n scopeKey\n userKey\n ignoredArtifacts {\n ${WIZARD_ARTIFACT_ASSIGNMENT_FIELDS}\n }\n }\n }\n`;\n\nexport const CREATE_OR_UPDATE_SKILL_FROM_MARKDOWN_MUTATION = `\n mutation CreateOrUpdateSkillFromMarkdown($markdownContent: String!) {\n createOrUpdateSkillFromMarkdown(markdownContent: $markdownContent) {\n success\n skillSlug\n skillVersionId\n errors\n }\n }\n`;\n"],"mappings":"AAAA,MAAMA,2BAA2B,GAAG;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,iCAAiC,GAAG;AAC1C;AACA;AACA;AACA;AACA,IAAID,2BAA2B;AAC/B,CAAC;AAED,OAAO,MAAME,8BAA8B,GAAG;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAUD,iCAAiC;AAC3C;AACA;AACA,UAAUD,2BAA2B;AACrC;AACA;AACA;AACA;AACA;AACA,YAAYC,iCAAiC;AAC7C;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAME,uCAAuC,GAAG;AACvD;AACA;AACA;AACA;AACA;AACA,UAAUF,iCAAiC;AAC3C;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMG,4BAA4B,GAAG;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,2BAA2B,GAAG;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,iCAAiC,GAAG;AAC1C;AACA;AACA;AACA;AACA,IAAID,2BAA2B;AAC/B,CAAC;AAED,OAAO,MAAME,8BAA8B,GAAG;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAUD,iCAAiC;AAC3C;AACA;AACA,UAAUD,2BAA2B;AACrC;AACA;AACA;AACA;AACA;AACA,YAAYC,iCAAiC;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAME,4BAA4B,GAAG;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,uCAAuC,GAAG;AACvD;AACA;AACA;AACA;AACA;AACA,UAAUH,iCAAiC;AAC3C;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMI,6CAA6C,GAAG;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["PUBLISHED_SKILL_CORE_FIELDS","PUBLISHED_SKILL_ASSIGNMENT_FIELDS","PUBLISHED_SKILLS_CATALOG_QUERY","SET_PUBLISHED_SKILL_PREFERENCE_MUTATION","PUBLISHED_SKILL_DETAIL_QUERY","WIZARD_ARTIFACT_CORE_FIELDS","WIZARD_ARTIFACT_ASSIGNMENT_FIELDS","WIZARD_ARTIFACTS_CATALOG_QUERY","WIZARD_ARTIFACT_DETAIL_QUERY","SET_WIZARD_ARTIFACT_PREFERENCE_MUTATION","CREATE_OR_UPDATE_SKILL_FROM_MARKDOWN_MUTATION","IMPORT_WIZARD_ARTIFACT_SNAPSHOT_MUTATION"],"sources":["../src/graphql-operations.ts"],"sourcesContent":["const PUBLISHED_SKILL_CORE_FIELDS = `\n skill {\n id\n slug\n name\n summary\n whenToUse\n status\n installPolicy\n tags {\n id\n slug\n label\n description\n facet {\n id\n slug\n label\n description\n }\n }\n }\n skillVersion {\n id\n version\n title\n summary\n status\n }\n publishedArtifact {\n id\n frontmatterName\n frontmatterDescription\n checksum\n publishedAt\n fileCount\n }\n`;\n\nconst PUBLISHED_SKILL_ASSIGNMENT_FIELDS = `\n assignmentSource\n assignmentType\n scopePath\n includeChildren\n ${PUBLISHED_SKILL_CORE_FIELDS}\n`;\n\nexport const PUBLISHED_SKILLS_CATALOG_QUERY = `\n query PluginPublishedSkills($input: PublishedSkillsDeliveryInput!) {\n pluginPublishedSkills(input: $input) {\n workspace {\n id\n slug\n name\n repositoryUrl\n defaultBranch\n status\n }\n directoryPath\n skills {\n ${PUBLISHED_SKILL_ASSIGNMENT_FIELDS}\n }\n catalogSkills {\n ${PUBLISHED_SKILL_CORE_FIELDS}\n }\n userPreferences {\n scopeKey\n userKey\n ignoredSkills {\n ${PUBLISHED_SKILL_ASSIGNMENT_FIELDS}\n }\n }\n }\n }\n`;\n\nexport const SET_PUBLISHED_SKILL_PREFERENCE_MUTATION = `\n mutation SetPublishedSkillPreference($input: SetPublishedSkillPreferenceInput!) {\n setPublishedSkillPreference(input: $input) {\n scopeKey\n userKey\n ignoredSkills {\n ${PUBLISHED_SKILL_ASSIGNMENT_FIELDS}\n }\n }\n }\n`;\n\nexport const PUBLISHED_SKILL_DETAIL_QUERY = `\n query PluginPublishedSkillVersionArtifact($input: PublishedSkillArtifactDetailInput!) {\n pluginPublishedSkillVersionArtifact(input: $input) {\n id\n frontmatterName\n frontmatterDescription\n markdownBody\n renderedContent\n checksum\n publishedAt\n fileCount\n files {\n id\n relativePath\n contentType\n content\n checksum\n size\n sortOrder\n }\n }\n }\n`;\n\nconst WIZARD_ARTIFACT_CORE_FIELDS = `\n artifact {\n id\n kind\n slug\n name\n summary\n whenToUse\n status\n installPolicy\n }\n artifactVersion {\n id\n version\n title\n summary\n status\n frontmatterName\n frontmatterDescription\n checksum\n canonicalFilePath\n publishedAt\n fileCount\n }\n`;\n\nconst WIZARD_ARTIFACT_ASSIGNMENT_FIELDS = `\n assignmentSource\n assignmentType\n scopePath\n includeChildren\n ${WIZARD_ARTIFACT_CORE_FIELDS}\n`;\n\nexport const WIZARD_ARTIFACTS_CATALOG_QUERY = `\n query PluginWizardArtifacts($input: WizardArtifactsDeliveryInput!) {\n pluginWizardArtifacts(input: $input) {\n artifactKind\n workspace {\n id\n slug\n name\n repositoryUrl\n defaultBranch\n status\n }\n directoryPath\n artifacts {\n ${WIZARD_ARTIFACT_ASSIGNMENT_FIELDS}\n }\n catalogArtifacts {\n ${WIZARD_ARTIFACT_CORE_FIELDS}\n }\n artifactPreferences {\n scopeKey\n userKey\n ignoredArtifacts {\n ${WIZARD_ARTIFACT_ASSIGNMENT_FIELDS}\n }\n }\n unsupportedReason\n message\n }\n }\n`;\n\nexport const WIZARD_ARTIFACT_DETAIL_QUERY = `\n query PluginWizardArtifactVersion($input: WizardArtifactDetailInput!) {\n pluginWizardArtifactVersion(input: $input) {\n id\n artifact {\n id\n kind\n slug\n name\n summary\n whenToUse\n status\n installPolicy\n }\n version\n title\n summary\n status\n frontmatterName\n frontmatterDescription\n markdownBody\n renderedContent\n checksum\n canonicalFilePath\n publishedAt\n fileCount\n files {\n id\n relativePath\n contentType\n content\n checksum\n size\n sortOrder\n }\n }\n }\n`;\n\nexport const SET_WIZARD_ARTIFACT_PREFERENCE_MUTATION = `\n mutation SetWizardArtifactPreference($input: SetWizardArtifactPreferenceInput!) {\n setWizardArtifactPreference(input: $input) {\n scopeKey\n userKey\n ignoredArtifacts {\n ${WIZARD_ARTIFACT_ASSIGNMENT_FIELDS}\n }\n }\n }\n`;\n\nexport const CREATE_OR_UPDATE_SKILL_FROM_MARKDOWN_MUTATION = `\n mutation CreateOrUpdateSkillFromMarkdown($markdownContent: String!) {\n createOrUpdateSkillFromMarkdown(markdownContent: $markdownContent) {\n success\n skillSlug\n skillVersionId\n errors\n }\n }\n`;\n\nexport const IMPORT_WIZARD_ARTIFACT_SNAPSHOT_MUTATION = `\n mutation ImportWizardArtifactSnapshot($input: ImportWizardArtifactSnapshotInput!) {\n importWizardArtifactSnapshot(input: $input) {\n success\n skillSlug\n skillVersionId\n artifactSlug\n artifactVersionId\n errors\n }\n }\n`;\n"],"mappings":"AAAA,MAAMA,2BAA2B,GAAG;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,iCAAiC,GAAG;AAC1C;AACA;AACA;AACA;AACA,IAAID,2BAA2B;AAC/B,CAAC;AAED,OAAO,MAAME,8BAA8B,GAAG;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAUD,iCAAiC;AAC3C;AACA;AACA,UAAUD,2BAA2B;AACrC;AACA;AACA;AACA;AACA;AACA,YAAYC,iCAAiC;AAC7C;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAME,uCAAuC,GAAG;AACvD;AACA;AACA;AACA;AACA;AACA,UAAUF,iCAAiC;AAC3C;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMG,4BAA4B,GAAG;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,2BAA2B,GAAG;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,iCAAiC,GAAG;AAC1C;AACA;AACA;AACA;AACA,IAAID,2BAA2B;AAC/B,CAAC;AAED,OAAO,MAAME,8BAA8B,GAAG;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAUD,iCAAiC;AAC3C;AACA;AACA,UAAUD,2BAA2B;AACrC;AACA;AACA;AACA;AACA;AACA,YAAYC,iCAAiC;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAME,4BAA4B,GAAG;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,uCAAuC,GAAG;AACvD;AACA;AACA;AACA;AACA;AACA,UAAUH,iCAAiC;AAC3C;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMI,6CAA6C,GAAG;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,wCAAwC,GAAG;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
package/dist/plugin-tools.d.ts
CHANGED
|
@@ -37,6 +37,15 @@ export type EditorPublishSkillArgs = {
|
|
|
37
37
|
skillSlug: string;
|
|
38
38
|
directory?: string;
|
|
39
39
|
};
|
|
40
|
+
export type WizardArtifactImportArgs = {
|
|
41
|
+
artifactKind?: string;
|
|
42
|
+
source: string;
|
|
43
|
+
slug?: string;
|
|
44
|
+
skill?: string;
|
|
45
|
+
name?: string;
|
|
46
|
+
summary?: string;
|
|
47
|
+
directory?: string;
|
|
48
|
+
};
|
|
40
49
|
type ToolSchemaValue<TSelf> = {
|
|
41
50
|
optional: () => TSelf;
|
|
42
51
|
describe: (description: string) => TSelf;
|
|
@@ -71,6 +80,7 @@ type PublishedSkillToolHandlers = {
|
|
|
71
80
|
updateWizardArtifactPreference: (args: WizardArtifactPreferenceArgs, context: ToolExecuteContext) => Promise<unknown>;
|
|
72
81
|
getStatus: (args: PluginStatusArgs, context: ToolExecuteContext) => Promise<unknown>;
|
|
73
82
|
publishEditorSkill: (args: EditorPublishSkillArgs, context: ToolExecuteContext) => Promise<unknown>;
|
|
83
|
+
importWizardArtifact: (args: WizardArtifactImportArgs, context: ToolExecuteContext) => Promise<unknown>;
|
|
74
84
|
};
|
|
75
85
|
export declare const AVAILABLE_PUBLISHED_SKILL_TOOLS: string[];
|
|
76
86
|
export declare const resolveAvailableTools: (role: string | null | undefined) => string[];
|
|
@@ -85,6 +95,7 @@ export declare const createPublishedSkillToolDefinitions: (tool: ToolFactory, ha
|
|
|
85
95
|
};
|
|
86
96
|
editorOnlyTools: {
|
|
87
97
|
opencode_wizard_editor_publish_skill: unknown;
|
|
98
|
+
opencode_wizard_artifact_import: unknown;
|
|
88
99
|
};
|
|
89
100
|
};
|
|
90
101
|
export {};
|
package/dist/plugin-tools.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const AVAILABLE_PUBLISHED_SKILL_TOOLS = ['opencode_wizard_catalog_fetch', 'opencode_wizard_artifact_fetch', 'opencode_wizard_artifact_preference_set', 'opencode_wizard_published_skills_fetch', 'opencode_wizard_published_skill_preference_set', 'opencode_wizard_status', 'opencode_wizard_editor_publish_skill'];
|
|
1
|
+
export const AVAILABLE_PUBLISHED_SKILL_TOOLS = ['opencode_wizard_catalog_fetch', 'opencode_wizard_artifact_fetch', 'opencode_wizard_artifact_preference_set', 'opencode_wizard_published_skills_fetch', 'opencode_wizard_published_skill_preference_set', 'opencode_wizard_status', 'opencode_wizard_editor_publish_skill', 'opencode_wizard_artifact_import'];
|
|
2
2
|
const SHARED_PUBLISHED_SKILL_TOOLS = AVAILABLE_PUBLISHED_SKILL_TOOLS.slice(0, 6);
|
|
3
3
|
export const resolveAvailableTools = role => {
|
|
4
4
|
if (role === 'EDITOR') return [...AVAILABLE_PUBLISHED_SKILL_TOOLS];
|
|
@@ -87,6 +87,21 @@ export const createPublishedSkillToolDefinitions = (tool, handlers) => ({
|
|
|
87
87
|
async execute(args, context) {
|
|
88
88
|
return handlers.publishEditorSkill(args, context);
|
|
89
89
|
}
|
|
90
|
+
}),
|
|
91
|
+
opencode_wizard_artifact_import: tool({
|
|
92
|
+
description: 'Editor-only import tool for external wizard artifacts. Supports SKILL from GitHub/raw SKILL.md sources and DESIGN_DOC from direct URLs or command-like inputs such as `npx getdesign@latest add bmw-m`. Imported backend artifacts become the plugin runtime authority; no project files are written.',
|
|
93
|
+
args: {
|
|
94
|
+
artifactKind: tool.schema.string().optional().describe('Wizard artifact kind to import: SKILL or DESIGN_DOC; inferred from source when omitted'),
|
|
95
|
+
source: tool.schema.string().describe('Direct URL or command-like input, e.g. `https://github.com/vercel-labs/skills --skill find-skills` or `npx getdesign@latest add bmw-m`'),
|
|
96
|
+
slug: tool.schema.string().optional().describe('Artifact slug; required for DESIGN_DOC unless inferable'),
|
|
97
|
+
skill: tool.schema.string().optional().describe('Skill directory/name for SKILL repo imports'),
|
|
98
|
+
name: tool.schema.string().optional().describe('Optional display name override'),
|
|
99
|
+
summary: tool.schema.string().optional().describe('Optional summary/description override'),
|
|
100
|
+
directory: tool.schema.string().optional().describe('Optional absolute or relative directory override')
|
|
101
|
+
},
|
|
102
|
+
async execute(args, context) {
|
|
103
|
+
return handlers.importWizardArtifact(args, context);
|
|
104
|
+
}
|
|
90
105
|
})
|
|
91
106
|
}
|
|
92
107
|
});
|
package/dist/plugin-tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AVAILABLE_PUBLISHED_SKILL_TOOLS","SHARED_PUBLISHED_SKILL_TOOLS","slice","resolveAvailableTools","role","createPublishedSkillToolDefinitions","tool","handlers","sharedTools","opencode_wizard_catalog_fetch","description","args","artifactKind","schema","string","optional","describe","directory","refresh","boolean","execute","context","fetchWizardArtifactCatalog","opencode_wizard_artifact_fetch","artifact","artifacts","fetchWizardArtifacts","opencode_wizard_artifact_preference_set","action","preferenceScope","updateWizardArtifactPreference","opencode_wizard_published_skills_fetch","skill","skills","fetchPublishedSkills","opencode_wizard_published_skill_preference_set","updatePublishedSkillPreference","opencode_wizard_status","getStatus","editorOnlyTools","opencode_wizard_editor_publish_skill","skillSlug","publishEditorSkill"],"sources":["../src/plugin-tools.ts"],"sourcesContent":["export type PublishedSkillFetchArgs = {\n skill?: string;\n skills?: string;\n directory?: string;\n refresh?: boolean;\n};\n\nexport type WizardArtifactKind = 'SKILL' | 'DESIGN_DOC';\n\nexport type WizardArtifactCatalogFetchArgs = {\n artifactKind?: string;\n directory?: string;\n refresh?: boolean;\n};\n\nexport type WizardArtifactFetchArgs = {\n artifactKind?: string;\n artifact?: string;\n artifacts?: string;\n directory?: string;\n refresh?: boolean;\n};\n\nexport type PluginStatusArgs = {\n directory?: string;\n};\n\nexport type PublishedSkillPreferenceArgs = {\n skill: string;\n action: string;\n preferenceScope?: string;\n directory?: string;\n};\n\nexport type WizardArtifactPreferenceArgs = {\n artifactKind?: string;\n artifact: string;\n action: string;\n preferenceScope?: string;\n directory?: string;\n};\n\nexport type EditorPublishSkillArgs = {\n skillSlug: string;\n directory?: string;\n};\n\ntype ToolSchemaValue<TSelf> = {\n optional: () => TSelf;\n describe: (description: string) => TSelf;\n};\n\ntype ToolSchema = {\n string: () => ToolSchemaValue<ToolSchemaValue<unknown>>;\n boolean: () => ToolSchemaValue<ToolSchemaValue<unknown>>;\n};\n\nexport type ToolExecuteContext = {\n directory: string;\n abort: AbortSignal;\n metadata: (payload: { title: string; metadata: Record<string, string> }) => void;\n};\n\ntype ToolDefinition<TArgs extends object> = {\n description: string;\n args: { [K in keyof TArgs]-?: unknown };\n execute: (args: TArgs, context: ToolExecuteContext) => Promise<unknown>;\n};\n\nexport type ToolFactory = (<TArgs extends object>(definition: ToolDefinition<TArgs>) => unknown) & {\n schema: ToolSchema;\n};\n\ntype PublishedSkillToolHandlers = {\n fetchPublishedSkills: (args: PublishedSkillFetchArgs, context: ToolExecuteContext) => Promise<unknown>;\n fetchWizardArtifactCatalog: (args: WizardArtifactCatalogFetchArgs, context: ToolExecuteContext) => Promise<unknown>;\n fetchWizardArtifacts: (args: WizardArtifactFetchArgs, context: ToolExecuteContext) => Promise<unknown>;\n updatePublishedSkillPreference: (args: PublishedSkillPreferenceArgs, context: ToolExecuteContext) => Promise<unknown>;\n updateWizardArtifactPreference: (args: WizardArtifactPreferenceArgs, context: ToolExecuteContext) => Promise<unknown>;\n getStatus: (args: PluginStatusArgs, context: ToolExecuteContext) => Promise<unknown>;\n publishEditorSkill: (args: EditorPublishSkillArgs, context: ToolExecuteContext) => Promise<unknown>;\n};\n\nexport const AVAILABLE_PUBLISHED_SKILL_TOOLS = [\n 'opencode_wizard_catalog_fetch',\n 'opencode_wizard_artifact_fetch',\n 'opencode_wizard_artifact_preference_set',\n 'opencode_wizard_published_skills_fetch',\n 'opencode_wizard_published_skill_preference_set',\n 'opencode_wizard_status',\n 'opencode_wizard_editor_publish_skill',\n];\n\nconst SHARED_PUBLISHED_SKILL_TOOLS = AVAILABLE_PUBLISHED_SKILL_TOOLS.slice(0, 6);\n\nexport const resolveAvailableTools = (role: string | null | undefined): string[] => {\n if (role === 'EDITOR') return [...AVAILABLE_PUBLISHED_SKILL_TOOLS];\n return [...SHARED_PUBLISHED_SKILL_TOOLS];\n};\n\nexport const createPublishedSkillToolDefinitions = (\n tool: ToolFactory,\n handlers: PublishedSkillToolHandlers,\n) => ({\n sharedTools: {\n opencode_wizard_catalog_fetch: tool<WizardArtifactCatalogFetchArgs>({\n description:\n 'Always-available canonical wizard artifact catalog tool. Supports artifactKind SKILL and DESIGN_DOC; catalogs are metadata-only and bodies/files require explicit artifact fetch.',\n args: {\n artifactKind: tool.schema\n .string()\n .optional()\n .describe('Wizard artifact kind to catalog: SKILL or DESIGN_DOC; defaults to SKILL'),\n directory: tool.schema.string().optional().describe('Optional absolute or relative directory override'),\n refresh: tool.schema.boolean().optional().describe('Bypass the local plugin cache for this request'),\n },\n async execute(args, context) {\n return handlers.fetchWizardArtifactCatalog(args, context);\n },\n }),\n opencode_wizard_artifact_fetch: tool<WizardArtifactFetchArgs>({\n description:\n 'Always-available canonical wizard artifact detail tool. Supports artifactKind SKILL and DESIGN_DOC; fetches explicit backend-authorized bodies/files for effective artifacts.',\n args: {\n artifactKind: tool.schema\n .string()\n .optional()\n .describe('Wizard artifact kind to fetch: SKILL or DESIGN_DOC; defaults to SKILL'),\n artifact: tool.schema\n .string()\n .optional()\n .describe('Single artifact identifier; for SKILL this is a skill slug, artifact name, or skill name'),\n artifacts: tool.schema\n .string()\n .optional()\n .describe('One or more comma-separated or newline-separated artifact identifiers'),\n directory: tool.schema.string().optional().describe('Optional absolute or relative directory override'),\n refresh: tool.schema.boolean().optional().describe('Bypass the local plugin cache for this request'),\n },\n async execute(args, context) {\n return handlers.fetchWizardArtifacts(args, context);\n },\n }),\n opencode_wizard_artifact_preference_set: tool<WizardArtifactPreferenceArgs>({\n description:\n 'Always-available canonical wizard artifact preference tool. Supports SKILL and DESIGN_DOC install/uninstall/ignore/unignore through server-backed artifact preference APIs.',\n args: {\n artifactKind: tool.schema\n .string()\n .optional()\n .describe('Wizard artifact kind to update: SKILL or DESIGN_DOC; defaults to SKILL'),\n artifact: tool.schema.string().describe('Artifact identifier; for SKILL this is the published skill slug'),\n action: tool.schema\n .string()\n .describe('Preference action: install, uninstall, ignore, or unignore'),\n preferenceScope: tool.schema\n .string()\n .optional()\n .describe('Preference scope for the action: project or global; defaults to project'),\n directory: tool.schema.string().optional().describe('Optional absolute or relative directory override'),\n },\n async execute(args, context) {\n return handlers.updateWizardArtifactPreference(args, context);\n },\n }),\n opencode_wizard_published_skills_fetch: tool<PublishedSkillFetchArgs>({\n description:\n 'Always-available tool to fetch one or multiple wizard-published skill bodies/details for the current scope. Use this for wizard-listed/private/scoped/backend-published skill slugs instead of the native OpenCode skill tool; auth/catalog failures are returned in tool output. Prefer `skills` for multiple identifiers, call with no args to discover/bootstrap auth, and pass `refresh: true` before clearing plugin/OpenCode caches',\n args: {\n skill: tool.schema\n .string()\n .optional()\n .describe(\n 'Single skill slug, artifact name, or skill name; backward-compatible with comma/newline-delimited lists',\n ),\n skills: tool.schema\n .string()\n .optional()\n .describe('One or more comma-separated or newline-separated skill slugs, artifact names, or skill names'),\n directory: tool.schema.string().optional().describe('Optional absolute or relative directory override'),\n refresh: tool.schema.boolean().optional().describe('Bypass the local plugin cache for this request'),\n },\n async execute(args, context) {\n return handlers.fetchPublishedSkills(args, context);\n },\n }),\n opencode_wizard_published_skill_preference_set: tool<PublishedSkillPreferenceArgs>({\n description:\n 'Always-available tool to install, uninstall, ignore, or unignore a backend-published wizard skill for non-TUI workflows using the same shared server-backed preference API as the TUI overlay; auth/catalog failures are returned in tool output',\n args: {\n skill: tool.schema.string().describe('Published skill slug, artifact name, or skill name to update'),\n action: tool.schema\n .string()\n .describe('Preference action: install, uninstall, ignore, or unignore'),\n preferenceScope: tool.schema\n .string()\n .optional()\n .describe('Preference scope for the action: project or global; defaults to project'),\n directory: tool.schema.string().optional().describe('Optional absolute or relative directory override'),\n },\n async execute(args, context) {\n return handlers.updatePublishedSkillPreference(args, context);\n },\n }),\n opencode_wizard_status: tool<PluginStatusArgs>({\n description:\n 'Always-available tool to report opencode-wizard plugin status, bootstrap auth when missing, and return safe auth/catalog/source/cache/workspace guidance without exposing tokens',\n args: {\n directory: tool.schema.string().optional().describe('Optional absolute or relative directory override'),\n },\n async execute(args, context) {\n return handlers.getStatus(args, context);\n },\n }),\n },\n editorOnlyTools: {\n opencode_wizard_editor_publish_skill: tool<EditorPublishSkillArgs>({\n description:\n 'Read skill markdown files from .opencode/skills/ and publish them to the backend via the createOrUpdateSkillFromMarkdown mutation. Requires EDITOR role.',\n args: {\n skillSlug: tool.schema\n .string()\n .describe('Skill slug matching a directory under .opencode/skills/'),\n directory: tool.schema.string().optional().describe('Optional absolute or relative directory override'),\n },\n async execute(args, context) {\n return handlers.publishEditorSkill(args, context);\n },\n }),\n },\n});\n"],"mappings":"AAmFA,OAAO,MAAMA,+BAA+B,GAAG,CAC7C,+BAA+B,EAC/B,gCAAgC,EAChC,yCAAyC,EACzC,wCAAwC,EACxC,gDAAgD,EAChD,wBAAwB,EACxB,sCAAsC,CACvC;AAED,MAAMC,4BAA4B,GAAGD,+BAA+B,CAACE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;AAEhF,OAAO,MAAMC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,CAACC,QAAQ,CAAC,kDAAkD;MACxG,CAAC;MACD,MAAMI,OAAOA,CAACT,IAAI,EAAEU,OAAO,EAAE;QAC3B,OAAOd,QAAQ,CAAC6B,8BAA8B,CAACzB,IAAI,EAAEU,OAAO,CAAC;MAC/D;IACF,CAAC,CAAC;IACFgB,sBAAsB,EAAE/B,IAAI,CAAmB;MAC7CI,WAAW,EACT,kLAAkL;MACpLC,IAAI,EAAE;QACJM,SAAS,EAAEX,IAAI,CAACO,MAAM,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,QAAQ,CAAC,kDAAkD;MACxG,CAAC;MACD,MAAMI,OAAOA,CAACT,IAAI,EAAEU,OAAO,EAAE;QAC3B,OAAOd,QAAQ,CAAC+B,SAAS,CAAC3B,IAAI,EAAEU,OAAO,CAAC;MAC1C;IACF,CAAC;EACH,CAAC;EACDkB,eAAe,EAAE;IACfC,oCAAoC,EAAElC,IAAI,CAAyB;MACjEI,WAAW,EACT,0JAA0J;MAC5JC,IAAI,EAAE;QACJ8B,SAAS,EAAEnC,IAAI,CAACO,MAAM,CACnBC,MAAM,CAAC,CAAC,CACRE,QAAQ,CAAC,yDAAyD,CAAC;QACtEC,SAAS,EAAEX,IAAI,CAACO,MAAM,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,QAAQ,CAAC,kDAAkD;MACxG,CAAC;MACD,MAAMI,OAAOA,CAACT,IAAI,EAAEU,OAAO,EAAE;QAC3B,OAAOd,QAAQ,CAACmC,kBAAkB,CAAC/B,IAAI,EAAEU,OAAO,CAAC;MACnD;IACF,CAAC;EACH;AACF,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["AVAILABLE_PUBLISHED_SKILL_TOOLS","SHARED_PUBLISHED_SKILL_TOOLS","slice","resolveAvailableTools","role","createPublishedSkillToolDefinitions","tool","handlers","sharedTools","opencode_wizard_catalog_fetch","description","args","artifactKind","schema","string","optional","describe","directory","refresh","boolean","execute","context","fetchWizardArtifactCatalog","opencode_wizard_artifact_fetch","artifact","artifacts","fetchWizardArtifacts","opencode_wizard_artifact_preference_set","action","preferenceScope","updateWizardArtifactPreference","opencode_wizard_published_skills_fetch","skill","skills","fetchPublishedSkills","opencode_wizard_published_skill_preference_set","updatePublishedSkillPreference","opencode_wizard_status","getStatus","editorOnlyTools","opencode_wizard_editor_publish_skill","skillSlug","publishEditorSkill","opencode_wizard_artifact_import","source","slug","name","summary","importWizardArtifact"],"sources":["../src/plugin-tools.ts"],"sourcesContent":["export type PublishedSkillFetchArgs = {\n skill?: string;\n skills?: string;\n directory?: string;\n refresh?: boolean;\n};\n\nexport type WizardArtifactKind = 'SKILL' | 'DESIGN_DOC';\n\nexport type WizardArtifactCatalogFetchArgs = {\n artifactKind?: string;\n directory?: string;\n refresh?: boolean;\n};\n\nexport type WizardArtifactFetchArgs = {\n artifactKind?: string;\n artifact?: string;\n artifacts?: string;\n directory?: string;\n refresh?: boolean;\n};\n\nexport type PluginStatusArgs = {\n directory?: string;\n};\n\nexport type PublishedSkillPreferenceArgs = {\n skill: string;\n action: string;\n preferenceScope?: string;\n directory?: string;\n};\n\nexport type WizardArtifactPreferenceArgs = {\n artifactKind?: string;\n artifact: string;\n action: string;\n preferenceScope?: string;\n directory?: string;\n};\n\nexport type EditorPublishSkillArgs = {\n skillSlug: string;\n directory?: string;\n};\n\nexport type WizardArtifactImportArgs = {\n artifactKind?: string;\n source: string;\n slug?: string;\n skill?: string;\n name?: string;\n summary?: string;\n directory?: string;\n};\n\ntype ToolSchemaValue<TSelf> = {\n optional: () => TSelf;\n describe: (description: string) => TSelf;\n};\n\ntype ToolSchema = {\n string: () => ToolSchemaValue<ToolSchemaValue<unknown>>;\n boolean: () => ToolSchemaValue<ToolSchemaValue<unknown>>;\n};\n\nexport type ToolExecuteContext = {\n directory: string;\n abort: AbortSignal;\n metadata: (payload: { title: string; metadata: Record<string, string> }) => void;\n};\n\ntype ToolDefinition<TArgs extends object> = {\n description: string;\n args: { [K in keyof TArgs]-?: unknown };\n execute: (args: TArgs, context: ToolExecuteContext) => Promise<unknown>;\n};\n\nexport type ToolFactory = (<TArgs extends object>(definition: ToolDefinition<TArgs>) => unknown) & {\n schema: ToolSchema;\n};\n\ntype PublishedSkillToolHandlers = {\n fetchPublishedSkills: (args: PublishedSkillFetchArgs, context: ToolExecuteContext) => Promise<unknown>;\n fetchWizardArtifactCatalog: (args: WizardArtifactCatalogFetchArgs, context: ToolExecuteContext) => Promise<unknown>;\n fetchWizardArtifacts: (args: WizardArtifactFetchArgs, context: ToolExecuteContext) => Promise<unknown>;\n updatePublishedSkillPreference: (args: PublishedSkillPreferenceArgs, context: ToolExecuteContext) => Promise<unknown>;\n updateWizardArtifactPreference: (args: WizardArtifactPreferenceArgs, context: ToolExecuteContext) => Promise<unknown>;\n getStatus: (args: PluginStatusArgs, context: ToolExecuteContext) => Promise<unknown>;\n publishEditorSkill: (args: EditorPublishSkillArgs, context: ToolExecuteContext) => Promise<unknown>;\n importWizardArtifact: (args: WizardArtifactImportArgs, context: ToolExecuteContext) => Promise<unknown>;\n};\n\nexport const AVAILABLE_PUBLISHED_SKILL_TOOLS = [\n 'opencode_wizard_catalog_fetch',\n 'opencode_wizard_artifact_fetch',\n 'opencode_wizard_artifact_preference_set',\n 'opencode_wizard_published_skills_fetch',\n 'opencode_wizard_published_skill_preference_set',\n 'opencode_wizard_status',\n 'opencode_wizard_editor_publish_skill',\n 'opencode_wizard_artifact_import',\n];\n\nconst SHARED_PUBLISHED_SKILL_TOOLS = AVAILABLE_PUBLISHED_SKILL_TOOLS.slice(0, 6);\n\nexport const resolveAvailableTools = (role: string | null | undefined): string[] => {\n if (role === 'EDITOR') return [...AVAILABLE_PUBLISHED_SKILL_TOOLS];\n return [...SHARED_PUBLISHED_SKILL_TOOLS];\n};\n\nexport const createPublishedSkillToolDefinitions = (\n tool: ToolFactory,\n handlers: PublishedSkillToolHandlers,\n) => ({\n sharedTools: {\n opencode_wizard_catalog_fetch: tool<WizardArtifactCatalogFetchArgs>({\n description:\n 'Always-available canonical wizard artifact catalog tool. Supports artifactKind SKILL and DESIGN_DOC; catalogs are metadata-only and bodies/files require explicit artifact fetch.',\n args: {\n artifactKind: tool.schema\n .string()\n .optional()\n .describe('Wizard artifact kind to catalog: SKILL or DESIGN_DOC; defaults to SKILL'),\n directory: tool.schema.string().optional().describe('Optional absolute or relative directory override'),\n refresh: tool.schema.boolean().optional().describe('Bypass the local plugin cache for this request'),\n },\n async execute(args, context) {\n return handlers.fetchWizardArtifactCatalog(args, context);\n },\n }),\n opencode_wizard_artifact_fetch: tool<WizardArtifactFetchArgs>({\n description:\n 'Always-available canonical wizard artifact detail tool. Supports artifactKind SKILL and DESIGN_DOC; fetches explicit backend-authorized bodies/files for effective artifacts.',\n args: {\n artifactKind: tool.schema\n .string()\n .optional()\n .describe('Wizard artifact kind to fetch: SKILL or DESIGN_DOC; defaults to SKILL'),\n artifact: tool.schema\n .string()\n .optional()\n .describe('Single artifact identifier; for SKILL this is a skill slug, artifact name, or skill name'),\n artifacts: tool.schema\n .string()\n .optional()\n .describe('One or more comma-separated or newline-separated artifact identifiers'),\n directory: tool.schema.string().optional().describe('Optional absolute or relative directory override'),\n refresh: tool.schema.boolean().optional().describe('Bypass the local plugin cache for this request'),\n },\n async execute(args, context) {\n return handlers.fetchWizardArtifacts(args, context);\n },\n }),\n opencode_wizard_artifact_preference_set: tool<WizardArtifactPreferenceArgs>({\n description:\n 'Always-available canonical wizard artifact preference tool. Supports SKILL and DESIGN_DOC install/uninstall/ignore/unignore through server-backed artifact preference APIs.',\n args: {\n artifactKind: tool.schema\n .string()\n .optional()\n .describe('Wizard artifact kind to update: SKILL or DESIGN_DOC; defaults to SKILL'),\n artifact: tool.schema.string().describe('Artifact identifier; for SKILL this is the published skill slug'),\n action: tool.schema\n .string()\n .describe('Preference action: install, uninstall, ignore, or unignore'),\n preferenceScope: tool.schema\n .string()\n .optional()\n .describe('Preference scope for the action: project or global; defaults to project'),\n directory: tool.schema.string().optional().describe('Optional absolute or relative directory override'),\n },\n async execute(args, context) {\n return handlers.updateWizardArtifactPreference(args, context);\n },\n }),\n opencode_wizard_published_skills_fetch: tool<PublishedSkillFetchArgs>({\n description:\n 'Always-available tool to fetch one or multiple wizard-published skill bodies/details for the current scope. Use this for wizard-listed/private/scoped/backend-published skill slugs instead of the native OpenCode skill tool; auth/catalog failures are returned in tool output. Prefer `skills` for multiple identifiers, call with no args to discover/bootstrap auth, and pass `refresh: true` before clearing plugin/OpenCode caches',\n args: {\n skill: tool.schema\n .string()\n .optional()\n .describe(\n 'Single skill slug, artifact name, or skill name; backward-compatible with comma/newline-delimited lists',\n ),\n skills: tool.schema\n .string()\n .optional()\n .describe('One or more comma-separated or newline-separated skill slugs, artifact names, or skill names'),\n directory: tool.schema.string().optional().describe('Optional absolute or relative directory override'),\n refresh: tool.schema.boolean().optional().describe('Bypass the local plugin cache for this request'),\n },\n async execute(args, context) {\n return handlers.fetchPublishedSkills(args, context);\n },\n }),\n opencode_wizard_published_skill_preference_set: tool<PublishedSkillPreferenceArgs>({\n description:\n 'Always-available tool to install, uninstall, ignore, or unignore a backend-published wizard skill for non-TUI workflows using the same shared server-backed preference API as the TUI overlay; auth/catalog failures are returned in tool output',\n args: {\n skill: tool.schema.string().describe('Published skill slug, artifact name, or skill name to update'),\n action: tool.schema\n .string()\n .describe('Preference action: install, uninstall, ignore, or unignore'),\n preferenceScope: tool.schema\n .string()\n .optional()\n .describe('Preference scope for the action: project or global; defaults to project'),\n directory: tool.schema.string().optional().describe('Optional absolute or relative directory override'),\n },\n async execute(args, context) {\n return handlers.updatePublishedSkillPreference(args, context);\n },\n }),\n opencode_wizard_status: tool<PluginStatusArgs>({\n description:\n 'Always-available tool to report opencode-wizard plugin status, bootstrap auth when missing, and return safe auth/catalog/source/cache/workspace guidance without exposing tokens',\n args: {\n directory: tool.schema.string().optional().describe('Optional absolute or relative directory override'),\n },\n async execute(args, context) {\n return handlers.getStatus(args, context);\n },\n }),\n },\n editorOnlyTools: {\n opencode_wizard_editor_publish_skill: tool<EditorPublishSkillArgs>({\n description:\n 'Read skill markdown files from .opencode/skills/ and publish them to the backend via the createOrUpdateSkillFromMarkdown mutation. Requires EDITOR role.',\n args: {\n skillSlug: tool.schema\n .string()\n .describe('Skill slug matching a directory under .opencode/skills/'),\n directory: tool.schema.string().optional().describe('Optional absolute or relative directory override'),\n },\n async execute(args, context) {\n return handlers.publishEditorSkill(args, context);\n },\n }),\n opencode_wizard_artifact_import: tool<WizardArtifactImportArgs>({\n description:\n 'Editor-only import tool for external wizard artifacts. Supports SKILL from GitHub/raw SKILL.md sources and DESIGN_DOC from direct URLs or command-like inputs such as `npx getdesign@latest add bmw-m`. Imported backend artifacts become the plugin runtime authority; no project files are written.',\n args: {\n artifactKind: tool.schema\n .string()\n .optional()\n .describe('Wizard artifact kind to import: SKILL or DESIGN_DOC; inferred from source when omitted'),\n source: tool.schema\n .string()\n .describe('Direct URL or command-like input, e.g. `https://github.com/vercel-labs/skills --skill find-skills` or `npx getdesign@latest add bmw-m`'),\n slug: tool.schema.string().optional().describe('Artifact slug; required for DESIGN_DOC unless inferable'),\n skill: tool.schema.string().optional().describe('Skill directory/name for SKILL repo imports'),\n name: tool.schema.string().optional().describe('Optional display name override'),\n summary: tool.schema.string().optional().describe('Optional summary/description override'),\n directory: tool.schema.string().optional().describe('Optional absolute or relative directory override'),\n },\n async execute(args, context) {\n return handlers.importWizardArtifact(args, context);\n },\n }),\n },\n});\n"],"mappings":"AA8FA,OAAO,MAAMA,+BAA+B,GAAG,CAC7C,+BAA+B,EAC/B,gCAAgC,EAChC,yCAAyC,EACzC,wCAAwC,EACxC,gDAAgD,EAChD,wBAAwB,EACxB,sCAAsC,EACtC,iCAAiC,CAClC;AAED,MAAMC,4BAA4B,GAAGD,+BAA+B,CAACE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;AAEhF,OAAO,MAAMC,qBAAqB,GAAIC,IAA+B,IAAe;EA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CAChBC,MAAM,CAAC,CAAC,CACRE,QAAQ,CAAC,wIAAwI,CAAC;QACrJ6B,IAAI,EAAEvC,IAAI,CAACO,MAAM,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,QAAQ,CAAC,yDAAyD,CAAC;QACzGgB,KAAK,EAAE1B,IAAI,CAACO,MAAM,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,QAAQ,CAAC,6CAA6C,CAAC;QAC9F8B,IAAI,EAAExC,IAAI,CAACO,MAAM,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,QAAQ,CAAC,gCAAgC,CAAC;QAChF+B,OAAO,EAAEzC,IAAI,CAACO,MAAM,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,QAAQ,CAAC,uCAAuC,CAAC;QAC1FC,SAAS,EAAEX,IAAI,CAACO,MAAM,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,QAAQ,CAAC,kDAAkD;MACxG,CAAC;MACD,MAAMI,OAAOA,CAACT,IAAI,EAAEU,OAAO,EAAE;QAC3B,OAAOd,QAAQ,CAACyC,oBAAoB,CAACrC,IAAI,EAAEU,OAAO,CAAC;MACrD;IACF,CAAC;EACH;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { WizardArtifactKind } from './types.js';
|
|
2
|
+
type ImportSourcePlan = {
|
|
3
|
+
artifactKind: WizardArtifactKind;
|
|
4
|
+
slug: string | null;
|
|
5
|
+
skill: string | null;
|
|
6
|
+
source: string;
|
|
7
|
+
sourceRef: string;
|
|
8
|
+
candidateUrls: string[];
|
|
9
|
+
};
|
|
10
|
+
export type ResolvedImportSource = ImportSourcePlan & {
|
|
11
|
+
markdownContent: string;
|
|
12
|
+
fetchedUrl: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const planWizardArtifactImport: (input: {
|
|
15
|
+
artifactKind?: string;
|
|
16
|
+
source: string;
|
|
17
|
+
slug?: string;
|
|
18
|
+
skill?: string;
|
|
19
|
+
}) => ImportSourcePlan;
|
|
20
|
+
export declare const fetchWizardArtifactImportSource: (input: {
|
|
21
|
+
artifactKind?: string;
|
|
22
|
+
source: string;
|
|
23
|
+
slug?: string;
|
|
24
|
+
skill?: string;
|
|
25
|
+
signal: AbortSignal;
|
|
26
|
+
}) => Promise<ResolvedImportSource>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { strFromU8, unzipSync } from 'fflate';
|
|
2
|
+
const GETDESIGN_RAW_BASE = 'https://raw.githubusercontent.com/VoltAgent/awesome-design-md/main/design-md';
|
|
3
|
+
const ZIP_MARKDOWN_FILE_PRIORITY = ['SKILL.md', 'skill.md', 'Skill.md', 'README.md', 'readme.md'];
|
|
4
|
+
const tokenizeCommandLikeInput = input => {
|
|
5
|
+
const tokens = input.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g) ?? [];
|
|
6
|
+
return tokens.map(token => token.replace(/^("|')|("|')$/g, ''));
|
|
7
|
+
};
|
|
8
|
+
const normalizeSlug = value => {
|
|
9
|
+
return value.trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
|
|
10
|
+
};
|
|
11
|
+
const parseOptionValue = (tokens, optionName) => {
|
|
12
|
+
const inlinePrefix = `${optionName}=`;
|
|
13
|
+
const inlineToken = tokens.find(token => token.startsWith(inlinePrefix));
|
|
14
|
+
if (inlineToken) return inlineToken.slice(inlinePrefix.length) || null;
|
|
15
|
+
const optionIndex = tokens.indexOf(optionName);
|
|
16
|
+
if (optionIndex < 0) return null;
|
|
17
|
+
return tokens[optionIndex + 1] ?? null;
|
|
18
|
+
};
|
|
19
|
+
const toWizardArtifactKind = value => {
|
|
20
|
+
const normalized = value.trim().toUpperCase();
|
|
21
|
+
if (normalized === 'SKILL' || normalized === 'DESIGN_DOC') return normalized;
|
|
22
|
+
throw new Error('artifactKind must be SKILL or DESIGN_DOC.');
|
|
23
|
+
};
|
|
24
|
+
const firstUrlToken = tokens => {
|
|
25
|
+
return tokens.find(token => /^https?:\/\//i.test(token)) ?? null;
|
|
26
|
+
};
|
|
27
|
+
const toRawGithubUrl = inputUrl => {
|
|
28
|
+
const parsedUrl = new URL(inputUrl);
|
|
29
|
+
if (parsedUrl.hostname === 'raw.githubusercontent.com') return parsedUrl.toString();
|
|
30
|
+
if (parsedUrl.hostname !== 'github.com') return null;
|
|
31
|
+
const parts = parsedUrl.pathname.split('/').filter(Boolean);
|
|
32
|
+
if (parts.length < 2) return null;
|
|
33
|
+
const [owner, repo, marker, branch, ...rest] = parts;
|
|
34
|
+
if (marker === 'blob' || marker === 'tree') {
|
|
35
|
+
return `https://raw.githubusercontent.com/${owner}/${repo}/${branch}/${rest.join('/')}`;
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
};
|
|
39
|
+
const isZipUrl = inputUrl => {
|
|
40
|
+
try {
|
|
41
|
+
return new URL(inputUrl).pathname.toLowerCase().endsWith('.zip');
|
|
42
|
+
} catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const zipSourceRef = (sourceRef, markdownPath) => {
|
|
47
|
+
const separator = sourceRef.includes('#') ? '&' : '#';
|
|
48
|
+
return `${sourceRef}${separator}path=${encodeURIComponent(markdownPath)}`;
|
|
49
|
+
};
|
|
50
|
+
const zipPathDepth = entryPath => entryPath.split('/').filter(Boolean).length;
|
|
51
|
+
const selectZipMarkdownEntry = archive => {
|
|
52
|
+
const candidates = Object.entries(archive).map(([entryPath, bytes]) => {
|
|
53
|
+
const fileName = entryPath.split('/').filter(Boolean).at(-1) ?? '';
|
|
54
|
+
const priority = ZIP_MARKDOWN_FILE_PRIORITY.indexOf(fileName);
|
|
55
|
+
if (priority < 0) return null;
|
|
56
|
+
return {
|
|
57
|
+
path: entryPath,
|
|
58
|
+
content: strFromU8(bytes),
|
|
59
|
+
priority,
|
|
60
|
+
depth: zipPathDepth(entryPath)
|
|
61
|
+
};
|
|
62
|
+
}).filter(candidate => candidate !== null).sort((left, right) => {
|
|
63
|
+
if (left.priority !== right.priority) return left.priority - right.priority;
|
|
64
|
+
if (left.depth !== right.depth) return left.depth - right.depth;
|
|
65
|
+
if (left.path.length !== right.path.length) return left.path.length - right.path.length;
|
|
66
|
+
return left.path.localeCompare(right.path);
|
|
67
|
+
});
|
|
68
|
+
return candidates[0] ?? null;
|
|
69
|
+
};
|
|
70
|
+
const extractMarkdownFromZip = bytes => {
|
|
71
|
+
const archive = unzipSync(new Uint8Array(bytes));
|
|
72
|
+
const selectedEntry = selectZipMarkdownEntry(archive);
|
|
73
|
+
if (!selectedEntry) throw new Error('No SKILL.md or README.md markdown file found in zip archive.');
|
|
74
|
+
return selectedEntry;
|
|
75
|
+
};
|
|
76
|
+
const buildGithubSkillCandidateUrls = (sourceUrl, skill) => {
|
|
77
|
+
const parsedUrl = new URL(sourceUrl);
|
|
78
|
+
if (isZipUrl(sourceUrl)) return [sourceUrl];
|
|
79
|
+
if (parsedUrl.hostname === 'raw.githubusercontent.com') return [parsedUrl.toString()];
|
|
80
|
+
if (parsedUrl.hostname !== 'github.com') return [sourceUrl];
|
|
81
|
+
const rawUrl = toRawGithubUrl(sourceUrl);
|
|
82
|
+
if (rawUrl?.endsWith('/SKILL.md')) return [rawUrl];
|
|
83
|
+
const parts = parsedUrl.pathname.split('/').filter(Boolean);
|
|
84
|
+
const [owner, repo, marker, branch, ...treePathParts] = parts;
|
|
85
|
+
const branches = marker === 'tree' && branch ? [branch] : ['main', 'master'];
|
|
86
|
+
const treePath = marker === 'tree' ? treePathParts.join('/') : '';
|
|
87
|
+
const skillSlug = skill ? normalizeSlug(skill) : null;
|
|
88
|
+
const paths = new Set();
|
|
89
|
+
if (treePath) paths.add(`${treePath}/SKILL.md`);
|
|
90
|
+
if (!treePath) paths.add('SKILL.md');
|
|
91
|
+
if (skillSlug) {
|
|
92
|
+
paths.add(`skills/${skillSlug}/SKILL.md`);
|
|
93
|
+
paths.add(`.agents/skills/${skillSlug}/SKILL.md`);
|
|
94
|
+
if (treePath) paths.add(`${treePath}/skills/${skillSlug}/SKILL.md`);
|
|
95
|
+
if (treePath) paths.add(`${treePath}/.agents/skills/${skillSlug}/SKILL.md`);
|
|
96
|
+
}
|
|
97
|
+
return branches.flatMap(candidateBranch => [...paths].map(candidatePath => `https://raw.githubusercontent.com/${owner}/${repo}/${candidateBranch}/${candidatePath}`));
|
|
98
|
+
};
|
|
99
|
+
export const planWizardArtifactImport = input => {
|
|
100
|
+
const source = input.source.trim();
|
|
101
|
+
const tokens = tokenizeCommandLikeInput(source);
|
|
102
|
+
const optionSkill = parseOptionValue(tokens, '--skill');
|
|
103
|
+
const skill = input.skill?.trim() || optionSkill || null;
|
|
104
|
+
const getdesignSlug = tokens.find((token, index) => tokens[index - 1] === 'add' && !token.startsWith('-')) ?? null;
|
|
105
|
+
const inferredKind = source.includes('getdesign') ? 'DESIGN_DOC' : 'SKILL';
|
|
106
|
+
const artifactKind = input.artifactKind ? toWizardArtifactKind(input.artifactKind) : inferredKind;
|
|
107
|
+
if (artifactKind === 'DESIGN_DOC') {
|
|
108
|
+
const rawSlug = input.slug?.trim() || getdesignSlug;
|
|
109
|
+
if (!rawSlug) throw new Error('DESIGN_DOC import requires a slug or a getdesign `add <slug>` input.');
|
|
110
|
+
const slug = normalizeSlug(rawSlug);
|
|
111
|
+
const directUrl = firstUrlToken(tokens);
|
|
112
|
+
const candidateUrls = directUrl ? [toRawGithubUrl(directUrl) ?? directUrl] : [`${GETDESIGN_RAW_BASE}/${slug}/DESIGN.md`];
|
|
113
|
+
return {
|
|
114
|
+
artifactKind,
|
|
115
|
+
slug,
|
|
116
|
+
skill: null,
|
|
117
|
+
source,
|
|
118
|
+
sourceRef: directUrl ?? `getdesign:${slug}`,
|
|
119
|
+
candidateUrls
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const sourceUrl = firstUrlToken(tokens) ?? source;
|
|
123
|
+
return {
|
|
124
|
+
artifactKind: 'SKILL',
|
|
125
|
+
slug: input.slug ? normalizeSlug(input.slug) : null,
|
|
126
|
+
skill,
|
|
127
|
+
source,
|
|
128
|
+
sourceRef: skill ? `${sourceUrl}#skill=${skill}` : sourceUrl,
|
|
129
|
+
candidateUrls: buildGithubSkillCandidateUrls(sourceUrl, skill)
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
export const fetchWizardArtifactImportSource = async input => {
|
|
133
|
+
const plan = planWizardArtifactImport(input);
|
|
134
|
+
const errors = [];
|
|
135
|
+
for (const candidateUrl of plan.candidateUrls) {
|
|
136
|
+
try {
|
|
137
|
+
const response = await fetch(candidateUrl, {
|
|
138
|
+
signal: input.signal
|
|
139
|
+
});
|
|
140
|
+
if (!response.ok) {
|
|
141
|
+
errors.push(`${candidateUrl}: HTTP ${response.status}`);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (isZipUrl(candidateUrl)) {
|
|
145
|
+
const zipMarkdown = extractMarkdownFromZip(await response.arrayBuffer());
|
|
146
|
+
return {
|
|
147
|
+
...plan,
|
|
148
|
+
markdownContent: zipMarkdown.content,
|
|
149
|
+
fetchedUrl: candidateUrl,
|
|
150
|
+
sourceRef: zipSourceRef(plan.sourceRef, zipMarkdown.path)
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
...plan,
|
|
155
|
+
markdownContent: await response.text(),
|
|
156
|
+
fetchedUrl: candidateUrl
|
|
157
|
+
};
|
|
158
|
+
} catch (error) {
|
|
159
|
+
errors.push(`${candidateUrl}: ${error instanceof Error ? error.message : 'Unknown fetch error'}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
throw new Error(`Could not fetch import source. Tried: ${errors.join('; ')}`);
|
|
163
|
+
};
|
|
164
|
+
//# sourceMappingURL=import-sources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["strFromU8","unzipSync","GETDESIGN_RAW_BASE","ZIP_MARKDOWN_FILE_PRIORITY","tokenizeCommandLikeInput","input","tokens","match","map","token","replace","normalizeSlug","value","trim","toLowerCase","parseOptionValue","optionName","inlinePrefix","inlineToken","find","startsWith","slice","length","optionIndex","indexOf","toWizardArtifactKind","normalized","toUpperCase","Error","firstUrlToken","test","toRawGithubUrl","inputUrl","parsedUrl","URL","hostname","toString","parts","pathname","split","filter","Boolean","owner","repo","marker","branch","rest","join","isZipUrl","endsWith","zipSourceRef","sourceRef","markdownPath","separator","includes","encodeURIComponent","zipPathDepth","entryPath","selectZipMarkdownEntry","archive","candidates","Object","entries","bytes","fileName","at","priority","path","content","depth","candidate","sort","left","right","localeCompare","extractMarkdownFromZip","Uint8Array","selectedEntry","buildGithubSkillCandidateUrls","sourceUrl","skill","rawUrl","treePathParts","branches","treePath","skillSlug","paths","Set","add","flatMap","candidateBranch","candidatePath","planWizardArtifactImport","source","optionSkill","getdesignSlug","index","inferredKind","artifactKind","rawSlug","slug","directUrl","candidateUrls","fetchWizardArtifactImportSource","plan","errors","candidateUrl","response","fetch","signal","ok","push","status","zipMarkdown","arrayBuffer","markdownContent","fetchedUrl","text","error","message"],"sources":["../../src/server/import-sources.ts"],"sourcesContent":["import { strFromU8, unzipSync } from 'fflate';\nimport type { WizardArtifactKind } from './types.js';\n\ntype ImportSourcePlan = {\n artifactKind: WizardArtifactKind;\n slug: string | null;\n skill: string | null;\n source: string;\n sourceRef: string;\n candidateUrls: string[];\n};\n\nexport type ResolvedImportSource = ImportSourcePlan & {\n markdownContent: string;\n fetchedUrl: string;\n};\n\nconst GETDESIGN_RAW_BASE = 'https://raw.githubusercontent.com/VoltAgent/awesome-design-md/main/design-md';\nconst ZIP_MARKDOWN_FILE_PRIORITY = ['SKILL.md', 'skill.md', 'Skill.md', 'README.md', 'readme.md'] as const;\n\nconst tokenizeCommandLikeInput = (input: string): string[] => {\n const tokens = input.match(/(?:[^\\s\"']+|\"[^\"]*\"|'[^']*')+/g) ?? [];\n return tokens.map((token) => token.replace(/^(\"|')|(\"|')$/g, ''));\n};\n\nconst normalizeSlug = (value: string): string => {\n return value\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n};\n\nconst parseOptionValue = (tokens: string[], optionName: string): string | null => {\n const inlinePrefix = `${optionName}=`;\n const inlineToken = tokens.find((token) => token.startsWith(inlinePrefix));\n if (inlineToken) return inlineToken.slice(inlinePrefix.length) || null;\n\n const optionIndex = tokens.indexOf(optionName);\n if (optionIndex < 0) return null;\n return tokens[optionIndex + 1] ?? null;\n};\n\nconst toWizardArtifactKind = (value: string): WizardArtifactKind => {\n const normalized = value.trim().toUpperCase();\n if (normalized === 'SKILL' || normalized === 'DESIGN_DOC') return normalized;\n throw new Error('artifactKind must be SKILL or DESIGN_DOC.');\n};\n\nconst firstUrlToken = (tokens: string[]): string | null => {\n return tokens.find((token) => /^https?:\\/\\//i.test(token)) ?? null;\n};\n\nconst toRawGithubUrl = (inputUrl: string): string | null => {\n const parsedUrl = new URL(inputUrl);\n if (parsedUrl.hostname === 'raw.githubusercontent.com') return parsedUrl.toString();\n if (parsedUrl.hostname !== 'github.com') return null;\n\n const parts = parsedUrl.pathname.split('/').filter(Boolean);\n if (parts.length < 2) return null;\n\n const [owner, repo, marker, branch, ...rest] = parts;\n if (marker === 'blob' || marker === 'tree') {\n return `https://raw.githubusercontent.com/${owner}/${repo}/${branch}/${rest.join('/')}`;\n }\n\n return null;\n};\n\nconst isZipUrl = (inputUrl: string): boolean => {\n try {\n return new URL(inputUrl).pathname.toLowerCase().endsWith('.zip');\n } catch {\n return false;\n }\n};\n\nconst zipSourceRef = (sourceRef: string, markdownPath: string): string => {\n const separator = sourceRef.includes('#') ? '&' : '#';\n return `${sourceRef}${separator}path=${encodeURIComponent(markdownPath)}`;\n};\n\nconst zipPathDepth = (entryPath: string): number => entryPath.split('/').filter(Boolean).length;\n\nconst selectZipMarkdownEntry = (archive: Record<string, Uint8Array>): { path: string; content: string } | null => {\n const candidates = Object.entries(archive)\n .map(([entryPath, bytes]) => {\n const fileName = entryPath.split('/').filter(Boolean).at(-1) ?? '';\n const priority = ZIP_MARKDOWN_FILE_PRIORITY.indexOf(fileName as (typeof ZIP_MARKDOWN_FILE_PRIORITY)[number]);\n if (priority < 0) return null;\n\n return {\n path: entryPath,\n content: strFromU8(bytes),\n priority,\n depth: zipPathDepth(entryPath),\n };\n })\n .filter((candidate): candidate is { path: string; content: string; priority: number; depth: number } => candidate !== null)\n .sort((left, right) => {\n if (left.priority !== right.priority) return left.priority - right.priority;\n if (left.depth !== right.depth) return left.depth - right.depth;\n if (left.path.length !== right.path.length) return left.path.length - right.path.length;\n return left.path.localeCompare(right.path);\n });\n\n return candidates[0] ?? null;\n};\n\nconst extractMarkdownFromZip = (bytes: ArrayBuffer): { path: string; content: string } => {\n const archive = unzipSync(new Uint8Array(bytes));\n const selectedEntry = selectZipMarkdownEntry(archive);\n if (!selectedEntry) throw new Error('No SKILL.md or README.md markdown file found in zip archive.');\n return selectedEntry;\n};\n\nconst buildGithubSkillCandidateUrls = (sourceUrl: string, skill: string | null): string[] => {\n const parsedUrl = new URL(sourceUrl);\n if (isZipUrl(sourceUrl)) return [sourceUrl];\n if (parsedUrl.hostname === 'raw.githubusercontent.com') return [parsedUrl.toString()];\n if (parsedUrl.hostname !== 'github.com') return [sourceUrl];\n\n const rawUrl = toRawGithubUrl(sourceUrl);\n if (rawUrl?.endsWith('/SKILL.md')) return [rawUrl];\n\n const parts = parsedUrl.pathname.split('/').filter(Boolean);\n const [owner, repo, marker, branch, ...treePathParts] = parts;\n const branches = marker === 'tree' && branch ? [branch] : ['main', 'master'];\n const treePath = marker === 'tree' ? treePathParts.join('/') : '';\n const skillSlug = skill ? normalizeSlug(skill) : null;\n const paths = new Set<string>();\n\n if (treePath) paths.add(`${treePath}/SKILL.md`);\n if (!treePath) paths.add('SKILL.md');\n if (skillSlug) {\n paths.add(`skills/${skillSlug}/SKILL.md`);\n paths.add(`.agents/skills/${skillSlug}/SKILL.md`);\n if (treePath) paths.add(`${treePath}/skills/${skillSlug}/SKILL.md`);\n if (treePath) paths.add(`${treePath}/.agents/skills/${skillSlug}/SKILL.md`);\n }\n\n return branches.flatMap((candidateBranch) =>\n [...paths].map((candidatePath) => `https://raw.githubusercontent.com/${owner}/${repo}/${candidateBranch}/${candidatePath}`),\n );\n};\n\nexport const planWizardArtifactImport = (input: {\n artifactKind?: string;\n source: string;\n slug?: string;\n skill?: string;\n}): ImportSourcePlan => {\n const source = input.source.trim();\n const tokens = tokenizeCommandLikeInput(source);\n const optionSkill = parseOptionValue(tokens, '--skill');\n const skill = input.skill?.trim() || optionSkill || null;\n const getdesignSlug = tokens.find((token, index) => tokens[index - 1] === 'add' && !token.startsWith('-')) ?? null;\n const inferredKind: WizardArtifactKind = source.includes('getdesign') ? 'DESIGN_DOC' : 'SKILL';\n const artifactKind = input.artifactKind ? toWizardArtifactKind(input.artifactKind) : inferredKind;\n\n if (artifactKind === 'DESIGN_DOC') {\n const rawSlug = input.slug?.trim() || getdesignSlug;\n if (!rawSlug) throw new Error('DESIGN_DOC import requires a slug or a getdesign `add <slug>` input.');\n const slug = normalizeSlug(rawSlug);\n const directUrl = firstUrlToken(tokens);\n const candidateUrls = directUrl ? [toRawGithubUrl(directUrl) ?? directUrl] : [`${GETDESIGN_RAW_BASE}/${slug}/DESIGN.md`];\n return { artifactKind, slug, skill: null, source, sourceRef: directUrl ?? `getdesign:${slug}`, candidateUrls };\n }\n\n const sourceUrl = firstUrlToken(tokens) ?? source;\n return {\n artifactKind: 'SKILL',\n slug: input.slug ? normalizeSlug(input.slug) : null,\n skill,\n source,\n sourceRef: skill ? `${sourceUrl}#skill=${skill}` : sourceUrl,\n candidateUrls: buildGithubSkillCandidateUrls(sourceUrl, skill),\n };\n};\n\nexport const fetchWizardArtifactImportSource = async (input: {\n artifactKind?: string;\n source: string;\n slug?: string;\n skill?: string;\n signal: AbortSignal;\n}): Promise<ResolvedImportSource> => {\n const plan = planWizardArtifactImport(input);\n const errors: string[] = [];\n\n for (const candidateUrl of plan.candidateUrls) {\n try {\n const response = await fetch(candidateUrl, { signal: input.signal });\n if (!response.ok) {\n errors.push(`${candidateUrl}: HTTP ${response.status}`);\n continue;\n }\n\n if (isZipUrl(candidateUrl)) {\n const zipMarkdown = extractMarkdownFromZip(await response.arrayBuffer());\n return {\n ...plan,\n markdownContent: zipMarkdown.content,\n fetchedUrl: candidateUrl,\n sourceRef: zipSourceRef(plan.sourceRef, zipMarkdown.path),\n };\n }\n\n return { ...plan, markdownContent: await response.text(), fetchedUrl: candidateUrl };\n } catch (error) {\n errors.push(`${candidateUrl}: ${error instanceof Error ? error.message : 'Unknown fetch error'}`);\n }\n }\n\n throw new Error(`Could not fetch import source. Tried: ${errors.join('; ')}`);\n};\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,SAAS,QAAQ,QAAQ;AAiB7C,MAAMC,kBAAkB,GAAG,8EAA8E;AACzG,MAAMC,0BAA0B,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,CAAU;AAE1G,MAAMC,wBAAwB,GAAIC,KAAa,IAAe;EAC5D,MAAMC,MAAM,GAAGD,KAAK,CAACE,KAAK,CAAC,gCAAgC,CAAC,IAAI,EAAE;EAClE,OAAOD,MAAM,CAACE,GAAG,CAAEC,KAAK,IAAKA,KAAK,CAACC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AACnE,CAAC;AAED,MAAMC,aAAa,GAAIC,KAAa,IAAa;EAC/C,OAAOA,KAAK,CACTC,IAAI,CAAC,CAAC,CACNC,WAAW,CAAC,CAAC,CACbJ,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAC3BA,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;AAC5B,CAAC;AAED,MAAMK,gBAAgB,GAAGA,CAACT,MAA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{ CREATE_OR_UPDATE_SKILL_FROM_MARKDOWN_MUTATION, SET_WIZARD_ARTIFACT_PREFERENCE_MUTATION } from '../graphql-operations.js';
|
|
3
|
+
import { CREATE_OR_UPDATE_SKILL_FROM_MARKDOWN_MUTATION, IMPORT_WIZARD_ARTIFACT_SNAPSHOT_MUTATION, SET_WIZARD_ARTIFACT_PREFERENCE_MUTATION } from '../graphql-operations.js';
|
|
4
4
|
import { createPublishedSkillToolDefinitions, resolveAvailableTools } from '../plugin-tools.js';
|
|
5
5
|
import { resolveStoredAuthState, toAuthState, writeAuthState } from './auth-store.js';
|
|
6
6
|
import { resolveConfig } from './config.js';
|
|
@@ -15,6 +15,7 @@ import { CACHE_TTL_MS, LOGIN_TIMEOUT_MS, OIDC_CALLBACK_URL, PLUGIN_ID, PRESENCE_
|
|
|
15
15
|
export { PLUGIN_ID, NATIVE_SKILLS_URL_COMPATIBILITY } from './constants.js';
|
|
16
16
|
import { buildSystemNote, filterIgnoredPublishedSkills, resolvePluginStatusSnapshot, toAiFacingPluginStatusSnapshot, toFetchFailureOutput, toPluginStatusMetadata, toPublishedSkillCatalog } from './status.js';
|
|
17
17
|
import { createIdleLoginBootstrapSnapshot } from './auth-bootstrap.js';
|
|
18
|
+
import { fetchWizardArtifactImportSource, planWizardArtifactImport } from './import-sources.js';
|
|
18
19
|
import { getCatalogCacheKey, resolvePublishedSkillPreferenceCacheContext, setPublishedSkillIgnored, setPublishedSkillInstalled, toPublishedSkillPreferenceAction, toPublishedSkillPreferenceScope } from './preferences.js';
|
|
19
20
|
export { buildSystemNote, resolvePluginStatusSnapshot, toPluginAuthStateSummary, toPublishedSkillCatalog } from './status.js';
|
|
20
21
|
const importOpencodePluginModule = new Function('specifier', 'return import(specifier)');
|
|
@@ -1232,6 +1233,121 @@ export const OpencodeWizardSkillsPlugin = async input => {
|
|
|
1232
1233
|
}
|
|
1233
1234
|
};
|
|
1234
1235
|
};
|
|
1236
|
+
const executeWizardArtifactImportTool = async ({
|
|
1237
|
+
args,
|
|
1238
|
+
context
|
|
1239
|
+
}) => {
|
|
1240
|
+
const authState = await resolveStoredAuthState(input.worktree, config);
|
|
1241
|
+
const importPlan = planWizardArtifactImport({
|
|
1242
|
+
artifactKind: args.artifactKind,
|
|
1243
|
+
source: args.source,
|
|
1244
|
+
slug: args.slug,
|
|
1245
|
+
skill: args.skill
|
|
1246
|
+
});
|
|
1247
|
+
if (!authState || authState.role !== 'EDITOR') {
|
|
1248
|
+
return {
|
|
1249
|
+
output: JSON.stringify({
|
|
1250
|
+
pluginId: PLUGIN_ID,
|
|
1251
|
+
status: 'forbidden',
|
|
1252
|
+
artifactKind: importPlan.artifactKind,
|
|
1253
|
+
source: importPlan.source,
|
|
1254
|
+
message: 'This tool requires EDITOR role. Your current session does not have the required editor permission.'
|
|
1255
|
+
}, null, 2),
|
|
1256
|
+
metadata: {
|
|
1257
|
+
status: 'forbidden',
|
|
1258
|
+
role: authState?.role ?? 'none'
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
const requestedDirectory = normalizeDirectoryArg(context.directory, args.directory);
|
|
1263
|
+
const directoryPath = normalizeRepositoryPath(workspacePath, requestedDirectory);
|
|
1264
|
+
lastInteractiveDirectoryPath = directoryPath;
|
|
1265
|
+
let importSource;
|
|
1266
|
+
try {
|
|
1267
|
+
importSource = await fetchWizardArtifactImportSource({
|
|
1268
|
+
artifactKind: args.artifactKind,
|
|
1269
|
+
source: args.source,
|
|
1270
|
+
slug: args.slug,
|
|
1271
|
+
skill: args.skill,
|
|
1272
|
+
signal: context.abort
|
|
1273
|
+
});
|
|
1274
|
+
} catch (error) {
|
|
1275
|
+
return {
|
|
1276
|
+
output: JSON.stringify({
|
|
1277
|
+
pluginId: PLUGIN_ID,
|
|
1278
|
+
status: 'source_fetch_failed',
|
|
1279
|
+
artifactKind: importPlan.artifactKind,
|
|
1280
|
+
source: importPlan.source,
|
|
1281
|
+
candidateUrls: importPlan.candidateUrls,
|
|
1282
|
+
message: error instanceof Error ? error.message : 'Unknown import source fetch failure.'
|
|
1283
|
+
}, null, 2),
|
|
1284
|
+
metadata: {
|
|
1285
|
+
status: 'source_fetch_failed',
|
|
1286
|
+
artifactKind: importPlan.artifactKind,
|
|
1287
|
+
directoryPath
|
|
1288
|
+
}
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
const response = await fetchPublishedSkillsGraphQl({
|
|
1292
|
+
worktree: input.worktree,
|
|
1293
|
+
config,
|
|
1294
|
+
query: IMPORT_WIZARD_ARTIFACT_SNAPSHOT_MUTATION,
|
|
1295
|
+
variables: {
|
|
1296
|
+
input: {
|
|
1297
|
+
artifactKind: importSource.artifactKind,
|
|
1298
|
+
slug: importSource.slug,
|
|
1299
|
+
name: args.name,
|
|
1300
|
+
summary: args.summary,
|
|
1301
|
+
markdownContent: importSource.markdownContent,
|
|
1302
|
+
source: importSource.fetchedUrl,
|
|
1303
|
+
sourceSnapshotRef: importSource.sourceRef
|
|
1304
|
+
}
|
|
1305
|
+
},
|
|
1306
|
+
signal: context.abort
|
|
1307
|
+
});
|
|
1308
|
+
if (!response.ok) {
|
|
1309
|
+
return {
|
|
1310
|
+
output: JSON.stringify({
|
|
1311
|
+
pluginId: PLUGIN_ID,
|
|
1312
|
+
status: 'request_failed',
|
|
1313
|
+
artifactKind: importSource.artifactKind,
|
|
1314
|
+
source: importSource.source,
|
|
1315
|
+
fetchedUrl: importSource.fetchedUrl,
|
|
1316
|
+
message: response.result.message
|
|
1317
|
+
}, null, 2),
|
|
1318
|
+
metadata: {
|
|
1319
|
+
status: 'request_failed',
|
|
1320
|
+
artifactKind: importSource.artifactKind,
|
|
1321
|
+
directoryPath
|
|
1322
|
+
}
|
|
1323
|
+
};
|
|
1324
|
+
}
|
|
1325
|
+
const payload = response.data.importWizardArtifactSnapshot;
|
|
1326
|
+
await scheduleInteractivePresenceStart();
|
|
1327
|
+
return {
|
|
1328
|
+
output: JSON.stringify({
|
|
1329
|
+
pluginId: PLUGIN_ID,
|
|
1330
|
+
status: payload.success ? 'imported' : 'import_failed',
|
|
1331
|
+
artifactKind: importSource.artifactKind,
|
|
1332
|
+
artifactSlug: payload.artifactSlug,
|
|
1333
|
+
artifactVersionId: payload.artifactVersionId,
|
|
1334
|
+
skillSlug: payload.skillSlug,
|
|
1335
|
+
skillVersionId: payload.skillVersionId,
|
|
1336
|
+
source: importSource.source,
|
|
1337
|
+
fetchedUrl: importSource.fetchedUrl,
|
|
1338
|
+
sourceSnapshotRef: importSource.sourceRef,
|
|
1339
|
+
errors: payload.errors,
|
|
1340
|
+
message: 'Imported backend artifact is now the wizard/plugin runtime authority; no project files were written.'
|
|
1341
|
+
}, null, 2),
|
|
1342
|
+
metadata: {
|
|
1343
|
+
status: payload.success ? 'imported' : 'import_failed',
|
|
1344
|
+
artifactKind: importSource.artifactKind,
|
|
1345
|
+
artifactSlug: payload.artifactSlug ?? '',
|
|
1346
|
+
artifactVersionId: payload.artifactVersionId ?? '',
|
|
1347
|
+
directoryPath
|
|
1348
|
+
}
|
|
1349
|
+
};
|
|
1350
|
+
};
|
|
1235
1351
|
const role = initialAuthState?.role ?? null;
|
|
1236
1352
|
const isEditor = role === 'EDITOR';
|
|
1237
1353
|
const {
|
|
@@ -1265,6 +1381,10 @@ export const OpencodeWizardSkillsPlugin = async input => {
|
|
|
1265
1381
|
publishEditorSkill: (args, context) => executeEditorPublishSkillTool({
|
|
1266
1382
|
args,
|
|
1267
1383
|
context
|
|
1384
|
+
}),
|
|
1385
|
+
importWizardArtifact: (args, context) => executeWizardArtifactImportTool({
|
|
1386
|
+
args,
|
|
1387
|
+
context
|
|
1268
1388
|
})
|
|
1269
1389
|
});
|
|
1270
1390
|
return {
|