opencode-github-sync 3.4.0 → 4.0.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 +82 -8
- package/README.zh-CN.md +48 -6
- package/dist/cli/app.d.ts +3 -2
- package/dist/cli/app.d.ts.map +1 -1
- package/dist/cli/app.js +7 -5
- package/dist/cli/app.js.map +1 -1
- package/dist/cli/i18n.d.ts +11 -0
- package/dist/cli/i18n.d.ts.map +1 -1
- package/dist/cli/i18n.js +22 -0
- package/dist/cli/i18n.js.map +1 -1
- package/dist/cli/index.d.ts +14 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +98 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/menu.d.ts.map +1 -1
- package/dist/cli/menu.js +17 -15
- package/dist/cli/menu.js.map +1 -1
- package/dist/core/autosync.d.ts +7 -3
- package/dist/core/autosync.d.ts.map +1 -1
- package/dist/core/autosync.js +32 -58
- package/dist/core/autosync.js.map +1 -1
- package/dist/core/categories.d.ts +3 -19
- package/dist/core/categories.d.ts.map +1 -1
- package/dist/core/categories.js +0 -85
- package/dist/core/categories.js.map +1 -1
- package/dist/core/compare.d.ts +1 -1
- package/dist/core/compare.d.ts.map +1 -1
- package/dist/core/compare.js +10 -1
- package/dist/core/compare.js.map +1 -1
- package/dist/core/configsync.d.ts +57 -0
- package/dist/core/configsync.d.ts.map +1 -0
- package/dist/core/configsync.js +310 -0
- package/dist/core/configsync.js.map +1 -0
- package/dist/core/history.d.ts +1 -1
- package/dist/core/history.d.ts.map +1 -1
- package/dist/core/history.js +3 -2
- package/dist/core/history.js.map +1 -1
- package/dist/core/lease.d.ts.map +1 -1
- package/dist/core/lease.js +5 -4
- package/dist/core/lease.js.map +1 -1
- package/dist/core/lock.d.ts.map +1 -1
- package/dist/core/lock.js +2 -1
- package/dist/core/lock.js.map +1 -1
- package/dist/core/manifest.d.ts +71 -0
- package/dist/core/manifest.d.ts.map +1 -0
- package/dist/core/manifest.js +302 -0
- package/dist/core/manifest.js.map +1 -0
- package/dist/core/migrate.d.ts +14 -0
- package/dist/core/migrate.d.ts.map +1 -0
- package/dist/core/migrate.js +207 -0
- package/dist/core/migrate.js.map +1 -0
- package/dist/core/overrides.d.ts +9 -29
- package/dist/core/overrides.d.ts.map +1 -1
- package/dist/core/overrides.js +29 -83
- package/dist/core/overrides.js.map +1 -1
- package/dist/core/paths.d.ts +21 -1
- package/dist/core/paths.d.ts.map +1 -1
- package/dist/core/paths.js +26 -0
- package/dist/core/paths.js.map +1 -1
- package/dist/core/repo.d.ts +1 -11
- package/dist/core/repo.d.ts.map +1 -1
- package/dist/core/repo.js +0 -32
- package/dist/core/repo.js.map +1 -1
- package/dist/core/settings.d.ts +32 -11
- package/dist/core/settings.d.ts.map +1 -1
- package/dist/core/settings.js +77 -26
- package/dist/core/settings.js.map +1 -1
- package/dist/core/setup.d.ts.map +1 -1
- package/dist/core/setup.js +3 -1
- package/dist/core/setup.js.map +1 -1
- package/dist/core/stage.d.ts +4 -16
- package/dist/core/stage.d.ts.map +1 -1
- package/dist/core/stage.js +13 -46
- package/dist/core/stage.js.map +1 -1
- package/dist/core/sync.d.ts +2 -0
- package/dist/core/sync.d.ts.map +1 -1
- package/dist/core/sync.js +116 -215
- package/dist/core/sync.js.map +1 -1
- package/dist/core/update.d.ts +13 -1
- package/dist/core/update.d.ts.map +1 -1
- package/dist/core/update.js +25 -4
- package/dist/core/update.js.map +1 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +8 -0
- package/dist/plugin/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { git } from "./git.js";
|
|
4
|
+
import { parseJsonc } from "./jsonc.js";
|
|
5
|
+
import { DEFAULT_MANIFEST, MANIFEST_FILE, legacyExtras } from "./manifest.js";
|
|
6
|
+
import { AGENTS_DIR, DATA_DIR, SESSIONS_DIR, STATE_DIR, repoDir, toolRoot, } from "./paths.js";
|
|
7
|
+
import { saveToRecovery } from "./recovery.js";
|
|
8
|
+
import { DEFAULT_GITATTRIBUTES, DEFAULT_GITIGNORE } from "./repo.js";
|
|
9
|
+
import { LEGACY_OVERRIDES_FILE, LEGACY_SETTINGS_FILE, overridesPath, settingsPath, writeRuntime, } from "./settings.js";
|
|
10
|
+
/**
|
|
11
|
+
* One-time upgrade of a 3.x machine to the 4.0 layout.
|
|
12
|
+
*
|
|
13
|
+
* 3.x made `~/.config/opencode` itself the git worktree and kept its own
|
|
14
|
+
* settings inside it. 4.0 keeps both in `~/.config/opencode-sync`. The move:
|
|
15
|
+
*
|
|
16
|
+
* 1. `config/.git` and the mirror folders (`_agents`, `_state`, ...) are
|
|
17
|
+
* renamed into `opencode-sync/repo/` (same disk, so nothing is copied),
|
|
18
|
+
* and the tracked root files are checked out there from the index.
|
|
19
|
+
* 2. The settings, overrides, autosync state and log are copied into the
|
|
20
|
+
* tool's home.
|
|
21
|
+
* 3. When the repository shared a root file or folder the default manifest
|
|
22
|
+
* does not list, a manifest keeping it is written, so upgrading never
|
|
23
|
+
* quietly stops syncing something.
|
|
24
|
+
* 4. The 3.x files left in the config folder (settings, overrides, and the
|
|
25
|
+
* tool's own `.gitignore` / `.gitattributes`) go to the recovery folder.
|
|
26
|
+
*
|
|
27
|
+
* The live config files are not touched. Anything that fails before step 4
|
|
28
|
+
* is undone, so the machine is left exactly as 3.x had it.
|
|
29
|
+
*/
|
|
30
|
+
const MIRRORS = [AGENTS_DIR, DATA_DIR, STATE_DIR, SESSIONS_DIR, "_extra", "_upstream"];
|
|
31
|
+
const LEGACY_AUTOSYNC_STATE = "opencode-sync-autosync.json";
|
|
32
|
+
const LEGACY_LOG = "opencode-sync-autosync.log";
|
|
33
|
+
export class MigrationError extends Error {
|
|
34
|
+
constructor(message) {
|
|
35
|
+
super(message);
|
|
36
|
+
this.name = "MigrationError";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function needsMigration(roots) {
|
|
40
|
+
if (fs.existsSync(settingsPath(roots.config)))
|
|
41
|
+
return false;
|
|
42
|
+
return fs.existsSync(path.join(roots.config, LEGACY_SETTINGS_FILE));
|
|
43
|
+
}
|
|
44
|
+
/** Upgrade a 3.x machine if it still has the 3.x layout. Cheap when not. */
|
|
45
|
+
export function ensureMigrated(roots) {
|
|
46
|
+
if (!needsMigration(roots))
|
|
47
|
+
return undefined;
|
|
48
|
+
return migrateFrom3x(roots);
|
|
49
|
+
}
|
|
50
|
+
function sameText(file, expected) {
|
|
51
|
+
try {
|
|
52
|
+
return fs.readFileSync(file, "utf8").replace(/\r\n/g, "\n") === expected;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** Root entries HEAD tracks, folders with a trailing slash. */
|
|
59
|
+
function trackedRootEntries(repo) {
|
|
60
|
+
const listed = git(["ls-tree", "-z", "HEAD"], { cwd: repo });
|
|
61
|
+
if (!listed.ok)
|
|
62
|
+
return [];
|
|
63
|
+
return listed.stdout
|
|
64
|
+
.split("\0")
|
|
65
|
+
.filter(Boolean)
|
|
66
|
+
.map((record) => {
|
|
67
|
+
const [meta = "", name = ""] = record.split("\t");
|
|
68
|
+
return meta.split(" ")[1] === "tree" ? `${name}/` : name;
|
|
69
|
+
})
|
|
70
|
+
.filter((name) => name && name !== "/");
|
|
71
|
+
}
|
|
72
|
+
export function migrateFrom3x(roots) {
|
|
73
|
+
const tool = toolRoot(roots);
|
|
74
|
+
const repo = repoDir(roots);
|
|
75
|
+
fs.mkdirSync(tool, { recursive: true });
|
|
76
|
+
// Two processes starting at once: the second one leaves it to the first.
|
|
77
|
+
const guard = path.join(tool, ".migrating");
|
|
78
|
+
try {
|
|
79
|
+
fs.mkdirSync(guard);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
const moved = [];
|
|
85
|
+
const created = [];
|
|
86
|
+
const move = (from, to) => {
|
|
87
|
+
fs.renameSync(from, to);
|
|
88
|
+
moved.push({ from, to });
|
|
89
|
+
};
|
|
90
|
+
const copy = (from, to) => {
|
|
91
|
+
fs.mkdirSync(path.dirname(to), { recursive: true });
|
|
92
|
+
fs.copyFileSync(from, to);
|
|
93
|
+
created.push(to);
|
|
94
|
+
};
|
|
95
|
+
const result = { movedRepository: false, manifestWritten: [] };
|
|
96
|
+
try {
|
|
97
|
+
const legacyGit = path.join(roots.config, ".git");
|
|
98
|
+
if (fs.existsSync(legacyGit)) {
|
|
99
|
+
if (fs.existsSync(repo) && fs.readdirSync(repo).length > 0) {
|
|
100
|
+
throw new MigrationError(`${repo} already exists and is not empty`);
|
|
101
|
+
}
|
|
102
|
+
fs.mkdirSync(repo, { recursive: true });
|
|
103
|
+
move(legacyGit, path.join(repo, ".git"));
|
|
104
|
+
for (const dir of MIRRORS) {
|
|
105
|
+
const from = path.join(roots.config, dir);
|
|
106
|
+
if (fs.existsSync(from))
|
|
107
|
+
move(from, path.join(repo, dir));
|
|
108
|
+
}
|
|
109
|
+
// Only what is missing comes back from the index. Files that were
|
|
110
|
+
// edited in the old worktree stay as they are and are shared next push.
|
|
111
|
+
const deleted = git(["ls-files", "--deleted", "-z"], { cwd: repo });
|
|
112
|
+
if (!deleted.ok)
|
|
113
|
+
throw new MigrationError(deleted.stderr || "git ls-files failed");
|
|
114
|
+
const missing = deleted.stdout.split("\0").filter(Boolean);
|
|
115
|
+
for (let i = 0; i < missing.length; i += 200) {
|
|
116
|
+
const out = git(["checkout", "--", ...missing.slice(i, i + 200)], { cwd: repo });
|
|
117
|
+
if (!out.ok)
|
|
118
|
+
throw new MigrationError(out.stderr || "git checkout failed");
|
|
119
|
+
}
|
|
120
|
+
result.movedRepository = true;
|
|
121
|
+
if (!fs.existsSync(path.join(repo, MANIFEST_FILE))) {
|
|
122
|
+
const extras = legacyExtras(trackedRootEntries(repo));
|
|
123
|
+
if (extras.length > 0) {
|
|
124
|
+
const text = [
|
|
125
|
+
"# Files of ~/.config/opencode this repository shares (opencode-github-sync 4.0).",
|
|
126
|
+
"# Written on upgrade from 3.x; the last block keeps what 3.x already shared.",
|
|
127
|
+
...DEFAULT_MANIFEST,
|
|
128
|
+
"",
|
|
129
|
+
"# Shared by 3.x",
|
|
130
|
+
...extras,
|
|
131
|
+
"",
|
|
132
|
+
].join("\n");
|
|
133
|
+
fs.writeFileSync(path.join(repo, MANIFEST_FILE), text);
|
|
134
|
+
created.push(path.join(repo, MANIFEST_FILE));
|
|
135
|
+
result.manifestWritten = extras;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const legacySettings = path.join(roots.config, LEGACY_SETTINGS_FILE);
|
|
140
|
+
copy(legacySettings, settingsPath(roots.config));
|
|
141
|
+
try {
|
|
142
|
+
const paused = Number(parseJsonc(fs.readFileSync(legacySettings, "utf8"))?.autosync
|
|
143
|
+
?.pausedUntil);
|
|
144
|
+
if (Number.isFinite(paused) && paused > Date.now()) {
|
|
145
|
+
writeRuntime(roots.config, { pausedUntil: paused });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
// An unreadable 3.x file is copied as it is; loading it reports the error.
|
|
150
|
+
}
|
|
151
|
+
const legacyOverrides = path.join(roots.config, LEGACY_OVERRIDES_FILE);
|
|
152
|
+
if (fs.existsSync(legacyOverrides))
|
|
153
|
+
copy(legacyOverrides, overridesPath(roots.config));
|
|
154
|
+
const legacyState = path.join(roots.state, LEGACY_AUTOSYNC_STATE);
|
|
155
|
+
if (fs.existsSync(legacyState)) {
|
|
156
|
+
try {
|
|
157
|
+
writeRuntime(roots.config, JSON.parse(fs.readFileSync(legacyState, "utf8")));
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
// Bookkeeping only: losing it costs one extra attempt.
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const legacyLog = path.join(roots.config, "logs", LEGACY_LOG);
|
|
164
|
+
if (fs.existsSync(legacyLog))
|
|
165
|
+
copy(legacyLog, path.join(tool, "logs", LEGACY_LOG));
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
for (const file of created.reverse())
|
|
169
|
+
fs.rmSync(file, { force: true });
|
|
170
|
+
for (const { from, to } of moved.reverse()) {
|
|
171
|
+
try {
|
|
172
|
+
if (fs.existsSync(to) && !fs.existsSync(from))
|
|
173
|
+
fs.renameSync(to, from);
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
// Reported below; the paths are in the message.
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
fs.rmSync(guard, { recursive: true, force: true });
|
|
180
|
+
throw new MigrationError(`Upgrading from 3.x failed and was undone: ${error.message}\n` +
|
|
181
|
+
`Nothing in ${roots.config} was changed.`);
|
|
182
|
+
}
|
|
183
|
+
// Past this point the new layout is complete; cleanup is best effort.
|
|
184
|
+
const leftovers = [LEGACY_SETTINGS_FILE, LEGACY_OVERRIDES_FILE];
|
|
185
|
+
if (result.movedRepository) {
|
|
186
|
+
if (sameText(path.join(roots.config, ".gitignore"), DEFAULT_GITIGNORE)) {
|
|
187
|
+
leftovers.push(".gitignore");
|
|
188
|
+
}
|
|
189
|
+
if (sameText(path.join(roots.config, ".gitattributes"), DEFAULT_GITATTRIBUTES)) {
|
|
190
|
+
leftovers.push(".gitattributes");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
try {
|
|
194
|
+
result.recovery = saveToRecovery(roots, "upgrade-from-3x", leftovers.map((rel) => ({ source: path.join(roots.config, rel), rel })));
|
|
195
|
+
for (const rel of leftovers)
|
|
196
|
+
fs.rmSync(path.join(roots.config, rel), { force: true });
|
|
197
|
+
fs.rmSync(path.join(roots.config, "logs", LEGACY_LOG), { force: true });
|
|
198
|
+
fs.rmSync(path.join(roots.state, LEGACY_AUTOSYNC_STATE), { force: true });
|
|
199
|
+
fs.rmSync(path.join(roots.config, ".opencode-sync.lock"), { recursive: true, force: true });
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
// Leftover 3.x files are ignored by 4.0.
|
|
203
|
+
}
|
|
204
|
+
fs.rmSync(guard, { recursive: true, force: true });
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=migrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/core/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EACL,UAAU,EACV,QAAQ,EAER,YAAY,EACZ,SAAS,EACT,OAAO,EACP,QAAQ,GACT,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,OAAO,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AACvF,MAAM,qBAAqB,GAAG,6BAA6B,CAAC;AAC5D,MAAM,UAAU,GAAG,4BAA4B,CAAC;AAEhD,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CA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EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/core/overrides.d.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
/** Locate the OpenCode config file inside a directory, if there is one. */
|
|
2
2
|
export declare function findConfigFile(dir: string): string | undefined;
|
|
3
|
-
export declare function hasOverrides(configRoot: string): boolean;
|
|
4
3
|
export declare function loadOverrides(configRoot: string): Record<string, any>;
|
|
5
|
-
/**
|
|
6
|
-
* Merge the local overrides into the config file after a pull.
|
|
7
|
-
*
|
|
8
|
-
* Returns true when the file was rewritten.
|
|
9
|
-
*/
|
|
10
|
-
export declare function applyOverrides(configRoot: string): boolean;
|
|
11
4
|
/**
|
|
12
5
|
* Remove override-owned keys from an effective config so it can be pushed.
|
|
13
6
|
*
|
|
@@ -17,27 +10,14 @@ export declare function applyOverrides(configRoot: string): boolean;
|
|
|
17
10
|
*/
|
|
18
11
|
export declare function stripOverrides(effective: Record<string, any>, overrides: Record<string, any>, previous: Record<string, any> | undefined): Record<string, any>;
|
|
19
12
|
/**
|
|
20
|
-
*
|
|
21
|
-
* the repository
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* committed version — that is the whole point. Plain `git status` therefore
|
|
25
|
-
* reports it as modified forever, which looks like pending work that never goes
|
|
26
|
-
* away. This lets the status command tell a real edit apart from the expected
|
|
27
|
-
* override difference.
|
|
28
|
-
*
|
|
29
|
-
* Returns `false` when there are no overrides, so callers fall back to git.
|
|
30
|
-
*/
|
|
31
|
-
export declare function configMatchesRepo(configRoot: string, previousText: string | undefined): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Produce the text that should be committed for the config file.
|
|
34
|
-
*
|
|
35
|
-
* `previousText` is the version currently recorded in the repository. It has to
|
|
36
|
-
* be read out of git rather than off disk, because the worktree *is* the config
|
|
37
|
-
* directory — the file on disk is the effective config, overrides and all, so
|
|
38
|
-
* using it as the baseline would quietly publish this machine's overrides.
|
|
39
|
-
*
|
|
40
|
-
* Returns `undefined` when the file can be committed as-is.
|
|
13
|
+
* The committed form of an effective config text: override-owned keys put
|
|
14
|
+
* back to the repository's values (`previousText`), or removed when the
|
|
15
|
+
* repository never had them. `undefined` when there are no overrides, which
|
|
16
|
+
* means the text is committed byte for byte.
|
|
41
17
|
*/
|
|
42
|
-
export declare function
|
|
18
|
+
export declare function repoTextFromEffective(effectiveText: string, overrides: Record<string, any>, previousText: string | undefined): string | undefined;
|
|
19
|
+
/** The effective form of a committed config text: overrides merged in. */
|
|
20
|
+
export declare function effectiveTextFromRepo(repoText: string, overrides: Record<string, any>): string | undefined;
|
|
21
|
+
/** True when two config texts hold the same data, ignoring layout and key order. */
|
|
22
|
+
export declare function sameConfigData(a: string, b: string): boolean;
|
|
43
23
|
//# sourceMappingURL=overrides.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../../src/core/overrides.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../../src/core/overrides.ts"],"names":[],"mappings":"AA2BA,2EAA2E;AAC3E,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM9D;AAED,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CASrE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC9B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,GACxC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAqBrB;AAkBD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC9B,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,MAAM,GAAG,SAAS,CAKpB;AAED,0EAA0E;AAC1E,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC7B,MAAM,GAAG,SAAS,CAIpB;AAED,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAM5D"}
|
package/dist/core/overrides.js
CHANGED
|
@@ -10,20 +10,16 @@ import { OVERRIDES_FILE, overridesPath } from "./settings.js";
|
|
|
10
10
|
* toolchain path, an MCP server that only exists on one box. Overrides restore
|
|
11
11
|
* that freedom by splitting the config into two layers.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* working copy `opencode.jsonc` shared baseline, committed
|
|
14
|
+
* `~/.config/opencode-sync/overrides.jsonc` this machine only
|
|
15
|
+
* ─────────────────────────────────────── deep merge
|
|
16
|
+
* live `~/.config/opencode/opencode.jsonc` what OpenCode actually reads
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* When no overrides file exists the config is copied byte for byte, which keeps
|
|
25
|
-
* comments and formatting untouched. The structural rewrite only happens for
|
|
26
|
-
* users who actually opted into overrides.
|
|
18
|
+
* Copying the live file into the working copy restores every override-owned
|
|
19
|
+
* key to the value the repository already had (or removes it when the
|
|
20
|
+
* repository never had it), so overridden keys are invisible to sync in both
|
|
21
|
+
* directions. Without overrides the config is copied byte for byte, which keeps
|
|
22
|
+
* comments and formatting untouched.
|
|
27
23
|
*/
|
|
28
24
|
const CONFIG_FILENAMES = ["opencode.jsonc", "opencode.json"];
|
|
29
25
|
/** Locate the OpenCode config file inside a directory, if there is one. */
|
|
@@ -35,13 +31,6 @@ export function findConfigFile(dir) {
|
|
|
35
31
|
}
|
|
36
32
|
return undefined;
|
|
37
33
|
}
|
|
38
|
-
export function hasOverrides(configRoot) {
|
|
39
|
-
const file = overridesPath(configRoot);
|
|
40
|
-
if (!fs.existsSync(file))
|
|
41
|
-
return false;
|
|
42
|
-
const parsed = loadOverrides(configRoot);
|
|
43
|
-
return Object.keys(parsed).length > 0;
|
|
44
|
-
}
|
|
45
34
|
export function loadOverrides(configRoot) {
|
|
46
35
|
const file = overridesPath(configRoot);
|
|
47
36
|
if (!fs.existsSync(file))
|
|
@@ -54,26 +43,6 @@ export function loadOverrides(configRoot) {
|
|
|
54
43
|
throw new Error(`Cannot read ${OVERRIDES_FILE}: ${e.message}`);
|
|
55
44
|
}
|
|
56
45
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Merge the local overrides into the config file after a pull.
|
|
59
|
-
*
|
|
60
|
-
* Returns true when the file was rewritten.
|
|
61
|
-
*/
|
|
62
|
-
export function applyOverrides(configRoot) {
|
|
63
|
-
const overrides = loadOverrides(configRoot);
|
|
64
|
-
if (Object.keys(overrides).length === 0)
|
|
65
|
-
return false;
|
|
66
|
-
const configFile = findConfigFile(configRoot);
|
|
67
|
-
if (!configFile)
|
|
68
|
-
return false;
|
|
69
|
-
const base = parseJsonc(fs.readFileSync(configFile, "utf8"));
|
|
70
|
-
const merged = deepMerge(base, overrides);
|
|
71
|
-
const next = `${JSON.stringify(merged, null, 2)}\n`;
|
|
72
|
-
if (fs.readFileSync(configFile, "utf8") === next)
|
|
73
|
-
return false;
|
|
74
|
-
fs.writeFileSync(configFile, next);
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
46
|
/**
|
|
78
47
|
* Remove override-owned keys from an effective config so it can be pushed.
|
|
79
48
|
*
|
|
@@ -115,55 +84,32 @@ function canonical(value) {
|
|
|
115
84
|
return JSON.stringify(value) ?? "null";
|
|
116
85
|
}
|
|
117
86
|
/**
|
|
118
|
-
*
|
|
119
|
-
* the repository
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* committed version — that is the whole point. Plain `git status` therefore
|
|
123
|
-
* reports it as modified forever, which looks like pending work that never goes
|
|
124
|
-
* away. This lets the status command tell a real edit apart from the expected
|
|
125
|
-
* override difference.
|
|
126
|
-
*
|
|
127
|
-
* Returns `false` when there are no overrides, so callers fall back to git.
|
|
87
|
+
* The committed form of an effective config text: override-owned keys put
|
|
88
|
+
* back to the repository's values (`previousText`), or removed when the
|
|
89
|
+
* repository never had them. `undefined` when there are no overrides, which
|
|
90
|
+
* means the text is committed byte for byte.
|
|
128
91
|
*/
|
|
129
|
-
export function
|
|
130
|
-
const overrides = loadOverrides(configRoot);
|
|
92
|
+
export function repoTextFromEffective(effectiveText, overrides, previousText) {
|
|
131
93
|
if (Object.keys(overrides).length === 0)
|
|
132
|
-
return
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
94
|
+
return undefined;
|
|
95
|
+
const effective = parseJsonc(effectiveText);
|
|
96
|
+
const previous = previousText ? parseJsonc(previousText) : undefined;
|
|
97
|
+
return `${JSON.stringify(stripOverrides(effective, overrides, previous), null, 2)}\n`;
|
|
98
|
+
}
|
|
99
|
+
/** The effective form of a committed config text: overrides merged in. */
|
|
100
|
+
export function effectiveTextFromRepo(repoText, overrides) {
|
|
101
|
+
if (Object.keys(overrides).length === 0)
|
|
102
|
+
return undefined;
|
|
103
|
+
const base = parseJsonc(repoText);
|
|
104
|
+
return `${JSON.stringify(deepMerge(base ?? {}, overrides), null, 2)}\n`;
|
|
105
|
+
}
|
|
106
|
+
/** True when two config texts hold the same data, ignoring layout and key order. */
|
|
107
|
+
export function sameConfigData(a, b) {
|
|
138
108
|
try {
|
|
139
|
-
|
|
140
|
-
const previous = parseJsonc(previousText);
|
|
141
|
-
return canonical(stripOverrides(effective, overrides, previous)) === canonical(previous);
|
|
109
|
+
return canonical(parseJsonc(a)) === canonical(parseJsonc(b));
|
|
142
110
|
}
|
|
143
111
|
catch {
|
|
144
|
-
// Unparseable on either side: treat it as a genuine difference.
|
|
145
112
|
return false;
|
|
146
113
|
}
|
|
147
114
|
}
|
|
148
|
-
/**
|
|
149
|
-
* Produce the text that should be committed for the config file.
|
|
150
|
-
*
|
|
151
|
-
* `previousText` is the version currently recorded in the repository. It has to
|
|
152
|
-
* be read out of git rather than off disk, because the worktree *is* the config
|
|
153
|
-
* directory — the file on disk is the effective config, overrides and all, so
|
|
154
|
-
* using it as the baseline would quietly publish this machine's overrides.
|
|
155
|
-
*
|
|
156
|
-
* Returns `undefined` when the file can be committed as-is.
|
|
157
|
-
*/
|
|
158
|
-
export function configTextForRepo(configRoot, previousText) {
|
|
159
|
-
const overrides = loadOverrides(configRoot);
|
|
160
|
-
if (Object.keys(overrides).length === 0)
|
|
161
|
-
return undefined;
|
|
162
|
-
const configFile = findConfigFile(configRoot);
|
|
163
|
-
if (!configFile)
|
|
164
|
-
return undefined;
|
|
165
|
-
const effective = parseJsonc(fs.readFileSync(configFile, "utf8"));
|
|
166
|
-
const previous = previousText ? parseJsonc(previousText) : undefined;
|
|
167
|
-
return `${JSON.stringify(stripOverrides(effective, overrides, previous), null, 2)}\n`;
|
|
168
|
-
}
|
|
169
115
|
//# sourceMappingURL=overrides.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overrides.js","sourceRoot":"","sources":["../../src/core/overrides.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9D
|
|
1
|
+
{"version":3,"file":"over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AACpF,MAAM,UAAU,cAAc,CAAC,CAAS,EAAE,CAAS;IACjD,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/core/paths.d.ts
CHANGED
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
* machine.
|
|
7
7
|
*/
|
|
8
8
|
export interface Roots {
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* `~/.config/opencode` — OpenCode's live configuration. Since 4.0 it is no
|
|
11
|
+
* longer a git worktree: listed files are copied to and from the working
|
|
12
|
+
* copy in the tool's own home (see `toolRootFor`).
|
|
13
|
+
*/
|
|
10
14
|
config: string;
|
|
11
15
|
/** `~/.local/share/opencode` — auth, account, sqlite database. */
|
|
12
16
|
data: string;
|
|
@@ -23,6 +27,22 @@ export declare function getStateRoot(): string;
|
|
|
23
27
|
export declare function getAgentsRoot(): string;
|
|
24
28
|
export declare function getCacheRoot(): string;
|
|
25
29
|
export declare function getRoots(): Roots;
|
|
30
|
+
/** Name of the tool's home, a sibling of the OpenCode config directory. */
|
|
31
|
+
export declare const TOOL_DIR_NAME = "opencode-sync";
|
|
32
|
+
/** The git working copy inside the tool's home. */
|
|
33
|
+
export declare const REPO_DIR_NAME = "repo";
|
|
34
|
+
/**
|
|
35
|
+
* The tool's own home: `~/.config/opencode-sync`, next to the OpenCode config
|
|
36
|
+
* directory. It holds this machine's settings, overrides, runtime state, logs,
|
|
37
|
+
* the sync lock and the git working copy. It is always derived from the config
|
|
38
|
+
* root, so anything that points the config root at a sandbox (tests, CI) gets
|
|
39
|
+
* a sandboxed tool home with it. `SYNC_TOOL_ROOT` overrides it outright.
|
|
40
|
+
*/
|
|
41
|
+
export declare function toolRootFor(configRoot: string): string;
|
|
42
|
+
export declare function toolRoot(roots: Roots): string;
|
|
43
|
+
/** The git working copy the tool syncs through. Never the live config. */
|
|
44
|
+
export declare function repoDirFor(configRoot: string): string;
|
|
45
|
+
export declare function repoDir(roots: Roots): string;
|
|
26
46
|
/** Path of the OpenCode SQLite database that holds all sessions. */
|
|
27
47
|
export declare function getDatabasePath(roots?: Roots): string;
|
|
28
48
|
/** Directory inside the sync repo where session shards are written. */
|
package/dist/core/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/core/paths.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,WAAW,KAAK;IACpB
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/core/paths.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,WAAW,KAAK;IACpB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;CACf;AAQD,wBAAgB,aAAa,IAAI,MAAM,CAGtC;AAED,wBAAgB,WAAW,IAAI,MAAM,CAGpC;AAED,wBAAgB,YAAY,IAAI,MAAM,CAGrC;AAED,wBAAgB,aAAa,IAAI,MAAM,CAGtC;AAED,wBAAgB,YAAY,IAAI,MAAM,CAGrC;AAED,wBAAgB,QAAQ,IAAI,KAAK,CAQhC;AAED,2EAA2E;AAC3E,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAC7C,mDAAmD;AACnD,eAAO,MAAM,aAAa,SAAS,CAAC;AAEpC;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAGtD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAE7C;AAED,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAE5C;AAED,oEAAoE;AACpE,wBAAgB,eAAe,CAAC,KAAK,GAAE,KAAkB,GAAG,MAAM,CAEjE;AAED,uEAAuE;AACvE,eAAO,MAAM,YAAY,cAAc,CAAC;AACxC,uEAAuE;AACvE,eAAO,MAAM,QAAQ,UAAU,CAAC;AAChC,wEAAwE;AACxE,eAAO,MAAM,SAAS,WAAW,CAAC;AAClC,mEAAmE;AACnE,eAAO,MAAM,UAAU,YAAY,CAAC"}
|
package/dist/core/paths.js
CHANGED
|
@@ -40,6 +40,32 @@ export function getRoots() {
|
|
|
40
40
|
cache: getCacheRoot(),
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
+
/** Name of the tool's home, a sibling of the OpenCode config directory. */
|
|
44
|
+
export const TOOL_DIR_NAME = "opencode-sync";
|
|
45
|
+
/** The git working copy inside the tool's home. */
|
|
46
|
+
export const REPO_DIR_NAME = "repo";
|
|
47
|
+
/**
|
|
48
|
+
* The tool's own home: `~/.config/opencode-sync`, next to the OpenCode config
|
|
49
|
+
* directory. It holds this machine's settings, overrides, runtime state, logs,
|
|
50
|
+
* the sync lock and the git working copy. It is always derived from the config
|
|
51
|
+
* root, so anything that points the config root at a sandbox (tests, CI) gets
|
|
52
|
+
* a sandboxed tool home with it. `SYNC_TOOL_ROOT` overrides it outright.
|
|
53
|
+
*/
|
|
54
|
+
export function toolRootFor(configRoot) {
|
|
55
|
+
if (process.env.SYNC_TOOL_ROOT)
|
|
56
|
+
return process.env.SYNC_TOOL_ROOT;
|
|
57
|
+
return path.join(path.dirname(configRoot), TOOL_DIR_NAME);
|
|
58
|
+
}
|
|
59
|
+
export function toolRoot(roots) {
|
|
60
|
+
return toolRootFor(roots.config);
|
|
61
|
+
}
|
|
62
|
+
/** The git working copy the tool syncs through. Never the live config. */
|
|
63
|
+
export function repoDirFor(configRoot) {
|
|
64
|
+
return path.join(toolRootFor(configRoot), REPO_DIR_NAME);
|
|
65
|
+
}
|
|
66
|
+
export function repoDir(roots) {
|
|
67
|
+
return repoDirFor(roots.config);
|
|
68
|
+
}
|
|
43
69
|
/** Path of the OpenCode SQLite database that holds all sessions. */
|
|
44
70
|
export function getDatabasePath(roots = getRoots()) {
|
|
45
71
|
return path.join(roots.data, "opencode.db");
|
package/dist/core/paths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/core/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/core/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AA0B7B,SAAS,GAAG,CAAC,MAAc,EAAE,GAAG,QAAkB;IAChD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,GAAG,QAAQ,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IACtE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,SAAS,CAAC,EAAE,UAAU,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc;QAAE,OAAO,OAAO,CAAC,GA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C,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IAClE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAY;IACnC,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,UAAU,CAAC,UAAkB;IAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAY;IAClC,OAAO,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,eAAe,CAAC,QAAe,QAAQ,EAAE;IACvD,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;AAC9C,CAAC;AAED,uEAAuE;AACvE,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC;AACxC,uEAAuE;AACvE,MAAM,CAAC,MAAM,QAAQ,GAAG,OAAO,CAAC;AAChC,wEAAwE;AACxE,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC;AAClC,mEAAmE;AACnE,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC"}
|
package/dist/core/repo.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* represented instead by the shards in `_sessions/`
|
|
8
8
|
* - caches, logs and OS junk
|
|
9
9
|
*/
|
|
10
|
-
export declare const DEFAULT_GITIGNORE = "# opencode-github-sync \u2014 machine-local, never committed\
|
|
10
|
+
export declare const DEFAULT_GITIGNORE = "# opencode-github-sync \u2014 machine-local, never committed\nmachine.jsonc\noverrides.jsonc\n.opencode-sync.lock\n\n# Runtime / generated\nnode_modules/\nbun.lock\nlogs/\n**/__pycache__/\n*.pyc\n\n# Session storage lives in _sessions/ as portable shards.\n# The raw database is far too large for git and cannot be merged.\n_data/opencode.db\n_data/opencode.db-shm\n_data/opencode.db-wal\n_data/bin/\n_data/log/\n_data/tool-output/\n_data/snapshot/\n_data/storage/session\n_data/storage/session_diff\n\n# Machine-local UI state and the autosync runtime state\n_state/session.json\n_state/opencode-sync-autosync.json\n_state/opencode-sync-autosync.json.tmp\n\n# OpenCode 2 machine files: the background-service record (URL, pid and a\n# plaintext password, in both the config and the state directory), lock files\n# and per-machine histories\n/service.json\n_state/service.json\n_state/locks/\n_state/**/locks/\n_state/**/*.lock\n_state/pty/\n_state/latest/tui/\n_state/prompt-history.jsonl\n_state/frecency.jsonl\n\n# Empty directories recreated by OpenCode at runtime\nplugin/\n\n# OS files\n.DS_Store\nThumbs.db\ndesktop.ini\n";
|
|
11
11
|
export declare const DEFAULT_GITATTRIBUTES = "# Store and check out everything with LF.\n# \"text=auto\" alone would rewrite files to CRLF on Windows, which silently\n# breaks shell scripts shipped inside skills and makes every cross-platform\n# pull look like a whole-file change.\n* text=auto eol=lf\n\n# Session shards are gzipped JSON \u2014 binary, and never line-merged\n_sessions/*.json.gz binary\n\n# Skill notes grow by appended sections on several machines at once. Keep both\n# sides instead of stopping the sync on a conflict; JSON and JSONC still stop.\n_agents/**/references/**/*.md merge=union\n_agents/**/lessons-learned.md merge=union\n";
|
|
12
12
|
/**
|
|
13
13
|
* Files an older version could have committed that must never be tracked:
|
|
@@ -19,16 +19,6 @@ export declare const UNTRACKED_MACHINE_FILES: string[];
|
|
|
19
19
|
export declare const UNTRACKED_MACHINE_GLOBS: string[];
|
|
20
20
|
/** Remove machine files from the index if a previous version committed them. */
|
|
21
21
|
export declare function untrackMachineFiles(root: string): void;
|
|
22
|
-
/**
|
|
23
|
-
* Keep this machine's config-dir `service.json` exactly as it is across a sync.
|
|
24
|
-
*
|
|
25
|
-
* Git treats ignored files as expendable: a reset, fast-forward or rebase onto
|
|
26
|
-
* a commit that still tracks `service.json` (pushed by an older version)
|
|
27
|
-
* overwrites the local file, and replaying the commit that untracks it then
|
|
28
|
-
* deletes it. Returns the function that puts the original back, or removes
|
|
29
|
-
* another machine's copy when this machine had none.
|
|
30
|
-
*/
|
|
31
|
-
export declare function holdMachineFiles(root: string): () => void;
|
|
32
22
|
/**
|
|
33
23
|
* Paths that exist inside the worktree but must stay out of every commit.
|
|
34
24
|
*
|
package/dist/core/repo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../src/core/repo.ts"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../src/core/repo.ts"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,6mCAiD7B,CAAC;AAEF,eAAO,MAAM,qBAAqB,omBAajC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,UAQnC,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,uBAAuB,UAAyD,CAAC;AAE9F,gFAAgF;AAChF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CActD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,UAQ/B,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAM7D;AAED,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAE3C;AAED,qFAAqF;AACrF,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE3D;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf;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
|
106
106
|
...UNTRACKED_MACHINE_GLOBS.map((p) => `:(top,glob)${p}`),
|
|
107
107
|
], { cwd: root });
|
|
108
108
|
}
|
|
109
|
-
/**
|
|
110
|
-
* Keep this machine's config-dir `service.json` exactly as it is across a sync.
|
|
111
|
-
*
|
|
112
|
-
* Git treats ignored files as expendable: a reset, fast-forward or rebase onto
|
|
113
|
-
* a commit that still tracks `service.json` (pushed by an older version)
|
|
114
|
-
* overwrites the local file, and replaying the commit that untracks it then
|
|
115
|
-
* deletes it. Returns the function that puts the original back, or removes
|
|
116
|
-
* another machine's copy when this machine had none.
|
|
117
|
-
*/
|
|
118
|
-
export function holdMachineFiles(root) {
|
|
119
|
-
const file = path.join(root, "service.json");
|
|
120
|
-
let original;
|
|
121
|
-
try {
|
|
122
|
-
original = fs.readFileSync(file);
|
|
123
|
-
}
|
|
124
|
-
catch {
|
|
125
|
-
original = undefined;
|
|
126
|
-
}
|
|
127
|
-
return () => {
|
|
128
|
-
try {
|
|
129
|
-
if (original === undefined) {
|
|
130
|
-
fs.rmSync(file, { force: true });
|
|
131
|
-
}
|
|
132
|
-
else if (!fs.existsSync(file) || !fs.readFileSync(file).equals(original)) {
|
|
133
|
-
fs.writeFileSync(file, original, { mode: 0o600 });
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
catch {
|
|
137
|
-
// Best effort: OpenCode recreates its service record on start.
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
109
|
/**
|
|
142
110
|
* Paths that exist inside the worktree but must stay out of every commit.
|
|
143
111
|
*
|