secondme-init

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

SecondMe 项目初始化

SecondMe Project Initialization

初始化 SecondMe 项目配置,支持直接解析 App Info 格式或手动输入凭证。
工具使用: 收集用户输入时使用
AskUserQuestion
工具。

Initialize SecondMe project configuration, supporting direct parsing of App Info format or manual credential input.
Tool Usage: Use the
AskUserQuestion
tool when collecting user input.

工作流程

Workflow

第零步:环境检查

Step 0: Environment Check

重要提醒: 当前目录将作为项目根目录,Next.js 项目会直接在此目录中初始化。
  1. 显示当前工作目录路径,让用户确认:
    📂 当前工作目录: /path/to/current/dir
    
    ⚠️  Next.js 项目将直接在此目录中初始化,请确保你已在一个新建的空文件夹中运行。
  2. 检查当前目录内容(除
    .secondme/
    .git/
    CLAUDE.md
    .claude/
    等配置文件外):
    • 如果目录为空或仅有配置文件:继续到下一步
    • 如果存在其他文件:发出警告
      ⚠️  当前目录不为空,包含以下文件/文件夹:
      - src/
      - package.json
      - ...
      
      继续操作可能会覆盖现有文件。是否确认继续?
    • 使用
      AskUserQuestion
      让用户确认是否继续

Important Reminder: The current directory will be used as the project root directory, and the Next.js project will be initialized directly here.
  1. Display the current working directory path for user confirmation:
    📂 Current Working Directory: /path/to/current/dir
    
    ⚠️  The Next.js project will be initialized directly in this directory. Please ensure you are running this in a new empty folder.
  2. Check the contents of the current directory (excluding configuration files like
    .secondme/
    ,
    .git/
    ,
    CLAUDE.md
    ,
    .claude/
    ):
    • If the directory is empty or only contains configuration files: Proceed to the next step
    • If other files exist: Issue a warning
      ⚠️  The current directory is not empty and contains the following files/folders:
      - src/
      - package.json
      - ...
      
      Continuing may overwrite existing files. Are you sure you want to proceed?
    • Use
      AskUserQuestion
      to let the user confirm whether to continue

第一步:检查现有配置

Step 1: Check Existing Configuration

首先检查项目根目录是否存在
.secondme/state.json
如果存在
  1. 读取并显示当前配置摘要:
    📋 已有配置:
    - App Name: secondme-tinder
    - Client ID: 71658da7-***
    - 数据库: postgresql://***
    - 已选模块: auth, chat, profile
    - 当前阶段: init
  2. 询问用户是否要修改配置或继续使用
如果不存在:继续到第二步

First, check if
.secondme/state.json
exists in the project root directory:
If it exists:
  1. Read and display a summary of the current configuration:
    📋 Existing Configuration:
    - App Name: secondme-tinder
    - Client ID: 71658da7-***
    - Database: postgresql://***
    - Selected Modules: auth, chat, profile
    - Current Stage: init
  2. Ask the user whether to modify the configuration or continue using it
If it does not exist: Proceed to Step 2

第二步:收集配置信息

Step 2: Collect Configuration Information

首先询问用户是否已有 SecondMe 应用的 Client ID 和 Client Secret。
如果用户没有凭证,引导用户前往开发者平台注册:
📌 你还没有 SecondMe 应用凭证?请按以下步骤获取:

1. 访问 SecondMe 开发者平台:https://develop.second.me
2. 注册并登录账号
3. 创建一个新的 App
4. 创建完成后,你会获得 App Info(包含 Client ID、Client Secret 等信息)
5. 将 App Info 复制粘贴到这里即可
提示用户获取到凭证后再继续。如果用户已有凭证,继续以下流程。

First, ask the user if they already have the Client ID and Client Secret for the SecondMe application.
If the user does not have credentials, guide them to register on the developer platform:
📌 Don't have SecondMe application credentials yet? Follow these steps to obtain them:

1. Visit the SecondMe Developer Platform: https://develop.second.me
2. Register and log in to your account
3. Create a new App
4. After creation, you will get App Info (including Client ID, Client Secret, etc.)
5. Copy and paste the App Info here
Prompt the user to continue after obtaining the credentials. If the user already has credentials, proceed with the following process.

