@oyasmi/pipiclaw 0.8.7 → 0.8.8-beta.1

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 CHANGED
@@ -51,7 +51,7 @@ pipiclaw
51
51
  程序会创建:
52
52
 
53
53
  ```text
54
- ~/.pi/pipiclaw/
54
+ ~/.pipiclaw/
55
55
  ├── channel.json # 钉钉应用配置
56
56
  ├── auth.json # 模型凭据
57
57
  ├── models.json # 自定义模型提供方
@@ -62,7 +62,7 @@ pipiclaw
62
62
  # events/、skills/、sub-agents/ 及各会话通道目录
63
63
  ```
64
64
 
65
- 默认 app home 是 `~/.pi/pipiclaw/`;设置 `PIPICLAW_HOME=/your/path` 可整体迁移。如果 `channel.json` 仍是初始化模板,程序会提示补全配置后再启动,这是正常行为。
65
+ 默认 app home 是 `~/.pipiclaw/`;设置 `PIPICLAW_HOME=/your/path` 可整体迁移。如果 `channel.json` 仍是初始化模板,程序会提示补全配置后再启动,这是正常行为。
66
66
 
67
67
  ### 4. 创建钉钉应用(Create a DingTalk App)
68
68
 
@@ -75,7 +75,7 @@ pipiclaw
75
75
 
76
76
  ### 5. 填写 `channel.json`(Fill `channel.json`)
77
77
 
78
- 编辑 `~/.pi/pipiclaw/channel.json`:
78
+ 编辑 `~/.pipiclaw/channel.json`:
79
79
 
80
80
  ```json
81
81
  {
@@ -102,7 +102,7 @@ pipiclaw
102
102
  export ANTHROPIC_API_KEY=sk-ant-...
103
103
  ```
104
104
 
105
- 或写入 `~/.pi/pipiclaw/auth.json`:
105
+ 或写入 `~/.pipiclaw/auth.json`:
106
106
 
107
107
  ```json
108
108
  {
@@ -110,7 +110,7 @@ export ANTHROPIC_API_KEY=sk-ant-...
110
110
  }
111
111
  ```
112
112
 
113
- **方案 B:自定义模型提供方。** 适用于 OpenAI-compatible 网关、代理、自建或聚合服务,编辑 `~/.pi/pipiclaw/models.json`:
113
+ **方案 B:自定义模型提供方。** 适用于 OpenAI-compatible 网关、代理、自建或聚合服务,编辑 `~/.pipiclaw/models.json`:
114
114
 
115
115
  ```json
116
116
  {
@@ -135,7 +135,7 @@ export ANTHROPIC_API_KEY=sk-ant-...
135
135
 
136
136
  ### 7. 可选:设置默认模型(Optional: Set a Default Model)
137
137
 
138
- 编辑 `~/.pi/pipiclaw/settings.json`:
138
+ 编辑 `~/.pipiclaw/settings.json`:
139
139
 
140
140
  ```json
