wangchuan 2.5.1 → 2.7.0
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/.wangchuan/config.example.json +85 -8
- package/dist/bin/wangchuan.d.ts +1 -1
- package/dist/bin/wangchuan.js +34 -4
- package/dist/bin/wangchuan.js.map +1 -1
- package/dist/src/commands/env.d.ts +11 -0
- package/dist/src/commands/env.d.ts.map +1 -0
- package/dist/src/commands/env.js +133 -0
- package/dist/src/commands/env.js.map +1 -0
- package/dist/src/commands/list.d.ts.map +1 -1
- package/dist/src/commands/list.js +5 -1
- package/dist/src/commands/list.js.map +1 -1
- package/dist/src/commands/pull.d.ts.map +1 -1
- package/dist/src/commands/pull.js +2 -1
- package/dist/src/commands/pull.js.map +1 -1
- package/dist/src/commands/push.d.ts +1 -1
- package/dist/src/commands/push.d.ts.map +1 -1
- package/dist/src/commands/push.js +25 -2
- package/dist/src/commands/push.js.map +1 -1
- package/dist/src/commands/status.d.ts.map +1 -1
- package/dist/src/commands/status.js +3 -1
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/sync.d.ts +18 -0
- package/dist/src/commands/sync.d.ts.map +1 -0
- package/dist/src/commands/sync.js +150 -0
- package/dist/src/commands/sync.js.map +1 -0
- package/dist/src/commands/watch.d.ts +10 -0
- package/dist/src/commands/watch.d.ts.map +1 -0
- package/dist/src/commands/watch.js +122 -0
- package/dist/src/commands/watch.js.map +1 -0
- package/dist/src/core/config.d.ts +7 -1
- package/dist/src/core/config.d.ts.map +1 -1
- package/dist/src/core/config.js +110 -8
- package/dist/src/core/config.js.map +1 -1
- package/dist/src/core/git.d.ts +11 -0
- package/dist/src/core/git.d.ts.map +1 -1
- package/dist/src/core/git.js +88 -0
- package/dist/src/core/git.js.map +1 -1
- package/dist/src/core/migrate.d.ts.map +1 -1
- package/dist/src/core/migrate.js +1 -0
- package/dist/src/core/migrate.js.map +1 -1
- package/dist/src/core/sync.d.ts +9 -0
- package/dist/src/core/sync.d.ts.map +1 -1
- package/dist/src/core/sync.js +38 -1
- package/dist/src/core/sync.js.map +1 -1
- package/dist/src/i18n.d.ts.map +1 -1
- package/dist/src/i18n.js +81 -2
- package/dist/src/i18n.js.map +1 -1
- package/dist/src/types.d.ts +20 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +3 -1
- package/dist/src/types.js.map +1 -1
- package/dist/test/sync.test.js +72 -4
- package/dist/test/sync.test.js.map +1 -1
- package/package.json +1 -1
- package/skill/SKILL.md +21 -3
- package/skill/claude/SKILL.md +113 -0
- package/skill/wangchuan-skill.sh +2 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sync.ts — wangchuan sync command (bidirectional smart sync)
|
|
3
|
+
*
|
|
4
|
+
* 1. Fetch remote to check for new commits
|
|
5
|
+
* 2. If remote is ahead, pull first
|
|
6
|
+
* 3. Then push local changes
|
|
7
|
+
*/
|
|
8
|
+
import type { SyncOptions, RestoreResult, StageResult, CommitResult } from '../types.js';
|
|
9
|
+
export interface SyncCommandResult {
|
|
10
|
+
readonly pulled: boolean;
|
|
11
|
+
readonly pullResult?: RestoreResult | undefined;
|
|
12
|
+
readonly pushed: boolean;
|
|
13
|
+
readonly pushResult?: (CommitResult & {
|
|
14
|
+
readonly stageResult?: StageResult | undefined;
|
|
15
|
+
}) | undefined;
|
|
16
|
+
}
|
|
17
|
+
export declare function cmdSync({ agent, dryRun }?: SyncOptions): Promise<SyncCommandResult>;
|
|
18
|
+
//# sourceMappingURL=sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/commands/sync.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIzF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAChD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,YAAY,GAAG;QAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;KAAE,CAAC,GAAG,SAAS,CAAC;CACvG;AAED,wBAAsB,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAE,WAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAgI7F"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sync.ts — wangchuan sync command (bidirectional smart sync)
|
|
3
|
+
*
|
|
4
|
+
* 1. Fetch remote to check for new commits
|
|
5
|
+
* 2. If remote is ahead, pull first
|
|
6
|
+
* 3. Then push local changes
|
|
7
|
+
*/
|
|
8
|
+
import os from 'os';
|
|
9
|
+
import { config } from '../core/config.js';
|
|
10
|
+
import { resolveGitBranch } from '../core/config.js';
|
|
11
|
+
import { ensureMigrated } from '../core/migrate.js';
|
|
12
|
+
import { gitEngine } from '../core/git.js';
|
|
13
|
+
import { syncEngine } from '../core/sync.js';
|
|
14
|
+
import { validator } from '../utils/validator.js';
|
|
15
|
+
import { logger } from '../utils/logger.js';
|
|
16
|
+
import { t } from '../i18n.js';
|
|
17
|
+
import chalk from 'chalk';
|
|
18
|
+
import ora from 'ora';
|
|
19
|
+
export async function cmdSync({ agent, dryRun } = {}) {
|
|
20
|
+
logger.banner(t('sync.banner'));
|
|
21
|
+
let cfg = config.load();
|
|
22
|
+
validator.requireInit(cfg);
|
|
23
|
+
cfg = ensureMigrated(cfg);
|
|
24
|
+
const repoPath = syncEngine.expandHome(cfg.localRepoPath);
|
|
25
|
+
const hostname = cfg.hostname || os.hostname();
|
|
26
|
+
if (agent)
|
|
27
|
+
logger.info(t('sync.filterAgent', { agent: chalk.cyan(agent) }));
|
|
28
|
+
if (dryRun)
|
|
29
|
+
logger.info(chalk.yellow(t('dryRun.enabled')));
|
|
30
|
+
// ── 1. Fetch and check remote ───────────────────────────────
|
|
31
|
+
let spinner = ora(t('sync.fetching')).start();
|
|
32
|
+
let remoteAhead = 0;
|
|
33
|
+
try {
|
|
34
|
+
remoteAhead = await gitEngine.fetchAndCheckRemoteAhead(repoPath, resolveGitBranch(cfg));
|
|
35
|
+
if (remoteAhead > 0) {
|
|
36
|
+
spinner.succeed(t('sync.remoteAhead', { count: remoteAhead }));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
spinner.succeed(t('sync.remoteUpToDate'));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
spinner.fail(t('sync.fetchFailed'));
|
|
44
|
+
throw new Error(t('sync.fetchFailedDetail', { error: err.message }));
|
|
45
|
+
}
|
|
46
|
+
// ── 2. Pull if remote has new commits ───────────────────────
|
|
47
|
+
let pulled = false;
|
|
48
|
+
let pullResult;
|
|
49
|
+
if (remoteAhead > 0) {
|
|
50
|
+
spinner = ora(t('sync.pulling')).start();
|
|
51
|
+
try {
|
|
52
|
+
await gitEngine.pull(repoPath, resolveGitBranch(cfg));
|
|
53
|
+
spinner.succeed(t('sync.pulled'));
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
spinner.fail(t('sync.pullFailed'));
|
|
57
|
+
throw new Error(t('sync.pullFailedDetail', { error: err.message }));
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
pullResult = await syncEngine.restoreFromRepo(cfg, agent);
|
|
61
|
+
pulled = true;
|
|
62
|
+
if (pullResult.synced.length > 0) {
|
|
63
|
+
logger.ok(t('sync.pullSummary', {
|
|
64
|
+
count: pullResult.synced.length,
|
|
65
|
+
encrypted: pullResult.decrypted.length,
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
throw new Error(t('sync.restoreFailed', { error: err.message }));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// ── 3. Push local changes ──────────────────────────────────
|
|
74
|
+
spinner = ora(t('sync.staging')).start();
|
|
75
|
+
let stageResult;
|
|
76
|
+
try {
|
|
77
|
+
stageResult = await syncEngine.stageToRepo(cfg, agent);
|
|
78
|
+
spinner.succeed(t('sync.staged', { count: stageResult.synced.length }));
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
spinner.fail(t('sync.stagingFailed'));
|
|
82
|
+
throw new Error(t('sync.stagingFailedDetail', { error: err.message }));
|
|
83
|
+
}
|
|
84
|
+
let pushResult = { committed: false, pushed: false };
|
|
85
|
+
if (stageResult.synced.length > 0 || stageResult.deleted.length > 0) {
|
|
86
|
+
// ── Dry-run: print summary and skip commit/push ─────────────
|
|
87
|
+
if (dryRun) {
|
|
88
|
+
console.log();
|
|
89
|
+
for (const f of stageResult.synced) {
|
|
90
|
+
logger.ok(` ${chalk.green(f)}`);
|
|
91
|
+
}
|
|
92
|
+
for (const f of stageResult.deleted) {
|
|
93
|
+
logger.info(` ${chalk.red('✕ ' + f)}`);
|
|
94
|
+
}
|
|
95
|
+
logger.ok('\n' + t('dryRun.wouldSync', {
|
|
96
|
+
count: stageResult.synced.length,
|
|
97
|
+
encrypted: stageResult.encrypted.length,
|
|
98
|
+
}));
|
|
99
|
+
if (stageResult.deleted.length > 0) {
|
|
100
|
+
logger.ok(t('dryRun.wouldPrune', { count: stageResult.deleted.length }));
|
|
101
|
+
}
|
|
102
|
+
logger.ok(t('dryRun.wouldCommit', { repo: cfg.repo }));
|
|
103
|
+
pushResult = { committed: false, pushed: false, stageResult };
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
const agentTag = agent ? `[${agent}]` : '';
|
|
107
|
+
const msg = t('sync.commitMsg', { tag: agentTag, host: hostname });
|
|
108
|
+
spinner = ora(t('sync.pushing')).start();
|
|
109
|
+
try {
|
|
110
|
+
const gitResult = await gitEngine.commitAndPush(repoPath, msg, resolveGitBranch(cfg));
|
|
111
|
+
if (gitResult.committed) {
|
|
112
|
+
spinner.succeed(t('sync.pushed', { repo: cfg.repo }));
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
spinner.info(t('sync.nothingToCommit'));
|
|
116
|
+
}
|
|
117
|
+
pushResult = { ...gitResult, stageResult };
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
spinner.fail(t('sync.pushFailed'));
|
|
121
|
+
try {
|
|
122
|
+
await gitEngine.rollback(repoPath);
|
|
123
|
+
}
|
|
124
|
+
catch (re) {
|
|
125
|
+
logger.error(t('sync.rollbackFailed', { error: re.message }));
|
|
126
|
+
}
|
|
127
|
+
throw new Error(t('sync.pushFailedDetail', { error: err.message }));
|
|
128
|
+
}
|
|
129
|
+
} // end else (non-dry-run)
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
logger.info(t('sync.noChanges'));
|
|
133
|
+
}
|
|
134
|
+
// ── 4. Summary ─────────────────────────────────────────────
|
|
135
|
+
console.log();
|
|
136
|
+
if (pulled && pullResult) {
|
|
137
|
+
logger.ok(t('sync.summaryPull', { count: pullResult.synced.length }));
|
|
138
|
+
}
|
|
139
|
+
if (pushResult.committed && pushResult.stageResult) {
|
|
140
|
+
logger.ok(t('sync.summaryPush', {
|
|
141
|
+
count: pushResult.stageResult.synced.length,
|
|
142
|
+
sha: pushResult.sha ?? '-',
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
if (!pulled && !pushResult.committed) {
|
|
146
|
+
logger.ok(t('sync.alreadyInSync'));
|
|
147
|
+
}
|
|
148
|
+
return { pulled, pullResult, pushed: pushResult.committed, pushResult };
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../src/commands/sync.ts"],"names":[],"mappings":"AAAA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gBACD,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAG,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACjF,CAAC;QACD,CAAC,CAAC,yBAAyB;IAC7B,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACnC,CAAC;IAED,8DAA8D;IAC9D,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,IAAI,MAAM,IAAI,UAAU,EAAE,CAAC;QACzB,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,kBAAkB,EAAE,EAAE,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACxE,CAAC;IACD,IAAI,UAAU,CAAC,SAAS,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC;QACnD,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,kBAAkB,EAAE;YAC9B,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM;YAC3C,GAAG,EAAE,UAAU,CAAC,GAAG,IAAI,GAAG;SAC3B,CAAC,CAAC,CAAC;IACN,CAAC;IACD,IAAI,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;QACrC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,SAAS,EAAE,UAAU,EAAE,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* watch.ts — wangchuan watch command (long-running daemon)
|
|
3
|
+
*
|
|
4
|
+
* Monitors enabled agents' workspace directories for file changes.
|
|
5
|
+
* Debounces changes then auto-triggers sync. Also periodically polls
|
|
6
|
+
* remote for new commits.
|
|
7
|
+
*/
|
|
8
|
+
import type { WatchOptions } from '../types.js';
|
|
9
|
+
export declare function cmdWatch({ agent, interval }?: WatchOptions): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=watch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../../src/commands/watch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH,OAAO,KAAK,EAAE,YAAY,EAA8B,MAAM,aAAa,CAAC;AAgC5E,wBAAsB,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuFpF"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* watch.ts — wangchuan watch command (long-running daemon)
|
|
3
|
+
*
|
|
4
|
+
* Monitors enabled agents' workspace directories for file changes.
|
|
5
|
+
* Debounces changes then auto-triggers sync. Also periodically polls
|
|
6
|
+
* remote for new commits.
|
|
7
|
+
*/
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
import { config } from '../core/config.js';
|
|
11
|
+
import { ensureMigrated } from '../core/migrate.js';
|
|
12
|
+
import { syncEngine } from '../core/sync.js';
|
|
13
|
+
import { validator } from '../utils/validator.js';
|
|
14
|
+
import { logger } from '../utils/logger.js';
|
|
15
|
+
import { t } from '../i18n.js';
|
|
16
|
+
import { cmdSync } from './sync.js';
|
|
17
|
+
import chalk from 'chalk';
|
|
18
|
+
const DEFAULT_INTERVAL_MINUTES = 5;
|
|
19
|
+
const DEBOUNCE_MS = 5_000;
|
|
20
|
+
/**
|
|
21
|
+
* Collect all absolute paths that should be watched for a given config.
|
|
22
|
+
* Returns a map of absPath → true for quick lookup, plus the list of
|
|
23
|
+
* directories to attach fs.watch() on.
|
|
24
|
+
*/
|
|
25
|
+
function collectWatchTargets(cfg, agent) {
|
|
26
|
+
const entries = syncEngine.buildFileEntries(cfg, undefined, agent);
|
|
27
|
+
const watchFiles = new Set();
|
|
28
|
+
const watchDirs = new Set();
|
|
29
|
+
for (const entry of entries) {
|
|
30
|
+
watchFiles.add(entry.srcAbs);
|
|
31
|
+
watchDirs.add(path.dirname(entry.srcAbs));
|
|
32
|
+
}
|
|
33
|
+
return { watchDirs: [...watchDirs], watchFiles };
|
|
34
|
+
}
|
|
35
|
+
function timestamp() {
|
|
36
|
+
return new Date().toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai', hour12: false });
|
|
37
|
+
}
|
|
38
|
+
export async function cmdWatch({ agent, interval } = {}) {
|
|
39
|
+
logger.banner(t('watch.banner'));
|
|
40
|
+
let cfg = config.load();
|
|
41
|
+
validator.requireInit(cfg);
|
|
42
|
+
cfg = ensureMigrated(cfg);
|
|
43
|
+
const intervalMinutes = interval ?? DEFAULT_INTERVAL_MINUTES;
|
|
44
|
+
if (agent)
|
|
45
|
+
logger.info(t('watch.filterAgent', { agent: chalk.cyan(agent) }));
|
|
46
|
+
logger.info(t('watch.interval', { minutes: intervalMinutes }));
|
|
47
|
+
const { watchDirs, watchFiles } = collectWatchTargets(cfg, agent);
|
|
48
|
+
if (watchDirs.length === 0) {
|
|
49
|
+
logger.warn(t('watch.noTargets'));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
logger.info(t('watch.watching', { dirs: watchDirs.length, files: watchFiles.size }));
|
|
53
|
+
// ── Debounce state ──────────────────────────────────────────
|
|
54
|
+
let debounceTimer = null;
|
|
55
|
+
let syncing = false;
|
|
56
|
+
async function triggerSync(reason) {
|
|
57
|
+
if (syncing)
|
|
58
|
+
return;
|
|
59
|
+
syncing = true;
|
|
60
|
+
try {
|
|
61
|
+
logger.step(t('watch.triggerSync', { reason, time: timestamp() }));
|
|
62
|
+
await cmdSync(agent ? { agent } : {});
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
logger.error(t('watch.syncError', { error: err.message }));
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
syncing = false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function onFileChange(filePath) {
|
|
72
|
+
if (!watchFiles.has(filePath))
|
|
73
|
+
return;
|
|
74
|
+
logger.debug(t('watch.fileChanged', { file: filePath }));
|
|
75
|
+
if (debounceTimer)
|
|
76
|
+
clearTimeout(debounceTimer);
|
|
77
|
+
debounceTimer = setTimeout(() => {
|
|
78
|
+
void triggerSync(t('watch.reasonFileChange'));
|
|
79
|
+
}, DEBOUNCE_MS);
|
|
80
|
+
}
|
|
81
|
+
// ── Attach fs.watch() to directories ─────────────────────────
|
|
82
|
+
const watchers = [];
|
|
83
|
+
for (const dir of watchDirs) {
|
|
84
|
+
if (!fs.existsSync(dir)) {
|
|
85
|
+
logger.debug(t('watch.dirNotFound', { dir }));
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const watcher = fs.watch(dir, { persistent: true }, (_event, filename) => {
|
|
90
|
+
if (!filename)
|
|
91
|
+
return;
|
|
92
|
+
const fullPath = path.join(dir, filename);
|
|
93
|
+
onFileChange(fullPath);
|
|
94
|
+
});
|
|
95
|
+
watchers.push(watcher);
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
logger.warn(t('watch.watchError', { dir, error: err.message }));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// ── Periodic remote polling ──────────────────────────────────
|
|
102
|
+
const pollInterval = setInterval(() => {
|
|
103
|
+
void triggerSync(t('watch.reasonPoll'));
|
|
104
|
+
}, intervalMinutes * 60 * 1_000);
|
|
105
|
+
// ── Graceful shutdown ────────────────────────────────────────
|
|
106
|
+
function shutdown() {
|
|
107
|
+
logger.info(t('watch.shutdown'));
|
|
108
|
+
if (debounceTimer)
|
|
109
|
+
clearTimeout(debounceTimer);
|
|
110
|
+
clearInterval(pollInterval);
|
|
111
|
+
for (const w of watchers)
|
|
112
|
+
w.close();
|
|
113
|
+
process.exit(0);
|
|
114
|
+
}
|
|
115
|
+
process.on('SIGINT', shutdown);
|
|
116
|
+
process.on('SIGTERM', shutdown);
|
|
117
|
+
logger.ok(t('watch.started'));
|
|
118
|
+
logger.info(t('watch.stopHint'));
|
|
119
|
+
// Run an initial sync immediately
|
|
120
|
+
await triggerSync(t('watch.reasonInitial'));
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=watch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../../src/commands/watch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAQ,IAAI,CAAC;AACtB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAe,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAO,oBAAoB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAW,iBAAiB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAY,uBAAuB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAe,oBAAoB,CAAC;AACrD,OAAO,EAAE,CAAC,EAAE,MAAoB,YAAY,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAc,WAAW,CAAC;AAG5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAM,WAAW,GAAG,KAAK,CAAC;AAE1B;;;;GAIG;AACH,SAAS,mBAAmB,CAC1B,GAAoB,EACpB,KAAiB;IAEjB,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IACnE,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,MAAM,SAAS,GAAI,IAAI,GAAG,EAAU,CAAC;IAErC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,UAAU,CAAC,GAAG,CAAC,K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AC;QAC5B,KAAK,MAAM,CAAC,IAAI,QAAQ;YAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAEhC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;IAC9B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEjC,kCAAkC;IAClC,MAAM,WAAW,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import type { WangchuanConfig, AgentProfiles, SharedConfig } from '../types.js';
|
|
8
8
|
export declare const CONFIG_VERSION = 2;
|
|
9
9
|
export declare const config: {
|
|
10
|
-
/**
|
|
10
|
+
/** Read config, return null if not found */
|
|
11
11
|
readonly load: () => WangchuanConfig | null;
|
|
12
12
|
/** 保存配置到磁盘 */
|
|
13
13
|
readonly save: (cfg: WangchuanConfig) => void;
|
|
@@ -31,4 +31,10 @@ export declare const config: {
|
|
|
31
31
|
readonly example: string;
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Resolve the git branch for the given config's active environment.
|
|
36
|
+
* - environment undefined or 'default' → cfg.branch (typically 'main')
|
|
37
|
+
* - any other value → 'env/{name}'
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveGitBranch(cfg: WangchuanConfig): string;
|
|
34
40
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/core/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAOhF,eAAO,MAAM,cAAc,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/core/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAOhF,eAAO,MAAM,cAAc,IAAI,CAAC;AAmJhC,eAAO,MAAM,MAAM;IACjB,4CAA4C;yBACpC,eAAe,GAAG,IAAI;IAsB9B,cAAc;yBACJ,eAAe,KAAG,IAAI;IAMhC,kBAAkB;yCACc,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC;IAaxD,2BAA2B;gCACJ,MAAM,KAAG,OAAO,CAAC,eAAe,CAAC;IAiBxD,2BAA2B;2BACf,eAAe,YAAY,OAAO,CAAC,eAAe,CAAC,KAAG,eAAe;IAIjF,kBAAkB;;;;;;IAOlB,aAAa;;;;;;;CAOL,CAAC;AAEX;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAK7D"}
|
package/dist/src/core/config.js
CHANGED
|
@@ -24,9 +24,13 @@ const DEFAULT_PROFILES = {
|
|
|
24
24
|
{ src: 'MEMORY.md', encrypt: true },
|
|
25
25
|
{ src: 'AGENTS.md', encrypt: false },
|
|
26
26
|
{ src: 'SOUL.md', encrypt: false },
|
|
27
|
+
{ src: 'IDENTITY.md', encrypt: false },
|
|
28
|
+
{ src: 'USER.md', encrypt: true },
|
|
27
29
|
],
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
syncDirs: [
|
|
31
|
+
{ src: 'memory/', encrypt: true }, // dated memory logs (memory/SHARED.md etc.)
|
|
32
|
+
],
|
|
33
|
+
// skills/ → shared tier; TOOLS.md excluded (environment-specific)
|
|
30
34
|
},
|
|
31
35
|
claude: {
|
|
32
36
|
enabled: true,
|
|
@@ -35,7 +39,6 @@ const DEFAULT_PROFILES = {
|
|
|
35
39
|
{ src: 'CLAUDE.md', encrypt: false },
|
|
36
40
|
{ src: 'settings.json', encrypt: true },
|
|
37
41
|
],
|
|
38
|
-
// .claude.json 整文件不再同步,改用 jsonFields 提取 mcpServers
|
|
39
42
|
jsonFields: [
|
|
40
43
|
{
|
|
41
44
|
src: '.claude.json',
|
|
@@ -49,17 +52,89 @@ const DEFAULT_PROFILES = {
|
|
|
49
52
|
enabled: true,
|
|
50
53
|
workspacePath: path.join(os.homedir(), '.gemini'),
|
|
51
54
|
syncFiles: [],
|
|
52
|
-
// projects.json 和 trustedFolders.json 是环境特有路径,不再同步
|
|
53
|
-
// settings.internal.json 改用 jsonFields 仅提取有用字段
|
|
54
55
|
jsonFields: [
|
|
55
56
|
{
|
|
56
57
|
src: 'settings.internal.json',
|
|
57
|
-
fields: ['security', 'model'],
|
|
58
|
+
fields: ['security', 'model', 'general'],
|
|
59
|
+
repoName: 'settings-sync.json',
|
|
60
|
+
encrypt: true,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
codebuddy: {
|
|
65
|
+
enabled: true,
|
|
66
|
+
workspacePath: path.join(os.homedir(), '.codebuddy'),
|
|
67
|
+
syncFiles: [
|
|
68
|
+
{ src: 'MEMORY.md', encrypt: true },
|
|
69
|
+
{ src: 'CODEBUDDY.md', encrypt: false },
|
|
70
|
+
],
|
|
71
|
+
jsonFields: [
|
|
72
|
+
// MCP config at ~/.codebuddy/mcp.json
|
|
73
|
+
{
|
|
74
|
+
src: 'mcp.json',
|
|
75
|
+
fields: ['mcpServers'],
|
|
76
|
+
repoName: 'mcpServers.json',
|
|
77
|
+
encrypt: true,
|
|
78
|
+
},
|
|
79
|
+
// settings.json → only portable fields (exclude hooks with absolute paths)
|
|
80
|
+
{
|
|
81
|
+
src: 'settings.json',
|
|
82
|
+
fields: ['enabledPlugins'],
|
|
83
|
+
repoName: 'settings-sync.json',
|
|
84
|
+
encrypt: true,
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
workbuddy: {
|
|
89
|
+
enabled: true,
|
|
90
|
+
workspacePath: path.join(os.homedir(), '.workbuddy'),
|
|
91
|
+
syncFiles: [
|
|
92
|
+
{ src: 'MEMORY.md', encrypt: true },
|
|
93
|
+
{ src: 'IDENTITY.md', encrypt: false },
|
|
94
|
+
{ src: 'SOUL.md', encrypt: false },
|
|
95
|
+
{ src: 'USER.md', encrypt: true },
|
|
96
|
+
],
|
|
97
|
+
jsonFields: [
|
|
98
|
+
// MCP config at ~/.workbuddy/mcp.json
|
|
99
|
+
{
|
|
100
|
+
src: 'mcp.json',
|
|
101
|
+
fields: ['mcpServers'],
|
|
102
|
+
repoName: 'mcpServers.json',
|
|
103
|
+
encrypt: true,
|
|
104
|
+
},
|
|
105
|
+
// settings.json → only portable fields
|
|
106
|
+
{
|
|
107
|
+
src: 'settings.json',
|
|
108
|
+
fields: ['enabledPlugins'],
|
|
58
109
|
repoName: 'settings-sync.json',
|
|
59
110
|
encrypt: true,
|
|
60
111
|
},
|
|
61
112
|
],
|
|
62
113
|
},
|
|
114
|
+
cursor: {
|
|
115
|
+
enabled: true,
|
|
116
|
+
workspacePath: path.join(os.homedir(), '.cursor'),
|
|
117
|
+
syncFiles: [],
|
|
118
|
+
syncDirs: [
|
|
119
|
+
{ src: 'rules/', encrypt: false }, // global rules directory
|
|
120
|
+
],
|
|
121
|
+
jsonFields: [
|
|
122
|
+
// MCP config at ~/.cursor/mcp.json
|
|
123
|
+
{
|
|
124
|
+
src: 'mcp.json',
|
|
125
|
+
fields: ['mcpServers'],
|
|
126
|
+
repoName: 'mcpServers.json',
|
|
127
|
+
encrypt: true,
|
|
128
|
+
},
|
|
129
|
+
// cli-config.json → only portable fields (exclude authInfo, privacyCache)
|
|
130
|
+
{
|
|
131
|
+
src: 'cli-config.json',
|
|
132
|
+
fields: ['permissions', 'model', 'enabledPlugins'],
|
|
133
|
+
repoName: 'cli-config-sync.json',
|
|
134
|
+
encrypt: true,
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
},
|
|
63
138
|
};
|
|
64
139
|
/** 共享层默认配置 */
|
|
65
140
|
const DEFAULT_SHARED = {
|
|
@@ -67,12 +142,16 @@ const DEFAULT_SHARED = {
|
|
|
67
142
|
sources: [
|
|
68
143
|
{ agent: 'claude', dir: 'skills/' },
|
|
69
144
|
{ agent: 'openclaw', dir: 'skills/' },
|
|
145
|
+
{ agent: 'codebuddy', dir: 'skills/' },
|
|
70
146
|
],
|
|
71
147
|
},
|
|
72
148
|
mcp: {
|
|
73
149
|
sources: [
|
|
74
150
|
{ agent: 'claude', src: '.claude.json', field: 'mcpServers' },
|
|
75
151
|
{ agent: 'openclaw', src: 'config/mcporter.json', field: 'mcpServers' },
|
|
152
|
+
{ agent: 'codebuddy', src: 'mcp.json', field: 'mcpServers' },
|
|
153
|
+
{ agent: 'workbuddy', src: 'mcp.json', field: 'mcpServers' },
|
|
154
|
+
{ agent: 'cursor', src: 'mcp.json', field: 'mcpServers' },
|
|
76
155
|
],
|
|
77
156
|
},
|
|
78
157
|
syncFiles: [
|
|
@@ -80,17 +159,29 @@ const DEFAULT_SHARED = {
|
|
|
80
159
|
],
|
|
81
160
|
};
|
|
82
161
|
export const config = {
|
|
83
|
-
/**
|
|
162
|
+
/** Read config, return null if not found */
|
|
84
163
|
load() {
|
|
85
164
|
if (!fs.existsSync(CONFIG_PATH))
|
|
86
165
|
return null;
|
|
166
|
+
let parsed;
|
|
87
167
|
try {
|
|
88
168
|
const raw = fs.readFileSync(CONFIG_PATH, 'utf-8');
|
|
89
|
-
|
|
169
|
+
parsed = JSON.parse(raw);
|
|
90
170
|
}
|
|
91
171
|
catch (err) {
|
|
92
172
|
throw new Error(t('config.loadFailed', { error: err.message }));
|
|
93
173
|
}
|
|
174
|
+
// Validate required fields
|
|
175
|
+
for (const field of ['repo', 'branch', 'localRepoPath', 'keyPath']) {
|
|
176
|
+
if (!parsed[field]) {
|
|
177
|
+
throw new Error(t('config.invalidFormat', { field }));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const profiles = parsed['profiles'];
|
|
181
|
+
if (!profiles?.['default']) {
|
|
182
|
+
throw new Error(t('config.invalidFormat', { field: 'profiles.default' }));
|
|
183
|
+
}
|
|
184
|
+
return parsed;
|
|
94
185
|
},
|
|
95
186
|
/** 保存配置到磁盘 */
|
|
96
187
|
save(cfg) {
|
|
@@ -147,4 +238,15 @@ export const config = {
|
|
|
147
238
|
example: EXAMPLE_PATH,
|
|
148
239
|
},
|
|
149
240
|
};
|
|
241
|
+
/**
|
|
242
|
+
* Resolve the git branch for the given config's active environment.
|
|
243
|
+
* - environment undefined or 'default' → cfg.branch (typically 'main')
|
|
244
|
+
* - any other value → 'env/{name}'
|
|
245
|
+
*/
|
|
246
|
+
export function resolveGitBranch(cfg) {
|
|
247
|
+
if (!cfg.environment || cfg.environment === 'default') {
|
|
248
|
+
return cfg.branch;
|
|
249
|
+
}
|
|
250
|
+
return `env/${cfg.environment}`;
|
|
251
|
+
}
|
|
150
252
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/core/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAQ,IAAI,CAAC;AACtB,OAAO,EAAE,MAAQ,IAAI,CAAC;AACtB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAW,YAAY,CAAC;AAGpC,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;AAC5D,MAAM,WAAW,GAAK,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,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M,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACpD,MAAM,GAAG,GAAoB;YAC3B,IAAI;YACJ,MAAM;YACN,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;YAC/C,OAAO,EAAQ,QAAQ;YACvB,QAAQ,EAAO,EAAE,CAAC,QAAQ,EAAE;YAC5B,OAAO,EAAQ,cAAc;YAC7B,QAAQ,EAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE;YAC5C,MAAM,EAAS,cAAc;SAC9B,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACf,OAAO,GAAG,CAAC;IACb,CAAC;IAED,2BAA2B;IAC3B,KAAK,CAAC,IAAqB,EAAE,QAAkC;QAC7D,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAC;IAClC,CAAC;IAED,kBAAkB;IAClB,QAAQ,EAAE;QACR,QAAQ,EAAE,gBAAgB;QAC1B,MAAM,EAAI,cAAc;QACxB,OAAO,EAAG,cAAc;KACzB;IAED,aAAa;IACb,KAAK,EAAE;QACL,GAAG,EAAM,aAAa;QACtB,MAAM,EAAG,WAAW;QACpB,GAAG,EAAM,QAAQ;QACjB,OAAO,EAAE,YAAY;KACtB;CACO,CAAC;AAEX;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAoB;IACnD,IAAI,CAAC,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACtD,OAAO,GAAG,CAAC,MAAM,CAAC;IACpB,CAAC;IACD,OAAO,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC"}
|
package/dist/src/core/git.d.ts
CHANGED
|
@@ -13,6 +13,17 @@ export declare const gitEngine: {
|
|
|
13
13
|
readonly log: (localPath: string, n?: number) => Promise<readonly DefaultLogFields[]>;
|
|
14
14
|
readonly getRemoteUrl: (localPath: string) => Promise<string | null>;
|
|
15
15
|
readonly rollback: (localPath: string) => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Fetch from remote and check if remote branch is ahead of local.
|
|
18
|
+
* Returns the number of commits the remote is ahead.
|
|
19
|
+
*/
|
|
20
|
+
readonly fetchAndCheckRemoteAhead: (localPath: string, branch?: string) => Promise<number>;
|
|
16
21
|
readonly isGitAvailable: () => Promise<boolean>;
|
|
22
|
+
readonly currentBranch: (localPath: string) => Promise<string>;
|
|
23
|
+
readonly listBranches: (localPath: string) => Promise<readonly string[]>;
|
|
24
|
+
readonly branchExists: (localPath: string, branch: string) => Promise<boolean>;
|
|
25
|
+
readonly createBranch: (localPath: string, branch: string, baseBranch?: string) => Promise<void>;
|
|
26
|
+
readonly switchBranch: (localPath: string, branch: string) => Promise<void>;
|
|
27
|
+
readonly deleteBranch: (localPath: string, branch: string) => Promise<void>;
|
|
17
28
|
};
|
|
18
29
|
//# sourceMappingURL=git.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../../src/core/git.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAa,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAI9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAShD,eAAO,MAAM,SAAS;uCACU,MAAM,aAAa,MAAM,sBAAoB,OAAO,CAAC,IAAI,CAAC;+BAalE,MAAM;wCAOG,MAAM,WAAW,MAAM,sBAAoB,OAAO,CAAC,YAAY,CAAC;iCAqBvE,MAAM;8BAKT,MAAM,iBAAU,OAAO,CAAC,SAAS,gBAAgB,EAAE,CAAC;uCAK3C,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;mCAKnC,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../../src/core/git.ts"],"names":[],"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