@syengup/fridaynext-claude-code-channel 0.0.0-stage → 0.1.0-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
@@ -1,3 +1,47 @@
1
- # Temporary Holding Version
1
+ # FridayNext Claude Code 插件 · Beta 1
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 发行包 `@syengup/fridaynext-claude-code-channel@0.1.0-beta.1` 内置已验证的官方标准插件 `0.1.11`。Claude Code 通过公开 TypeScript SDK 执行,Friday Kit 提供配对、持久队列、恢复和网络服务。
4
+
5
+ ## 环境
6
+
7
+ - 当前验证 macOS、Node.js ≥22.13、Claude Code **2.1.312**,以及包含 Claude Code 模块且兼容插件0.1.11的 Friday iOS 候选。
8
+ - 请先在电脑端完成 Claude Code 登录和模型配置。安装器不安装、更新或降级 Claude Code,不复制模型认证。
9
+ - 内置精确 registry SDK0.3.312、Kit0.2.0-beta.3及运行依赖。无需访问 Friday 私有源码仓库。
10
+
11
+ ## 安装与配对
12
+
13
+ ```sh
14
+ npx -y @syengup/fridaynext-claude-code-channel@0.1.0-beta.1
15
+ ```
16
+
17
+ 默认命令只通过官方插件命令注册并启用用户级插件。代码安装到 `~/.fridaynext/claude-code-plugin`,不启动模型或服务。若固定CLI不在PATH,可先设置 `FN_CLAUDE_BINARY=/绝对路径/claude-2.1.312`。已有其他市场的研发版时会拒绝混装;先正常停止原控制器,按官方命令移除旧来源,再安装,保留原私有数据目录。
18
+
19
+ 在授权项目目录运行:
20
+
21
+ ```sh
22
+ npx -y @syengup/fridaynext-claude-code-channel@0.1.0-beta.1 start
23
+ ```
24
+
25
+ 保持这个终端运行,另开终端生成一次性配对二维码:
26
+
27
+ ```sh
28
+ npx -y @syengup/fridaynext-claude-code-channel@0.1.0-beta.1 pair --qr
29
+ ```
30
+
31
+ 默认仅监听本机。需要手机局域网连接时,在启动前设置 `FN_CLAUDE_LISTEN_HOST=0.0.0.0` 和 `FN_CLAUDE_LAN_ADDRESS=电脑实际私网IPv4`;默认端口9849,可用 `FN_CLAUDE_PORT` 指定。工作目录取启动终端当前项目;更多目录通过 `FN_CLAUDE_WORKSPACE_ROOTS` 的JSON路径数组明确授权。FridayTunnel需要在服务私有根配置既有公网管理,权益、App Attest和宿主授权分别成立。
32
+
33
+ `doctor`检查固定CLI/认证状态,模型可用性另行判断;`status`读取当前服务;`stop`正常等待已有工作结束,保留会话。Ctrl+C同样正常关闭,不把断开连接当作取消模型。
34
+
35
+ ## 数据、重装与回退
36
+
37
+ 插件缓存和稳定安装根只放代码。身份/TLS/配对/账本默认位于 `~/Library/Application Support/FridayNext/ClaudeCode/service`;可用 `FN_CLAUDE_DATA_ROOT`指定独立0700私有根。`FN_CLAUDE_INSTALL_ROOT`只更改代码位置,不能指向数据目录。`CLAUDE_CONFIG_DIR`沿原Claude配置,模型认证留在电脑;手机使用Kit配对凭据。
38
+
39
+ 相同固定版本重复运行安装命令保留服务数据。未来版本或代码摘要不符会保守拒绝覆盖,先正常停止服务,再依对应版本说明升级/回退;不要删除身份/TLS/账本或手工抢owner锁。未知执行保留原请求查询,不换号重跑。官方卸载本版可用 `claude plugin uninstall fridaynext-claude-code@fridaynext-claude-beta --scope user`,它不等于撤销手机或清理服务数据。
40
+
41
+ ## 当前支持与限制
42
+
43
+ 支持SDK自有会话的首答/续聊/历史、真实流式与工具过程、停止/排队、会话设置、审批/多题提问、授权目录/新工作树、图片/普通文件输入输出、子任务及原有Friday辅助功能。图片为PNG/JPEG;输入最多4件、单件2MiB、合计4MiB。音视频、会话迁移、工作树归档/恢复、原生技能/配置管理未纳入本版。
44
+
45
+ **外部已经活动的原生会话尚无满足要求的公开同实例附着接缝。** 本版只控制本集成创建并持有的执行;同UUID resume不是接管原进程。电脑/手机原生控制赢家、部分宿主默认模型/权限持久写入仍有公开接口限制。Beta发行不表示这些条件或完整首发已完成。
46
+
47
+ 请只在愿意授权的工作目录使用,并保留配对资料的私密性。重新出码会使旧券失效,不撤销已配对手机;日志和反馈中不要粘贴认证、内容密钥或配对码。
package/install.mjs ADDED
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { createHash } from 'node:crypto';
7
+ import { execFileSync, spawnSync } from 'node:child_process';
8
+
9
+ const packageRoot = fileURLToPath(new URL('.', import.meta.url));
10
+ const root = path.resolve(process.env.FN_CLAUDE_INSTALL_ROOT ?? path.join(os.homedir(), '.fridaynext/claude-code-plugin'));
11
+ const binary = process.env.FN_CLAUDE_BINARY ?? 'claude';
12
+ const pluginId = 'fridaynext-claude-code@fridaynext-claude-beta';
13
+ const fail = code => { throw Object.assign(new Error(code), { code }); };
14
+ const read = file => JSON.parse(fs.readFileSync(file, 'utf8'));
15
+ const hash = bytes => createHash('sha256').update(bytes).digest('hex');
16
+ const privateRoot = () => {
17
+ const st = fs.lstatSync(root);
18
+ if (!st.isDirectory() || st.isSymbolicLink() || st.uid !== process.getuid() || (st.mode & 0o077)) fail('INSTALL_ROOT_UNSAFE');
19
+ };
20
+ function cli(args, json = true) {
21
+ try {
22
+ const text = execFileSync(binary, args, { encoding: 'utf8', timeout: 120000, maxBuffer: 1048576, stdio: ['ignore', 'pipe', 'pipe'] });
23
+ return json ? JSON.parse(text) : text.trim();
24
+ } catch (error) {
25
+ try {
26
+ const receipt = JSON.parse(error.stdout);
27
+ if (args[0] === 'plugin' && args[1] === 'enable' && receipt.command === 'enable' && receipt.plugin === pluginId
28
+ && receipt.scope === 'user' && receipt.failureCode === 'already_in_goal_state' && receipt.alreadyInGoalState === true) return receipt;
29
+ } catch { /* 未取得官方明确幂等回执时,仍保留失败。 */ }
30
+ throw Object.assign(new Error('CLAUDE_PLUGIN_COMMAND_FAILED'), { code: 'CLAUDE_PLUGIN_COMMAND_FAILED', operation: args.slice(0, 2).join(' ') });
31
+ }
32
+ }
33
+ async function verify(release) {
34
+ const plugin = path.join(root, 'plugin');
35
+ const manifest = read(path.join(plugin, '.claude-plugin/plugin.json'));
36
+ // 与适配器的来源合同核对相同字节;验证前不能加载待验证目录中的程序。
37
+ const files = ['.claude-plugin/plugin.json', '.mcp.json', 'hooks/hooks.json',
38
+ ...fs.readdirSync(path.join(plugin, 'src')).filter(name => name.endsWith('.mjs')).map(name => 'src/' + name)].sort();
39
+ const digest = createHash('sha256');
40
+ for (const file of files) digest.update(file + '\0').update(fs.readFileSync(path.join(plugin, file))).update('\0');
41
+ if (manifest.version !== release.adapterVersion || manifest.name !== 'fridaynext-claude-code' || digest.digest('hex') !== release.sourceDigest) fail('INSTALLED_SOURCE_CHANGED');
42
+ }
43
+ async function install() {
44
+ const release = read(path.join(packageRoot, 'release.json'));
45
+ const dataRoot = path.resolve(process.env.FN_CLAUDE_DATA_ROOT ?? path.join(os.homedir(), 'Library/Application Support/FridayNext/ClaudeCode/service'));
46
+ if (root === dataRoot || root.startsWith(dataRoot + path.sep) || dataRoot.startsWith(root + path.sep)) fail('INSTALL_ROOT_OVERLAPS_STATE');
47
+ if (cli(['--version'], false) !== release.host + ' (Claude Code)') fail('HOST_VERSION_UNSUPPORTED');
48
+ if (hash(fs.readFileSync(path.join(packageRoot, 'plugin.tgz'))) !== release.payloadSHA256) fail('RELEASE_PAYLOAD_CHANGED');
49
+ if (fs.lstatSync(path.dirname(root), { throwIfNoEntry: false })?.isSymbolicLink()) fail('INSTALL_ROOT_UNSAFE');
50
+ if (fs.lstatSync(root, { throwIfNoEntry: false })) {
51
+ privateRoot();
52
+ const old = read(path.join(root, 'release.json'));
53
+ if (old.payloadSHA256 !== release.payloadSHA256 || old.distributionVersion !== release.distributionVersion) fail('INSTALL_VERSION_CONFLICT');
54
+ } else {
55
+ fs.mkdirSync(path.dirname(root), { recursive: true, mode: 0o700 });
56
+ const stage = fs.mkdtempSync(path.join(path.dirname(root), '.claude-install-'));
57
+ try {
58
+ const names = execFileSync('tar', ['-tzf', path.join(packageRoot, 'plugin.tgz')], { encoding: 'utf8', maxBuffer: 8 * 1024 * 1024 }).split('\n').filter(Boolean);
59
+ if (names.some(name => path.isAbsolute(name) || name.split('/').includes('..'))) fail('RELEASE_PATH_UNSAFE');
60
+ execFileSync('tar', ['-xzf', path.join(packageRoot, 'plugin.tgz'), '-C', stage]);
61
+ fs.writeFileSync(path.join(stage, 'release.json'), JSON.stringify(release), { mode: 0o600 });
62
+ fs.renameSync(stage, root);
63
+ } finally { if (fs.existsSync(stage)) fs.rmSync(stage, { recursive: true, force: true }); }
64
+ }
65
+ privateRoot(); await verify(release);
66
+ cli(['plugin', 'validate', path.join(root, 'plugin')], false);
67
+ const markets = cli(['plugin', 'marketplace', 'list', '--json']);
68
+ const market = markets.find(value => value.name === 'fridaynext-claude-beta');
69
+ if (market && path.resolve(market.installLocation) !== root) fail('MARKETPLACE_SOURCE_CONFLICT');
70
+ if (!market) cli(['plugin', 'marketplace', 'add', root, '--scope', 'user', '--json']);
71
+ const plugins = cli(['plugin', 'list', '--json']);
72
+ if (plugins.some(value => value.id.startsWith('fridaynext-claude-code@') && value.id !== pluginId)) fail('PLUGIN_SOURCE_CONFLICT');
73
+ const current = plugins.find(value => value.id === pluginId && value.scope === 'user');
74
+ if (current && current.version !== release.adapterVersion) fail('PLUGIN_VERSION_CONFLICT');
75
+ if (!current) cli(['plugin', 'install', pluginId, '--scope', 'user', '--json']);
76
+ cli(['plugin', 'enable', pluginId, '--scope', 'user', '--json']);
77
+ const receipt = { state: 'installed', distributionVersion: release.distributionVersion, adapterVersion: release.adapterVersion,
78
+ pluginId, codeRoot: root, sourceDigest: release.sourceDigest, serviceStarted: false };
79
+ fs.writeFileSync(path.join(root, 'installed.json'), JSON.stringify(receipt), { mode: 0o600 });
80
+ console.log(JSON.stringify(receipt, null, 2));
81
+ }
82
+ try {
83
+ const [major, minor] = process.versions.node.split('.').map(Number);
84
+ if (major < 22 || major === 22 && minor < 13) fail('NODE_VERSION_UNSUPPORTED');
85
+ const [command = 'install', ...args] = process.argv.slice(2);
86
+ if (command === 'help' || command === '--help') console.log('用法:fridaynext-claude-code-channel [install|start|status|pair --qr|stop|doctor|recover]\n默认只安装并启用官方标准插件;start在当前项目以前台方式运行,另开终端pair --qr。');
87
+ else if (command === 'install') await install();
88
+ else if (['start', 'status', 'pair', 'stop', 'doctor', 'recover'].includes(command)) {
89
+ if (!fs.existsSync(root)) fail('PLUGIN_NOT_INSTALLED'); privateRoot();
90
+ const release = read(path.join(packageRoot, 'release.json')), installed = read(path.join(root, 'release.json'));
91
+ if (installed.payloadSHA256 !== release.payloadSHA256) fail('INSTALL_VERSION_CONFLICT');
92
+ await verify(release);
93
+ const child = spawnSync(process.execPath, [path.join(root, 'plugin/src/cli.mjs'), command, ...args], { stdio: 'inherit', env: process.env });
94
+ process.exitCode = child.status ?? 1;
95
+ } else fail('COMMAND_UNSUPPORTED');
96
+ } catch (error) {
97
+ console.error(JSON.stringify({ code: typeof error.code === 'string' ? error.code : 'CLAUDE_INSTALL_FAILED', operation: error.operation })); process.exitCode = 1;
98
+ }
package/package.json CHANGED
@@ -1,6 +1,24 @@
1
1
  {
2
2
  "name": "@syengup/fridaynext-claude-code-channel",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-beta.1",
4
+ "type": "module",
5
+ "description": "通过Claude Code官方插件命令安装FridayNext,并连接已授权的SDK自有会话",
6
+ "license": "UNLICENSED",
7
+ "engines": {
8
+ "node": ">=22.13.0"
9
+ },
10
+ "bin": {
11
+ "fridaynext-claude-code-channel": "install.mjs"
12
+ },
13
+ "files": [
14
+ "install.mjs",
15
+ "release.json",
16
+ "plugin.tgz",
17
+ "README.md"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public",
21
+ "tag": "beta",
22
+ "registry": "https://registry.npmjs.org/"
23
+ }
24
+ }
package/plugin.tgz ADDED
Binary file
package/release.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 1,
3
+ "distributionVersion": "0.1.0-beta.1",
4
+ "adapterVersion": "0.1.11",
5
+ "host": "2.1.312",
6
+ "sdk": "0.3.312",
7
+ "kit": "0.2.0-beta.3",
8
+ "sourceDigest": "44b4ee99b054c147ef73a5706f23a46f47a306935305f1acd1b4bbbc7dc80862",
9
+ "payloadSHA256": "dc7baf735d6f84894e4cebc81ddf28a9bf355ca9c3538a907a9e660132c90bd4"
10
+ }