141
141
  {
@@ -156,7 +156,7 @@ pipiclaw
156
156
 
157
157
  ### 9. 可选:启用内建 Web 工具(Optional: Enable Web Tools)
158
158
 
159
- `web_search` / `web_fetch` 默认关闭。首次启动生成的 `~/.pi/pipiclaw/tools.json` 已带可直接改用的模板,通常只需三步:
159
+ `web_search` / `web_fetch` 默认关闭。首次启动生成的 `~/.pipiclaw/tools.json` 已带可直接改用的模板,通常只需三步:
160
160
 
161
161
  1. 把 `tools.web.enable` 改成 `true`
162
162
  2. 填入搜索 provider 的 `apiKey`(默认示例为 Brave)
@@ -185,17 +185,17 @@ pipiclaw
185
185
 
186
186
  1. 先检查 Node.js 版本,必须 >= 22.19.0;不满足就停下来告诉我,不要继续安装。
187
187
  2. 执行 npm install -g @oyasmi/pipiclaw。权限失败时不要自行 sudo,把报错给我并询问怎么处理。
188
- 3. 运行一次 pipiclaw,让它初始化 ~/.pi/pipiclaw/ 和 workspace/。
188
+ 3. 运行一次 pipiclaw,让它初始化 ~/.pipiclaw/ 和 workspace/。
189
189
  4. 逐项询问我是否现在提供:钉钉应用的 clientId 和 clientSecret、AI Card 的
190
190
  cardTemplateId、模型接入方式(Anthropic 或自定义 provider)。
191
- 5. 钉钉配置写入 ~/.pi/pipiclaw/channel.json:robotCode 可留空,allowFrom 先设 []。
191
+ 5. 钉钉配置写入 ~/.pipiclaw/channel.json:robotCode 可留空,allowFrom 先设 []。
192
192
  AI Card 是推荐配置;我暂不提供 cardTemplateId 时可先留空,但最后要提醒我补上。
193
193
  最终文件里不要保留任何 your-* 占位值。
194
194
  6. 模型配置:
195
195
  - 我选 Anthropic:询问我是否提供 ANTHROPIC_API_KEY;提供就配置到可用,
196
196
  不提供就保留默认空 models.json,并告诉我之后要补 auth.json 或环境变量。
197
197
  - 我选自定义 provider:至少收集 provider 名称、baseUrl、api 类型、apiKey、
198
- 一个 model id,写入 ~/.pi/pipiclaw/models.json;OpenAI-compatible 服务优先用
198
+ 一个 model id,写入 ~/.pipiclaw/models.json;OpenAI-compatible 服务优先用
199
199
  openai-completions,并默认加 compat:supportsDeveloperRole: false、
200
200
  supportsReasoningEffort: false。
201
201
  - 我不提供的值不要编造。收尾时明确列出还缺什么、该改哪个文件。
@@ -257,7 +257,7 @@ npm run check # lint + typecheck + deadcode + test
257
257
  端到端测试说明:
258
258
 
259
259
  - `npm run test:e2e` 运行"除钉钉渠道外"的完整 E2E:真实 runtime、真实工具/记忆/Sidecar/LLM,只 mock 钉钉传输层。
260
- - 需要可用模型凭据:优先读取 `${PIPICLAW_HOME:-~/.pi/pipiclaw}/auth.json`,否则回退到 `ANTHROPIC_API_KEY`。
260
+ - 需要可用模型凭据:优先读取 `${PIPICLAW_HOME:-~/.pipiclaw}/auth.json`,否则回退到 `ANTHROPIC_API_KEY`。
261
261
  - 默认模型是 `anthropic/claude-sonnet-4-5`;使用其他 provider 时用 `PIPICLAW_E2E_PROVIDER` / `PIPICLAW_E2E_MODEL` 覆盖,例如 `PIPICLAW_E2E_PROVIDER=zpai PIPICLAW_E2E_MODEL=glm-5-turbo npm run test:e2e`。
262
262
  - E2E 不包含在 `npm run test` 中,避免日常测试被真实 LLM 依赖和调用成本影响。
263
263
 
@@ -18,5 +18,5 @@ export async function getApiKeyForModel(modelRegistry, model) {
18
18
  }
19
19
  }
20
20
  throw new Error(`No API key found for provider: ${model.provider}.\n\n` +
21
- "Configure credentials in ~/.pi/pipiclaw/auth.json or ~/.pi/pipiclaw/models.json, or set the matching provider environment variable.");
21
+ "Configure credentials in ~/.pipiclaw/auth.json or ~/.pipiclaw/models.json, or set the matching provider environment variable.");
22
22
  }
package/dist/paths.d.ts CHANGED
@@ -1,6 +1,14 @@
1
1
  export declare const APP_NAME = "pipiclaw";
2
2
  /** Prefer live source docs in a checkout; installed packages fall back to dist/playbooks. */
3
3
  export declare const PLAYBOOKS_DIR: string;
4
+ /**
5
+ * Legacy default app home used before the `~/.pipiclaw` default (introduced in
6
+ * 0.8.x). Kept only so bootstrap can migrate an existing install to the new
7
+ * default. FIXME(0.9.0): drop this together with the migration in bootstrap.ts.
8
+ */
9
+ export declare const LEGACY_APP_HOME_DIR: string;
10
+ /** The built-in default app home, independent of any `PIPICLAW_HOME` override. */
11
+ export declare const DEFAULT_APP_HOME_DIR: string;
4
12
  export declare const APP_HOME_DIR: string;
