跳到主内容
智客 ZICQ

技能库 智客分类:Agent 工作流 extension-core-infrastructure

Extension Core Infrastructure

核心基础设施提供后端连接配置,存储客户端,以及React App入口.

22159 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

核心基础设施提供后端连接配置,存储客户端,以及React App入口.

何时用

官方 description 未单独写出 Use when。按规范,代理会在用户任务与这段 description 的关键词匹配时激活本技能。

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Core Infrastructure、Overview、Requirements、Integration、Frontend、App Entry Point。

文件分析

文件分析:这是一份仅含 SKILL.md 的指令型技能,代理激活后整份正文进入上下文。

官方 description(原文)

Core infrastructure providing backend connection configuration, storage client, and React app entry point.

Core InfrastructureOverviewRequirementsIntegrationFrontendApp Entry Point`useInternetIdentity()` — Authentication HookReturn ValuesAuth State LifecycleUsageSign-in variants: plain II, Google, Microsoft, workspace SSO`useActor()` — Backend Actor Hook

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
extension-core-infrastructure
description
Core infrastructure providing backend connection configuration, storage client, and React app entry point.
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「extension-core-infrastructure」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-d0bd2049a145d0fe-Extension-Core-Infrastructure.html
请存为 .cursor/skills/extension-core-infrastructure/SKILL.md 或 .claude/skills/extension-core-infrastructure/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/caffeinelabs/skills' --list