方式一:解析 App Info 格式(推荐)

Method 1: Parse App Info Format (Recommended)

如果用户提供了以下格式的信息,自动解析:
undefined
If the user provides information in the following format, parse it automatically:
undefined

App Info

App Info


**解析规则**:

| 字段 | 提取方式 |
|------|----------|
| `app_name` | 直接提取 App Name |
| `client_id` | 直接提取 Client ID |
| `client_secret` | 直接提取 Client Secret |
| `redirect_uri` | 优先选择 `localhost:3000` 的 URI(开发用) |
| `redirect_uris` | 保存所有 Redirect URIs 列表 |
| `modules` | 根据 Allowed Scopes 自动推断(见下表) |

**Scopes 到模块的映射**:

| Scope | 模块 |
|-------|------|
| `user.info` | `auth`(必选) |
| `user.info.shades` | `profile` |
| `user.info.softmemory` | `profile` |
| `chat` | `chat` |
| `chat` | `act` |
| `note.add` | `note` |
| `voice` | 记录但暂不生成代码 |

**解析后只需额外收集**:
- **Database URL**(必填)

**Parsing Rules**:

| Field | Extraction Method |
|------|----------|
| `app_name` | Directly extract App Name |
| `client_id` | Directly extract Client ID |
| `client_secret` | Directly extract Client Secret |
| `redirect_uri` | Prioritize the URI with `localhost:3000` (for development) |
| `redirect_uris` | Save all Redirect URIs in a list |
| `modules` | Automatically infer based on Allowed Scopes (see the table below) |

**Scopes to Modules Mapping**:

| Scope | Module |
|-------|------|
| `user.info` | `auth` (Required) |
| `user.info.shades` | `profile` |
| `user.info.softmemory` | `profile` |
| `chat` | `chat` |
| `chat` | `act` |
| `note.add` | `note` |
| `voice` | Record but do not generate code temporarily |

**Additional Information to Collect After Parsing**:
- **Database URL** (Required)

方式二:手动输入

Method 2: Manual Input

如果用户没有提供 App Info,则依次收集:
  1. App Name (可选)
    • 提示:请输入应用名称
    • 默认值:
      secondme-app
  2. Client ID (必填)
    • 提示:请输入 SecondMe 应用的 Client ID
    • 如果用户没有,提示:请前往 https://develop.second.me 注册并创建 App 获取
    • 验证:非空
  3. Client Secret (必填)
    • 提示:请输入 SecondMe 应用的 Client Secret
    • 如果用户没有,提示:请前往 https://develop.second.me 注册并创建 App 获取
    • 验证:非空
  4. Redirect URI (可选)
    • 提示:请输入回调地址
    • 默认值:
      http://localhost:3000/api/auth/callback
  5. Database URL (必填)
    • 提示:请输入数据库连接串
    • 提供格式示例:
      • PostgreSQL:
        postgresql://user:pass@localhost:5432/dbname
      • MySQL:
        mysql://user:pass@localhost:3306/dbname
      • SQLite:
        file:./dev.db
  6. 功能模块选择(多选)

If the user does not provide App Info, collect the following information in order:
  1. App Name (Optional)
    • Prompt: Please enter the application name
    • Default value:
      secondme-app
  2. Client ID (Required)
    • Prompt: Please enter the Client ID of your SecondMe application
    • If the user does not have one, prompt: Please register and create an App at https://develop.second.me to obtain it
    • Validation: Non-empty
  3. Client Secret (Required)
    • Prompt: Please enter the Client Secret of your SecondMe application
    • If the user does not have one, prompt: Please register and create an App at https://develop.second.me to obtain it
    • Validation: Non-empty
  4. Redirect URI (Optional)
    • Prompt: Please enter the callback URL
    • Default value:
      http://localhost:3000/api/auth/callback
  5. Database URL (Required)
    • Prompt: Please enter the database connection string
    • Provide format examples:
      • PostgreSQL:
        postgresql://user:pass@localhost:5432/dbname
      • MySQL:
        mysql://user:pass@localhost:3306/dbname
      • SQLite:
        file:./dev.db
  6. Feature Module Selection (Multiple Selection)