5
13
  export declare const WORKSPACE_DIR: string;
6
14
  export declare const STATE_DIR: string;
package/dist/paths.js CHANGED
@@ -12,7 +12,15 @@ const bundledPlaybooksDir = fileURLToPath(new URL("./playbooks", import.meta.url
12
12
  const checkoutPlaybooksDir = fileURLToPath(new URL("../src/playbooks", import.meta.url));
13
13
  /** Prefer live source docs in a checkout; installed packages fall back to dist/playbooks. */
14
14
  export const PLAYBOOKS_DIR = existsSync(checkoutPlaybooksDir) ? checkoutPlaybooksDir : bundledPlaybooksDir;
15
- export const APP_HOME_DIR = process.env.PIPICLAW_HOME ?? join(homedir(), ".pi", APP_NAME);
15
+ /**
16
+ * Legacy default app home used before the `~/.pipiclaw` default (introduced in
17
+ * 0.8.x). Kept only so bootstrap can migrate an existing install to the new
18
+ * default. FIXME(0.9.0): drop this together with the migration in bootstrap.ts.
19
+ */
20
+ export const LEGACY_APP_HOME_DIR = join(homedir(), ".pi", APP_NAME);
21
+ /** The built-in default app home, independent of any `PIPICLAW_HOME` override. */
22
+ export const DEFAULT_APP_HOME_DIR = join(homedir(), `.${APP_NAME}`);
23
+ export const APP_HOME_DIR = process.env.PIPICLAW_HOME ?? DEFAULT_APP_HOME_DIR;
16
24
  export const WORKSPACE_DIR = join(APP_HOME_DIR, "workspace");
17
25
  export const STATE_DIR = join(APP_HOME_DIR, "state");
18
26
  export const EVENT_STATE_DIR = join(STATE_DIR, "events");
@@ -46,7 +46,8 @@ export declare class BootstrapExitError extends Error {
46
46
  }
47
47
  export declare function isBootstrapExitError(error: unknown): error is BootstrapExitError;
48
48
  export declare function readCliVersion(): string;
49
- export declare function bootstrapAppHome(paths?: BootstrapPaths): BootstrapResult;
49
+ export declare function migrateLegacyAppHome(targetDir: string, legacyDir: string, io: BootstrapIO): boolean;
50
+ export declare function bootstrapAppHome(paths?: BootstrapPaths, io?: BootstrapIO): BootstrapResult;
50
51
  export declare function printBootstrapSummary(result: BootstrapResult, io?: BootstrapIO, paths?: BootstrapPaths): void;
51
52
  export declare function loadConfig(paths?: BootstrapPaths, io?: BootstrapIO): DingTalkConfig;
52
53
  export declare function parseArgs(argv: string[], paths?: BootstrapPaths, io?: BootstrapIO): void;
@@ -1,4 +1,4 @@
1
- import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "fs";
1
+ import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "fs";
2
2
  import { join } from "path";
3
3
  import { formatUnknownCommandMessage, isRunnerBuiltInCommand, parseBuiltInCommand, slashCommandName, } from "../agent/commands.js";
4
4
  import { getOrCreateRunner } from "../agent/index.js";
@@ -9,7 +9,7 @@ import { createExecutor } from "../executor.js";
9
9
  import * as log from "../log.js";
10
10
  import { ensureChannelMemoryFilesSync } from "../memory/files.js";
11
11
  import { MemoryMaintenanceScheduler } from "../memory/scheduler.js";
12
- import { APP_HOME_DIR, APP_NAME, AUTH_CONFIG_PATH, CHANNEL_CONFIG_PATH, EVENT_HISTORY_PATH, MODELS_CONFIG_PATH, SECURITY_CONFIG_PATH, SETTINGS_CONFIG_PATH, TOOLS_CONFIG_PATH, WORKSPACE_DIR, } from "../paths.js";
12
+ import { APP_HOME_DIR, APP_NAME, AUTH_CONFIG_PATH, CHANNEL_CONFIG_PATH, DEFAULT_APP_HOME_DIR, EVENT_HISTORY_PATH, LEGACY_APP_HOME_DIR, MODELS_CONFIG_PATH, SECURITY_CONFIG_PATH, SETTINGS_CONFIG_PATH, TOOLS_CONFIG_PATH, WORKSPACE_DIR, } from "../paths.js";
13
13
  import { loadSecurityConfigWithDiagnostics } from "../security/config.js";
14
14
  import { flushSecurityLogs } from "../security/logger.js";
15
15
  import { PipiclawSettingsManager } from "../settings.js";
@@ -185,8 +185,33 @@ function hardenExistingSecretFile(path) {
185
185
  log.logWarning(`Failed to tighten permissions on ${path}`, errorMessage(err));
186
186
  }
187
187
  }
188
- export function bootstrapAppHome(paths = DEFAULT_BOOTSTRAP_PATHS) {
188
+ // FIXME(0.9.0): remove this legacy-home migration (and LEGACY_APP_HOME_DIR).
189
+ // The default app home moved from `~/.pi/pipiclaw` to `~/.pipiclaw`. When the
190
+ // new default location is not yet present but a legacy install is, move the old
191
+ // directory over so existing users keep their config/workspace/state with no
192
+ // manual step. Exported for direct testing; the env-gating (only for the real
193
+ // default home, never a custom PIPICLAW_HOME) lives at the call site.
194
+ export function migrateLegacyAppHome(targetDir, legacyDir, io) {
195
+ if (existsSync(targetDir) || !existsSync(legacyDir)) {
196
+ return false;
197
+ }
198
+ try {
199
+ renameSync(legacyDir, targetDir);
200
+ io.log(`Migrated existing data from ${legacyDir} to ${targetDir}.`);
201
+ return true;
202
+ }
203
+ catch (err) {
204
+ io.error(`Failed to migrate ${legacyDir} to ${targetDir}: ${errorMessage(err)}`);
205
+ io.error(`Move it manually, or set PIPICLAW_HOME=${legacyDir} to keep using the old location.`);
206
+ throw new BootstrapExitError(1);
207
+ }
208
+ }
209
+ export function bootstrapAppHome(paths = DEFAULT_BOOTSTRAP_PATHS, io = console) {
189
210
  const created = [];
211
+ // FIXME(0.9.0): remove alongside migrateLegacyAppHome.
212
+ if (paths.appHomeDir === DEFAULT_APP_HOME_DIR) {
213
+ migrateLegacyAppHome(paths.appHomeDir, LEGACY_APP_HOME_DIR, io);
214
+ }
190
215
  if (!existsSync(paths.appHomeDir)) {
191
216
  mkdirSync(paths.appHomeDir, { recursive: true });
192
217
  created.push("app home");
@@ -818,7 +843,7 @@ export async function bootstrap(argv, options = {}) {
818
843
  const registerSignalHandlers = options.registerSignalHandlers ?? true;
819
844
  const startServices = options.startServices ?? true;
820
845
  parseArgs(argv, paths, io);
821
- const bootstrapResult = bootstrapAppHome(paths);
846
+ const bootstrapResult = bootstrapAppHome(paths, io);
822
847
  printBootstrapSummary(bootstrapResult, io, paths);
823
848
  if (bootstrapResult.channelTemplateCreated) {
824
849
  io.error(`Fill in ${paths.channelConfigPath} and run \`${paths.appName}\` again.`);
package/dist/tui/app.js CHANGED
@@ -68,7 +68,7 @@ export async function runTuiApp(options) {
68
68
  // Transport-neutral init. Unlike the DingTalk path, the TUI ignores
69
69
  // channelTemplateCreated (it needs no channel.json) and shares app services
70
70
  // (settings, diagnostics) with bootstrap via prepareAppServices.
71
- printBootstrapSummary(bootstrapAppHome(paths), io, paths);
71
+ printBootstrapSummary(bootstrapAppHome(paths, io), io, paths);
72
72
  const { settingsManager } = prepareAppServices(paths);
73
73
  log.configureLogging(settingsManager.getLoggingSettings());
74
74
  log.logStartup(paths.workspaceDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oyasmi/pipiclaw",
3
- "version": "0.8.7",
3
+ "version": "0.8.8-beta.1",
4
4
  "description": "An AI assistant runtime for coding and team workflows, with DingTalk AI Cards, sub-agents, memory, and scheduled events.",
5
5
  "type": "module",
6
6
  "bin": {