npx skills add 'https://github.com/caffeinelabs/skills' --skill 'extension-core-infrastructure'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: extension-core-infrastructure description: Core infrastructure providing backend connection configuration, storage client, and React app entry point. version: 1.4.0 compatibility: npm: "@caffeineai/core-infrastructure": "^1.4.0" "@caffeineai/object-storage": "^1.1.0" caffeineai-subscription: [none] --- # Core Infrastructure Core infrastructure extension for [Caffeine AI](https://caffeine.ai?utm_source=caffeine-skill&utm_medium=referral). ## Overview This component provides the foundational infrastructure for all projects: backend connection configuration, Internet Identity authentication hooks, and actor management utilities. ## Requirements ``` "@caffeineai/core-infrastructure": "^1.4.0" "@caffeineai/object-storage": "^1.1.0" "@icp-sdk/auth": "^7.1.0" "@icp-sdk/core": "^5.3.0" ``` `@caffeineai/object-storage` is a peer dependency of core-infrastructure. Every project must install it as a direct npm dependency (the build template includes both packages). ## Integration Core infrastructure is automatically included in every project. No manual integration steps are required. # Frontend The core-infrastructure frontend package (`@caffeineai/core-infrastructure`) is automatically included in every project. ## App Entry Point Wrap the app with `InternetIdentityProvider` and `QueryClientProvider`: ```typescript import { InternetIdentityProvider } from "@caffeineai/core-infrastructure"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import ReactDOM from "react-dom/client"; import App from "./App"; const queryClient = new QueryClient(); ReactDOM.createRoot(document.getElementById("root")!).render( , ); ``` ## `useInternetIdentity()` — Authentication Hook Provides identity state, login, and logout for Internet Identity. ### Return Values | Field | Type | Description | |---|---|---| | `identity` | `Identity \| undefined` | The user's identity (available after login or session restore) | | `login` | `(options?: LoginOptions) => void` | Opens the II popup. Fire-and-forget — do not `await`. See [Sign-in variants](#sign-in-variants-plain-ii-google-microsoft-workspace-sso). | | `clear` | `() => void` | Logs out and clears stored identity. Fire-and-forget. | | `isAuthenticated` | `boolean` | `true` when user has a valid identity. **Use this for UI gating.** | | `isInitializing` | `boolean` | `true` while `AuthClient` is loading from IndexedDB | | `isLoggingIn` | `boolean` | `true` while the II popup is open | | `isLoginSuccess` | `boolean` | `true` only after interactive login (NOT after page reload restore) | | `isLoginError` | `boolean` | `true` if login or initialization failed | | `loginError` | `Error \| undefined` | The error object when `isLoginError` is `true` | ### Auth State Lifecycle | Scenario | `loginStatus` | `isAuthenticated` | |---|---|---| | Page load, no stored session | `"idle"` | `false` | | Restoring stored session | `"initializing"` | `false` → `true` | | Stored session restored after reload | `"idle"` | `true` | | Interactive login in progress | `"logging-in"` | `false` | | Interactive login just completed | `"success"` | `true` | | Login popup failed / cancelled | `"loginError"` | `false` | **IMPORTANT:** `isLoginSuccess` is only `true` after an interactive login via the popup — NOT when a stored identity is restored on page reload. Always use `isAuthenticated` for conditional rendering. ### Usage Gate authenticated UI on `isAuthenticated`: ```typescript const { isAuthenticated } = useInternetIdentity(); {isAuthenticated ? : } ``` Disable the login button while initializing or logging in: ```typescript const { login, isInitializing, isLoggingIn } = useInternetIdentity(); login()} disabled={isInitializing || isLoggingIn}> Sign in ``` `login()` and `clear()` are fire-and-forget — the hook's state fields (`isLoggingIn`, `isInitializing`) track the async lifecycle. Do not wrap them in local `useState` / `isPending` logic. ### Sign-in variants: plain II, Google, Microsoft, workspace SSO `login()` accepts an optional `LoginOptions` object selecting how the user signs in. All variants go through Internet Identity and produce the same identity, session behavior, and logout — they only change which screen the user sees first: ```typescript login(); // Plain Internet Identity sign-in login({ provider: "google" }); // One-click Google sign-in (II opens Google OAuth directly) login({ provider: "microsoft" }); // One-click Microsoft sign-in (II opens Microsoft OAuth directly) login({ ssoDomain: "acme.com" }); // Company/workspace SSO via the domain's identity provider ``` - **Google**: no Google API keys or OAuth client setup is needed — Internet Identity handles the OAuth flow. - **Microsoft**: no Azure/Entra app registration is needed — Internet Identity owns the OAuth client. Accepts both personal Microsoft accounts and work/school accounts. - **Workspace SSO**: the user enters their company domain (e.g. `acme.com`); Internet Identity discovers the company's OpenID Connect provider from `https:///.well-known/ii-openid-configuration` and signs in against it (works with Okta, Entra ID, and other OIDC providers the company has configured). Use this when the app needs a specific company's own tenant; use `provider: "microsoft"` for a one-click Microsoft button that needs no per-company setup. - Apple sign-in is not offered: Internet Identity returns no email or name claims for Apple, so the attribute callback would be empty. - Sessions from all variants are stored the same way: `isAuthenticated`, session restore on reload, and `clear()` behave identically regardless of the variant used. - When the backend uses `caffeineai-authorization`, Google, Microsoft, and SSO sign-ins carry verified name/email attributes (and the SSO domain) to the attribute callback automatically — see the `extension-authorization` skill. **Call `login()` only from a button's `onClick` handler.** The Internet Identity popup can only be opened while a real click event is dispatching; anything else fails with `Signer window should not be opened outside of click handler`. In particular: - Never call `login()` from a form's `onSubmit` — the `submit` event fires *after* the click event has finished, so the check fails. For the SSO domain field, use a plain `
` (not a ``) and a `type="button"` submit button whose `onClick` validates the domain and calls `login({ ssoDomain })` directly. - Never call `login()` from keyboard handlers (e.g. Enter in the domain input) or after an `await` — both run outside the click dispatch. If the app validates the SSO domain before calling `login`, mirror Internet Identity's own rules: accept a normal DNS name with at least two labels (e.g. `acme.com`) **or** a loopback host — `localhost` or `127.0.0.1`, with an optional `:port` (e.g. `localhost:3000`). II accepts loopback domains for local testing, so the input must not reject them. Standard sign-in UI pattern — prominent Google and Microsoft buttons, plain II sign-in, and a "company SSO" option that prompts for a domain: ```typescript function SignInOptions() { const { login, isInitializing, isLoggingIn } = useInternetIdentity(); const [ssoDomain, setSsoDomain] = useState(""); const disabled = isInitializing || isLoggingIn; return (
login({ provider: "google" })} disabled={disabled}> Continue with Google login({ provider: "microsoft" })} disabled={disabled}> Continue with Microsoft login()} disabled={disabled}> Sign in with Internet Identity {/* Company SSO: deliberately not a — login must run inside the button's click event, and form onSubmit fires after the click ends */} setSsoDomain(e.target.value)} placeholder="yourcompany.com" /> login({ ssoDomain: ssoDomain.trim() })} disabled={disabled || !ssoDomain.trim()} > Sign in with your company
); } ``` Only offer the variants the app actually needs: default to plain `login()` unless Google, Microsoft, or company SSO sign-in was requested. When one of them **is** requested, the sign-in page must show the requested direct sign-in option (Google button, Microsoft button, and/or SSO domain input) **and** keep a plain "Sign in with Internet Identity" button as a fallback — users without a Google or Microsoft account or a registered company domain must still be able to sign in. ## `useActor()` — Backend Actor Hook Creates and manages a typed backend actor instance. Automatically re-creates the actor when the user's identity changes (login/logout). ```typescript import { useActor } from "@caffeineai/core-infrastructure"; import { createActor } from "declarations/backend"; function MyComponent() { const { actor, isFetching } = useActor(createActor); // actor is null while loading, then the typed backend actor if (!actor || isFetching) return ; // Call backend methods directly const data = await actor.myBackendMethod(); } ``` ### Return Values | Field | Type | Description | |---|---|---| | `actor` | `T \| null` | The typed backend actor, or `null` while loading | | `isFetching` | `boolean` | `true` while the actor is being created | When the identity changes (login, logout, or session restore), the actor is automatically re-created with the new identity and all dependent queries are invalidated and refetched. ### Mock backend for visual QA (`VITE_USE_MOCK=true`) `useActor` can serve an app-owned mock instead of connecting to a canister. Put the mock at `src/frontend/src/mocks/backend.ts`, exporting `mockBackend`, and pass the glob from **app source**: ```typescript import { useActor } from "@caffeineai/core-infrastructure"; import { createActor } from "declarations/backend"; const mockModules = import.meta.glob("../mocks/backend.{ts,tsx,js,jsx}"); export function useAppActor() { return useActor(createActor, { mockModules }); } ``` The glob has to be written in the app because Vite resolves `import.meta.glob` relative to the file containing the call; the package cannot see the app's `mocks/` directory. Globbing rather than importing keeps the build green when the mock file does not exist. The mock is used only when `VITE_USE_MOCK=true`; otherwise `useActor` behaves exactly as before, and the real backend configuration is loaded. Outside React, `createActorWithConfig(createActor, { mockModules })` accepts the same option, and `loadMockBackendFromModules(mockModules)` resolves the mock on its own.

相关技能

Agent 工作流

Skill Creator

创造有效技能指南。 当用户想创造出新的技能(或更新现有的技能),以专业知识,工作流程,或工具集成来扩展克洛德的能力时,应该使用这种技能.

Agent 工作流

Clawdhub

使用ClawdHub CLI搜索,安装,更新并发布从taladhub.com的代理技能. 需要获取苍蝇上的新技能时使用,将安装的技能同步到最新版本或特定版本,或者发布 npm-instainddhub CLI 的新/更新的技能文件夹.

Agent 工作流

Agent Team Orchestration

管弦乐团多代理团队,任务设定周期,交接协议,审查工作流程. 使用时间: (1)建立2+特派员队伍,具有不同专业,(2)确定任务路线和生命周期(收录框_ spec_建设_审查_完成),(3)在特派员之间制定交接协议,(4)建立审查和质量关口,(5)管理特派员之间的交流和文物共享.

Agent 工作流

Superpowers

Spec-first,TDD,子代理驱动的软件开发工作流程. 当:(1)构建任何新功能或应用——触发脑暴_计划_子代理执行回路,(2)调试出一个bug或测试失败——触发系统性的根起过程,(3)用户说"让我们构建","帮助我计划","我想添加X",或"这个被打破",(4)完成一个功…