第三步:确认模块选择

Step 3: Confirm Module Selection

展示根据 Scopes 推断的模块(或用户选择的模块):
模块说明备注
auth
OAuth 认证必选,自动包含
profile
用户信息展示可选
chat
聊天功能可选
act
结构化动作判断(返回 JSON)可选,权限复用
chat
scope
note
笔记功能可选
询问用户是否需要调整模块选择。

Display the modules inferred from Scopes (or selected by the user):
ModuleDescriptionNotes
auth
OAuth AuthenticationRequired, automatically included
profile
User Information DisplayOptional
chat
Chat FunctionalityOptional
act
Structured Action Judgment (Returns JSON)Optional, reuses
chat
scope permissions
note
Note-taking FunctionalityOptional
Ask the user if they need to adjust the module selection.

第四步:生成配置文件

Step 4: Generate Configuration Files

4.1 创建
.secondme/state.json

4.1 Create
.secondme/state.json

json
{
  "version": "1.0",
  "stage": "init",
  "app_name": "secondme-tinder",
  "modules": ["auth", "chat", "profile"],
  "config": {
    "client_id": "71658da7-659c-414a-abdf-cb6472037fc2",
    "client_secret": "用户输入的 Client Secret",
    "redirect_uri": "http://localhost:3000/api/auth/callback",
    "redirect_uris": [
      "http://localhost:3000/api/auth/callback",
      "https://xxx.vercel.app/api/auth/callback"
    ],
    "database_url": "用户输入的数据库连接串",
    "allowed_scopes": ["user.info", "user.info.shades", "chat", "note.add"]
  },
  "api": {
    "base_url": "https://app.mindos.com/gate/lab",
    "oauth_url": "https://go.second.me/oauth/",
    "token_endpoint": "https://app.mindos.com/gate/lab/api/oauth/token",
    "access_token_ttl": 7200,
    "refresh_token_ttl": 2592000
  },
  "docs": {
    "quickstart": "https://develop-docs.second.me/zh/docs",
    "oauth2": "https://develop-docs.second.me/zh/docs/authentication/oauth2",
    "api_reference": "https://develop-docs.second.me/zh/docs/api-reference/secondme",
    "errors": "https://develop-docs.second.me/zh/docs/errors"
  },
  "prd": {}
}
json
{
  "version": "1.0",
  "stage": "init",
  "app_name": "secondme-tinder",
  "modules": ["auth", "chat", "profile"],
  "config": {
    "client_id": "71658da7-659c-414a-abdf-cb6472037fc2",
    "client_secret": "User-provided Client Secret",
    "redirect_uri": "http://localhost:3000/api/auth/callback",
    "redirect_uris": [
      "http://localhost:3000/api/auth/callback",
      "https://xxx.vercel.app/api/auth/callback"
    ],
    "database_url": "User-provided database connection string",
    "allowed_scopes": ["user.info", "user.info.shades", "chat", "note.add"]
  },
  "api": {
    "base_url": "https://app.mindos.com/gate/lab",
    "oauth_url": "https://go.second.me/oauth/",
    "token_endpoint": "https://app.mindos.com/gate/lab/api/oauth/token",
    "access_token_ttl": 7200,
    "refresh_token_ttl": 2592000
  },
  "docs": {
    "quickstart": "https://develop-docs.second.me/zh/docs",
    "oauth2": "https://develop-docs.second.me/zh/docs/authentication/oauth2",
    "api_reference": "https://develop-docs.second.me/zh/docs/api-reference/secondme",
    "errors": "https://develop-docs.second.me/zh/docs/errors"
  },
  "prd": {}
}

4.2 创建或更新
CLAUDE.md

4.2 Create or Update
CLAUDE.md

在项目根目录创建
CLAUDE.md
,内容如下:
markdown
undefined
Create
CLAUDE.md
in the project root directory with the following content:
markdown
undefined

SecondMe 集成项目

SecondMe Integration Project

应用信息

Application Information

  • App Name: [app_name]
  • Client ID: [client_id 部分隐藏]
  • App Name: [app_name]
  • Client ID: [Partially hidden client_id]

API 文档

API Documentation

开发时请参考官方文档(从
.secondme/state.json
docs
字段读取):
文档配置键
快速入门
docs.quickstart
OAuth2 认证
docs.oauth2
API 参考
docs.api_reference
错误码
docs.errors
Refer to the official documentation during development (read from the
docs
field in
.secondme/state.json
):
DocumentConfiguration Key
Quick Start
docs.quickstart
OAuth2 Authentication
docs.oauth2
API Reference
docs.api_reference
Error Codes
docs.errors

关键信息

Key Information

  • API 基础 URL: [从 state.json api.base_url 读取]
  • OAuth 授权 URL: [从 state.json api.oauth_url 读取]
  • Access Token 有效期: 2 小时
  • Refresh Token 有效期: 30 天
所有 API 端点配置请参考
.secondme/state.json
中的
api
docs
字段
  • API Base URL: [Read from state.json api.base_url]
  • OAuth Authorization URL: [Read from state.json api.oauth_url]
  • Access Token Expiry: 2 hours
  • Refresh Token Expiry: 30 days
All API endpoint configurations can be found in the
api
and
docs
fields of
.secondme/state.json

已选模块

Selected Modules

[根据推断/选择动态生成模块列表]
[Dynamically generate module list based on inference/selection]

权限列表 (Scopes)

Permission List (Scopes)

根据 App Info 中的 Allowed Scopes:
权限说明状态
user.info
用户基础信息✅ 已授权
user.info.shades
用户兴趣标签✅ 已授权
chat
聊天功能✅ 已授权
note.add
添加笔记✅ 已授权

---
Based on Allowed Scopes in App Info:
PermissionDescriptionStatus
user.info
Basic user information✅ Authorized
user.info.shades
User interest tags✅ Authorized
chat
Chat functionality✅ Authorized
note.add
Add notes✅ Authorized

---

第五步:输出结果

Step 5: Output Results

显示成功信息和下一步操作:
✅ SecondMe 项目配置已完成!

应用名称: secondme-tinder
已保存配置到 .secondme/state.json
已创建/更新 CLAUDE.md(包含 SecondMe API 文档链接)

已选择模块(根据 Allowed Scopes 推断):
- auth ✓
- profile ✓ (user.info.shades)
- chat ✓
- note ✓

⚠️  重要:请将 .secondme/ 添加到 .gitignore 以保护敏感信息

下一步:
- 运行 /secondme-prd 定义产品需求(推荐)
- 或运行 /secondme-nextjs --quick 快速生成项目

Display success message and next steps:
✅ SecondMe project configuration is complete!

Application Name: secondme-tinder
Configuration saved to .secondme/state.json
Created/updated CLAUDE.md (contains SecondMe API documentation links)

Selected Modules (Inferred from Allowed Scopes):
- auth ✓
- profile ✓ (user.info.shades)
- chat ✓
- note ✓

⚠️  Important: Add .secondme/ to .gitignore to protect sensitive information

Next Steps:
- Run /secondme-prd to define product requirements (Recommended)
- Or run /secondme-nextjs --quick to quickly generate the project

输出文件

Output Files

文件说明
.secondme/state.json
项目状态和配置
CLAUDE.md
API 参考文档,供开发时查阅

FileDescription
.secondme/state.json
Project state and configuration
CLAUDE.md
API reference documentation for development reference

App Info 格式示例

App Info Format Example

以下是完整的 App Info 格式,用户可以直接从 SecondMe 开发者后台复制:
undefined
The following is the complete App Info format, which users can copy directly from the SecondMe Developer Backend:
undefined

App Info

App Info


---

---

错误处理

Error Handling

  • App Info 格式无法解析:提示格式错误,切换到手动输入模式
  • Client Secret 为占位符:提示用户填写实际的 Secret
  • 数据库连接串格式错误:显示正确格式示例
  • 权限不足无法创建目录:提示检查目录权限
  • App Info format cannot be parsed: Prompt format error and switch to manual input mode
  • Client Secret is a placeholder: Prompt user to fill in the actual Secret
  • Database connection string format error: Display correct format examples
  • Insufficient permissions to create directory: Prompt to check directory permissions