harness-config-manager 0.1.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/LICENSE +21 -0
- package/README.md +1547 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +584 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/config.d.ts +7 -0
- package/dist/commands/config.js +49 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/context.d.ts +24 -0
- package/dist/commands/context.js +329 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/export.d.ts +19 -0
- package/dist/commands/export.js +116 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/import.d.ts +33 -0
- package/dist/commands/import.js +81 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/info.d.ts +19 -0
- package/dist/commands/info.js +235 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.js +116 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/install.d.ts +119 -0
- package/dist/commands/install.js +533 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/list.d.ts +9 -0
- package/dist/commands/list.js +102 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/params.d.ts +58 -0
- package/dist/commands/params.js +366 -0
- package/dist/commands/params.js.map +1 -0
- package/dist/commands/refs.d.ts +60 -0
- package/dist/commands/refs.js +329 -0
- package/dist/commands/refs.js.map +1 -0
- package/dist/commands/registry.d.ts +18 -0
- package/dist/commands/registry.js +173 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/commands/status.d.ts +10 -0
- package/dist/commands/status.js +83 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/targets.d.ts +8 -0
- package/dist/commands/targets.js +61 -0
- package/dist/commands/targets.js.map +1 -0
- package/dist/commands/uninstall.d.ts +71 -0
- package/dist/commands/uninstall.js +322 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/commands/update.d.ts +66 -0
- package/dist/commands/update.js +384 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/validate.d.ts +3 -0
- package/dist/commands/validate.js +38 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/core/bundle.d.ts +49 -0
- package/dist/core/bundle.js +326 -0
- package/dist/core/bundle.js.map +1 -0
- package/dist/core/config.d.ts +65 -0
- package/dist/core/config.js +112 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/conflicts.d.ts +67 -0
- package/dist/core/conflicts.js +300 -0
- package/dist/core/conflicts.js.map +1 -0
- package/dist/core/context.d.ts +139 -0
- package/dist/core/context.js +432 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/deps.d.ts +62 -0
- package/dist/core/deps.js +339 -0
- package/dist/core/deps.js.map +1 -0
- package/dist/core/errors.d.ts +21 -0
- package/dist/core/errors.js +26 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/executor.d.ts +9 -0
- package/dist/core/executor.js +139 -0
- package/dist/core/executor.js.map +1 -0
- package/dist/core/flavors.d.ts +128 -0
- package/dist/core/flavors.js +386 -0
- package/dist/core/flavors.js.map +1 -0
- package/dist/core/frontmatter.d.ts +6 -0
- package/dist/core/frontmatter.js +20 -0
- package/dist/core/frontmatter.js.map +1 -0
- package/dist/core/fsx.d.ts +40 -0
- package/dist/core/fsx.js +180 -0
- package/dist/core/fsx.js.map +1 -0
- package/dist/core/github.d.ts +37 -0
- package/dist/core/github.js +157 -0
- package/dist/core/github.js.map +1 -0
- package/dist/core/harnesses.d.ts +142 -0
- package/dist/core/harnesses.js +215 -0
- package/dist/core/harnesses.js.map +1 -0
- package/dist/core/hash.d.ts +12 -0
- package/dist/core/hash.js +34 -0
- package/dist/core/hash.js.map +1 -0
- package/dist/core/logger.d.ts +16 -0
- package/dist/core/logger.js +36 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/overlap.d.ts +79 -0
- package/dist/core/overlap.js +155 -0
- package/dist/core/overlap.js.map +1 -0
- package/dist/core/parameters.d.ts +249 -0
- package/dist/core/parameters.js +944 -0
- package/dist/core/parameters.js.map +1 -0
- package/dist/core/paths.d.ts +20 -0
- package/dist/core/paths.js +35 -0
- package/dist/core/paths.js.map +1 -0
- package/dist/core/planner.d.ts +36 -0
- package/dist/core/planner.js +364 -0
- package/dist/core/planner.js.map +1 -0
- package/dist/core/prompt.d.ts +52 -0
- package/dist/core/prompt.js +197 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/core/refmap.d.ts +91 -0
- package/dist/core/refmap.js +331 -0
- package/dist/core/refmap.js.map +1 -0
- package/dist/core/refs.d.ts +297 -0
- package/dist/core/refs.js +801 -0
- package/dist/core/refs.js.map +1 -0
- package/dist/core/registry.d.ts +119 -0
- package/dist/core/registry.js +363 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/rename.d.ts +36 -0
- package/dist/core/rename.js +74 -0
- package/dist/core/rename.js.map +1 -0
- package/dist/core/rollback.d.ts +38 -0
- package/dist/core/rollback.js +226 -0
- package/dist/core/rollback.js.map +1 -0
- package/dist/core/semver.d.ts +56 -0
- package/dist/core/semver.js +214 -0
- package/dist/core/semver.js.map +1 -0
- package/dist/core/state.d.ts +99 -0
- package/dist/core/state.js +196 -0
- package/dist/core/state.js.map +1 -0
- package/dist/core/store.d.ts +30 -0
- package/dist/core/store.js +54 -0
- package/dist/core/store.js.map +1 -0
- package/dist/core/types.d.ts +515 -0
- package/dist/core/types.js +49 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/merge/blocks.d.ts +48 -0
- package/dist/merge/blocks.js +0 -0
- package/dist/merge/blocks.js.map +1 -0
- package/dist/merge/json-merge.d.ts +66 -0
- package/dist/merge/json-merge.js +176 -0
- package/dist/merge/json-merge.js.map +1 -0
- package/dist/merge/toml.d.ts +48 -0
- package/dist/merge/toml.js +118 -0
- package/dist/merge/toml.js.map +1 -0
- package/dist/targets/claude-code.d.ts +11 -0
- package/dist/targets/claude-code.js +94 -0
- package/dist/targets/claude-code.js.map +1 -0
- package/dist/targets/copilot.d.ts +13 -0
- package/dist/targets/copilot.js +126 -0
- package/dist/targets/copilot.js.map +1 -0
- package/dist/targets/index.d.ts +20 -0
- package/dist/targets/index.js +60 -0
- package/dist/targets/index.js.map +1 -0
- package/dist/targets/opencode.d.ts +32 -0
- package/dist/targets/opencode.js +172 -0
- package/dist/targets/opencode.js.map +1 -0
- package/dist/targets/pi.d.ts +42 -0
- package/dist/targets/pi.js +134 -0
- package/dist/targets/pi.js.map +1 -0
- package/dist/targets/reasonix.d.ts +27 -0
- package/dist/targets/reasonix.js +192 -0
- package/dist/targets/reasonix.js.map +1 -0
- package/dist/targets/shared.d.ts +33 -0
- package/dist/targets/shared.js +109 -0
- package/dist/targets/shared.js.map +1 -0
- package/dist/targets/types.d.ts +40 -0
- package/dist/targets/types.js +17 -0
- package/dist/targets/types.js.map +1 -0
- package/docs/authoring-bundles.md +828 -0
- package/package.json +74 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural merge into JSON documents.
|
|
3
|
+
*
|
|
4
|
+
* JSON has no comments, so we cannot leave markers behind. Instead every write
|
|
5
|
+
* is recorded as (pointer, hash-of-written-value). On uninstall we resolve the
|
|
6
|
+
* pointer in the *current* file and only remove the item when it still hashes
|
|
7
|
+
* to what we wrote. That survives reformatting, key reordering and other
|
|
8
|
+
* bundles adding sibling keys, and it refuses to clobber edits the user made
|
|
9
|
+
* by hand.
|
|
10
|
+
*/
|
|
11
|
+
export type JsonObject = Record<string, unknown>;
|
|
12
|
+
/** Read a value at a pointer, or `undefined` when any segment is missing. */
|
|
13
|
+
export declare function getAtPointer(root: unknown, pointer: string[]): unknown;
|
|
14
|
+
export declare function hasPointer(root: unknown, pointer: string[]): boolean;
|
|
15
|
+
export interface SetResult {
|
|
16
|
+
/** The value previously stored at the pointer, when there was one. */
|
|
17
|
+
previous?: unknown;
|
|
18
|
+
hadPrevious: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Set a value at a pointer, creating intermediate objects as needed.
|
|
22
|
+
* Mutates `root`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function setAtPointer(root: JsonObject, pointer: string[], value: unknown): SetResult;
|
|
25
|
+
/**
|
|
26
|
+
* Remove a value at a pointer, but only when it still matches `expectedHash`.
|
|
27
|
+
* Returns what happened so callers can report honestly.
|
|
28
|
+
*/
|
|
29
|
+
export type RemoveOutcome = 'removed' | 'restored' | 'missing' | 'modified';
|
|
30
|
+
export declare function removeAtPointer(root: JsonObject, pointer: string[], expectedHash: string, options?: {
|
|
31
|
+
restore?: unknown;
|
|
32
|
+
hadPrevious?: boolean;
|
|
33
|
+
force?: boolean;
|
|
34
|
+
}): RemoveOutcome;
|
|
35
|
+
/**
|
|
36
|
+
* Append items to an array at a pointer, skipping values already present.
|
|
37
|
+
* Used for additive lists such as permission allow-lists.
|
|
38
|
+
*/
|
|
39
|
+
export declare function appendArrayItems(root: JsonObject, pointer: string[], items: unknown[]): {
|
|
40
|
+
appended: unknown[];
|
|
41
|
+
};
|
|
42
|
+
/** Remove array items whose canonical hash matches any of `hashes`. */
|
|
43
|
+
export declare function removeArrayItems(root: JsonObject, pointer: string[], hashes: string[]): {
|
|
44
|
+
removed: number;
|
|
45
|
+
missing: number;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* After removing an item, delete any now-empty containers above it, innermost
|
|
49
|
+
* first, so uninstalling does not leave `{"mcpServers": {}}` behind.
|
|
50
|
+
*
|
|
51
|
+
* An empty object or array carries no configuration, so this is information
|
|
52
|
+
* preserving -- and unlike tracking which containers we created at install
|
|
53
|
+
* time, it stays correct across reinstalls.
|
|
54
|
+
*/
|
|
55
|
+
export declare function pruneEmptyAncestors(root: JsonObject, pointer: string[]): void;
|
|
56
|
+
/**
|
|
57
|
+
* Flatten a settings fragment into leaf pointers.
|
|
58
|
+
*
|
|
59
|
+
* Objects are walked; arrays and primitives are treated as leaves so that each
|
|
60
|
+
* one becomes an independently revocable receipt. `arrayPointers` marks the
|
|
61
|
+
* pointers whose arrays should be appended to rather than replaced.
|
|
62
|
+
*/
|
|
63
|
+
export declare function flattenLeaves(fragment: unknown, basePointer?: string[]): {
|
|
64
|
+
pointer: string[];
|
|
65
|
+
value: unknown;
|
|
66
|
+
}[];
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural merge into JSON documents.
|
|
3
|
+
*
|
|
4
|
+
* JSON has no comments, so we cannot leave markers behind. Instead every write
|
|
5
|
+
* is recorded as (pointer, hash-of-written-value). On uninstall we resolve the
|
|
6
|
+
* pointer in the *current* file and only remove the item when it still hashes
|
|
7
|
+
* to what we wrote. That survives reformatting, key reordering and other
|
|
8
|
+
* bundles adding sibling keys, and it refuses to clobber edits the user made
|
|
9
|
+
* by hand.
|
|
10
|
+
*/
|
|
11
|
+
import { hashValue, valuesEqual } from '../core/hash.js';
|
|
12
|
+
/** Read a value at a pointer, or `undefined` when any segment is missing. */
|
|
13
|
+
export function getAtPointer(root, pointer) {
|
|
14
|
+
let current = root;
|
|
15
|
+
for (const key of pointer) {
|
|
16
|
+
if (!current || typeof current !== 'object' || Array.isArray(current))
|
|
17
|
+
return undefined;
|
|
18
|
+
current = current[key];
|
|
19
|
+
}
|
|
20
|
+
return current;
|
|
21
|
+
}
|
|
22
|
+
export function hasPointer(root, pointer) {
|
|
23
|
+
let current = root;
|
|
24
|
+
for (let i = 0; i < pointer.length; i += 1) {
|
|
25
|
+
const key = pointer[i];
|
|
26
|
+
if (!current || typeof current !== 'object' || Array.isArray(current))
|
|
27
|
+
return false;
|
|
28
|
+
if (!Object.prototype.hasOwnProperty.call(current, key))
|
|
29
|
+
return false;
|
|
30
|
+
current = current[key];
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Set a value at a pointer, creating intermediate objects as needed.
|
|
36
|
+
* Mutates `root`.
|
|
37
|
+
*/
|
|
38
|
+
export function setAtPointer(root, pointer, value) {
|
|
39
|
+
if (pointer.length === 0)
|
|
40
|
+
throw new Error('setAtPointer requires a non-empty pointer');
|
|
41
|
+
let current = root;
|
|
42
|
+
for (let i = 0; i < pointer.length - 1; i += 1) {
|
|
43
|
+
const key = pointer[i];
|
|
44
|
+
const existing = current[key];
|
|
45
|
+
if (!existing || typeof existing !== 'object' || Array.isArray(existing))
|
|
46
|
+
current[key] = {};
|
|
47
|
+
current = current[key];
|
|
48
|
+
}
|
|
49
|
+
const leaf = pointer[pointer.length - 1];
|
|
50
|
+
const hadPrevious = Object.prototype.hasOwnProperty.call(current, leaf);
|
|
51
|
+
const previous = hadPrevious ? current[leaf] : undefined;
|
|
52
|
+
current[leaf] = value;
|
|
53
|
+
return hadPrevious ? { previous, hadPrevious } : { hadPrevious };
|
|
54
|
+
}
|
|
55
|
+
export function removeAtPointer(root, pointer, expectedHash, options = {}) {
|
|
56
|
+
const parentPointer = pointer.slice(0, -1);
|
|
57
|
+
const leaf = pointer[pointer.length - 1];
|
|
58
|
+
const parent = getAtPointer(root, parentPointer);
|
|
59
|
+
if (!parent || typeof parent !== 'object' || Array.isArray(parent))
|
|
60
|
+
return 'missing';
|
|
61
|
+
const parentObject = parent;
|
|
62
|
+
if (!Object.prototype.hasOwnProperty.call(parentObject, leaf))
|
|
63
|
+
return 'missing';
|
|
64
|
+
const currentHash = hashValue(parentObject[leaf]);
|
|
65
|
+
if (currentHash !== expectedHash && !options.force)
|
|
66
|
+
return 'modified';
|
|
67
|
+
if (options.hadPrevious) {
|
|
68
|
+
parentObject[leaf] = options.restore;
|
|
69
|
+
return 'restored';
|
|
70
|
+
}
|
|
71
|
+
delete parentObject[leaf];
|
|
72
|
+
return 'removed';
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Append items to an array at a pointer, skipping values already present.
|
|
76
|
+
* Used for additive lists such as permission allow-lists.
|
|
77
|
+
*/
|
|
78
|
+
export function appendArrayItems(root, pointer, items) {
|
|
79
|
+
let current = root;
|
|
80
|
+
for (let i = 0; i < pointer.length - 1; i += 1) {
|
|
81
|
+
const key = pointer[i];
|
|
82
|
+
const existing = current[key];
|
|
83
|
+
if (!existing || typeof existing !== 'object' || Array.isArray(existing))
|
|
84
|
+
current[key] = {};
|
|
85
|
+
current = current[key];
|
|
86
|
+
}
|
|
87
|
+
const leaf = pointer[pointer.length - 1];
|
|
88
|
+
if (!Array.isArray(current[leaf]))
|
|
89
|
+
current[leaf] = [];
|
|
90
|
+
const array = current[leaf];
|
|
91
|
+
const appended = [];
|
|
92
|
+
for (const item of items) {
|
|
93
|
+
if (array.some((existing) => valuesEqual(existing, item)))
|
|
94
|
+
continue;
|
|
95
|
+
array.push(item);
|
|
96
|
+
appended.push(item);
|
|
97
|
+
}
|
|
98
|
+
return { appended };
|
|
99
|
+
}
|
|
100
|
+
/** Remove array items whose canonical hash matches any of `hashes`. */
|
|
101
|
+
export function removeArrayItems(root, pointer, hashes) {
|
|
102
|
+
const target = getAtPointer(root, pointer);
|
|
103
|
+
if (!Array.isArray(target))
|
|
104
|
+
return { removed: 0, missing: hashes.length };
|
|
105
|
+
const wanted = new Set(hashes);
|
|
106
|
+
let removed = 0;
|
|
107
|
+
const kept = target.filter((item) => {
|
|
108
|
+
const itemHash = hashValue(item);
|
|
109
|
+
if (wanted.has(itemHash)) {
|
|
110
|
+
wanted.delete(itemHash);
|
|
111
|
+
removed += 1;
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
});
|
|
116
|
+
target.length = 0;
|
|
117
|
+
target.push(...kept);
|
|
118
|
+
return { removed, missing: wanted.size };
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* After removing an item, delete any now-empty containers above it, innermost
|
|
122
|
+
* first, so uninstalling does not leave `{"mcpServers": {}}` behind.
|
|
123
|
+
*
|
|
124
|
+
* An empty object or array carries no configuration, so this is information
|
|
125
|
+
* preserving -- and unlike tracking which containers we created at install
|
|
126
|
+
* time, it stays correct across reinstalls.
|
|
127
|
+
*/
|
|
128
|
+
export function pruneEmptyAncestors(root, pointer) {
|
|
129
|
+
for (let depth = pointer.length; depth > 0; depth -= 1) {
|
|
130
|
+
const current = pointer.slice(0, depth);
|
|
131
|
+
const value = getAtPointer(root, current);
|
|
132
|
+
// The leaf itself is normally already gone; keep walking up from there.
|
|
133
|
+
if (value !== undefined) {
|
|
134
|
+
const isEmpty = (Array.isArray(value) && value.length === 0) ||
|
|
135
|
+
(typeof value === 'object' &&
|
|
136
|
+
value !== null &&
|
|
137
|
+
!Array.isArray(value) &&
|
|
138
|
+
Object.keys(value).length === 0);
|
|
139
|
+
if (!isEmpty)
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const parent = getAtPointer(root, current.slice(0, -1));
|
|
143
|
+
if (!parent || typeof parent !== 'object' || Array.isArray(parent))
|
|
144
|
+
return;
|
|
145
|
+
delete parent[current[current.length - 1]];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Flatten a settings fragment into leaf pointers.
|
|
150
|
+
*
|
|
151
|
+
* Objects are walked; arrays and primitives are treated as leaves so that each
|
|
152
|
+
* one becomes an independently revocable receipt. `arrayPointers` marks the
|
|
153
|
+
* pointers whose arrays should be appended to rather than replaced.
|
|
154
|
+
*/
|
|
155
|
+
export function flattenLeaves(fragment, basePointer = []) {
|
|
156
|
+
if (!fragment || typeof fragment !== 'object' || Array.isArray(fragment)) {
|
|
157
|
+
return basePointer.length ? [{ pointer: basePointer, value: fragment }] : [];
|
|
158
|
+
}
|
|
159
|
+
const out = [];
|
|
160
|
+
for (const [key, value] of Object.entries(fragment)) {
|
|
161
|
+
const pointer = [...basePointer, key];
|
|
162
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
163
|
+
const nested = flattenLeaves(value, pointer);
|
|
164
|
+
// An empty object is itself a meaningful leaf.
|
|
165
|
+
if (nested.length === 0)
|
|
166
|
+
out.push({ pointer, value });
|
|
167
|
+
else
|
|
168
|
+
out.push(...nested);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
out.push({ pointer, value });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return out;
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=json-merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-merge.js","sourceRoot":"","sources":["../../src/merge/json-merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAIzD,6EAA6E;AAC7E,MAAM,UAAU,YAAY,CAAC,IAAa,EAAE,OAAiB;IAC3D,IAAI,OAAO,GAAY,IAAI,CAAC;IAC5B,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;YAAE,OAAO,SAAS,CAAC;QACxF,OAAO,GAAI,OAAsB,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAa,EAAE,OAAiB;IACzD,IAAI,OAAO,GAAY,IAAI,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAW,CAAC;QACjC,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;YAAE,OAAO,KAAK,CAAC;QACpF,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EA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AG,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;;gBACjD,GAAG,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TOML support, used by the Reasonix target.
|
|
3
|
+
*
|
|
4
|
+
* We deliberately do *not* parse-modify-restringify: that would discard the
|
|
5
|
+
* user's comments and formatting across the whole file. Instead we append a
|
|
6
|
+
* comment-delimited marker block (see blocks.ts) containing only our own
|
|
7
|
+
* tables, and use parsing purely to detect conflicts before writing.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseToml(text: string): Record<string, unknown>;
|
|
10
|
+
/** Parse, tolerating an unreadable file by reporting it rather than throwing. */
|
|
11
|
+
export declare function tryParseToml(text: string): {
|
|
12
|
+
ok: true;
|
|
13
|
+
value: Record<string, unknown>;
|
|
14
|
+
} | {
|
|
15
|
+
ok: false;
|
|
16
|
+
error: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Render a fragment as TOML text (no markers -- the caller wraps it).
|
|
20
|
+
* Nested objects become sub-tables, which is the idiomatic form for the
|
|
21
|
+
* settings tables the Reasonix spec documents ([permissions], [tools.shell]).
|
|
22
|
+
*/
|
|
23
|
+
export declare function renderToml(fragment: Record<string, unknown>): string;
|
|
24
|
+
/**
|
|
25
|
+
* Render one `[[plugins]]`-style array-of-tables entry.
|
|
26
|
+
*
|
|
27
|
+
* Array-of-tables entries are always safe to append: repeating the header adds
|
|
28
|
+
* an element rather than redefining a table.
|
|
29
|
+
*
|
|
30
|
+
* Nested objects are written as *inline* tables (`env = { FOO = "bar" }`)
|
|
31
|
+
* rather than sub-tables (`[plugins.env]`). Both parse identically, but a
|
|
32
|
+
* sub-table binds to whichever `[[plugins]]` header precedes it, so anything
|
|
33
|
+
* inserted between the two would silently reattach it to the wrong server.
|
|
34
|
+
* Inline tables keep each entry self-contained -- which matters here, because
|
|
35
|
+
* these entries live inside marker blocks added and removed independently.
|
|
36
|
+
* It is also the form the spec documents.
|
|
37
|
+
*/
|
|
38
|
+
export declare function renderArrayOfTables(tableName: string, entry: Record<string, unknown>): string;
|
|
39
|
+
/** Names already used by entries of an array-of-tables, by their `name` key. */
|
|
40
|
+
export declare function existingArrayEntryNames(doc: Record<string, unknown>, tableName: string): string[];
|
|
41
|
+
/**
|
|
42
|
+
* Top-level table names in a fragment that are already defined in the document.
|
|
43
|
+
*
|
|
44
|
+
* TOML forbids defining the same table twice, so appending `[permissions]` to a
|
|
45
|
+
* file that already has one produces an invalid document. We detect that up
|
|
46
|
+
* front and surface it as a conflict instead of writing a broken file.
|
|
47
|
+
*/
|
|
48
|
+
export declare function collidingTables(doc: Record<string, unknown>, fragment: Record<string, unknown>): string[];
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TOML support, used by the Reasonix target.
|
|
3
|
+
*
|
|
4
|
+
* We deliberately do *not* parse-modify-restringify: that would discard the
|
|
5
|
+
* user's comments and formatting across the whole file. Instead we append a
|
|
6
|
+
* comment-delimited marker block (see blocks.ts) containing only our own
|
|
7
|
+
* tables, and use parsing purely to detect conflicts before writing.
|
|
8
|
+
*/
|
|
9
|
+
import { parse as parseTomlText, stringify as stringifyToml } from 'smol-toml';
|
|
10
|
+
export function parseToml(text) {
|
|
11
|
+
return parseTomlText(text);
|
|
12
|
+
}
|
|
13
|
+
/** Parse, tolerating an unreadable file by reporting it rather than throwing. */
|
|
14
|
+
export function tryParseToml(text) {
|
|
15
|
+
try {
|
|
16
|
+
return { ok: true, value: parseToml(text) };
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
return { ok: false, error: error.message };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Render a fragment as TOML text (no markers -- the caller wraps it).
|
|
24
|
+
* Nested objects become sub-tables, which is the idiomatic form for the
|
|
25
|
+
* settings tables the Reasonix spec documents ([permissions], [tools.shell]).
|
|
26
|
+
*/
|
|
27
|
+
export function renderToml(fragment) {
|
|
28
|
+
return stringifyToml(fragment).trim();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Render one `[[plugins]]`-style array-of-tables entry.
|
|
32
|
+
*
|
|
33
|
+
* Array-of-tables entries are always safe to append: repeating the header adds
|
|
34
|
+
* an element rather than redefining a table.
|
|
35
|
+
*
|
|
36
|
+
* Nested objects are written as *inline* tables (`env = { FOO = "bar" }`)
|
|
37
|
+
* rather than sub-tables (`[plugins.env]`). Both parse identically, but a
|
|
38
|
+
* sub-table binds to whichever `[[plugins]]` header precedes it, so anything
|
|
39
|
+
* inserted between the two would silently reattach it to the wrong server.
|
|
40
|
+
* Inline tables keep each entry self-contained -- which matters here, because
|
|
41
|
+
* these entries live inside marker blocks added and removed independently.
|
|
42
|
+
* It is also the form the spec documents.
|
|
43
|
+
*/
|
|
44
|
+
export function renderArrayOfTables(tableName, entry) {
|
|
45
|
+
const lines = [`[[${tableName}]]`];
|
|
46
|
+
for (const [key, value] of Object.entries(entry)) {
|
|
47
|
+
if (value === undefined)
|
|
48
|
+
continue;
|
|
49
|
+
lines.push(`${renderKey(key)} = ${renderValue(value)}`);
|
|
50
|
+
}
|
|
51
|
+
return lines.join('\n');
|
|
52
|
+
}
|
|
53
|
+
/** Bare key where TOML allows it, quoted otherwise. */
|
|
54
|
+
function renderKey(key) {
|
|
55
|
+
return /^[A-Za-z0-9_-]+$/.test(key) ? key : renderString(key);
|
|
56
|
+
}
|
|
57
|
+
// Control characters that have no shorthand escape in a TOML basic string.
|
|
58
|
+
const CONTROL_CHARS = /[\u0000-\u001f\u007f]/g;
|
|
59
|
+
function renderString(value) {
|
|
60
|
+
const escaped = value
|
|
61
|
+
.replace(/\\/g, '\\\\')
|
|
62
|
+
.replace(/"/g, '\\"')
|
|
63
|
+
.replace(/\n/g, '\\n')
|
|
64
|
+
.replace(/\r/g, '\\r')
|
|
65
|
+
.replace(/\t/g, '\\t')
|
|
66
|
+
.replace(CONTROL_CHARS, (character) => `\\u${character.charCodeAt(0).toString(16).padStart(4, '0')}`);
|
|
67
|
+
return `"${escaped}"`;
|
|
68
|
+
}
|
|
69
|
+
function renderValue(value) {
|
|
70
|
+
if (typeof value === 'string')
|
|
71
|
+
return renderString(value);
|
|
72
|
+
if (typeof value === 'boolean')
|
|
73
|
+
return value ? 'true' : 'false';
|
|
74
|
+
if (typeof value === 'number') {
|
|
75
|
+
if (!Number.isFinite(value))
|
|
76
|
+
throw new Error(`Cannot write ${value} to TOML`);
|
|
77
|
+
return String(value);
|
|
78
|
+
}
|
|
79
|
+
if (Array.isArray(value)) {
|
|
80
|
+
if (value.length === 0)
|
|
81
|
+
return '[]';
|
|
82
|
+
return `[ ${value.map((item) => renderValue(item)).join(', ')} ]`;
|
|
83
|
+
}
|
|
84
|
+
if (value && typeof value === 'object') {
|
|
85
|
+
const entries = Object.entries(value).filter(([, nested]) => nested !== undefined);
|
|
86
|
+
if (entries.length === 0)
|
|
87
|
+
return '{}';
|
|
88
|
+
const rendered = entries.map(([key, nested]) => `${renderKey(key)} = ${renderValue(nested)}`);
|
|
89
|
+
return `{ ${rendered.join(', ')} }`;
|
|
90
|
+
}
|
|
91
|
+
throw new Error(`Cannot write value of type ${typeof value} to TOML`);
|
|
92
|
+
}
|
|
93
|
+
/** Names already used by entries of an array-of-tables, by their `name` key. */
|
|
94
|
+
export function existingArrayEntryNames(doc, tableName) {
|
|
95
|
+
const table = doc[tableName];
|
|
96
|
+
if (!Array.isArray(table))
|
|
97
|
+
return [];
|
|
98
|
+
return table
|
|
99
|
+
.map((entry) => entry && typeof entry === 'object' ? entry.name : undefined)
|
|
100
|
+
.filter((name) => typeof name === 'string');
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Top-level table names in a fragment that are already defined in the document.
|
|
104
|
+
*
|
|
105
|
+
* TOML forbids defining the same table twice, so appending `[permissions]` to a
|
|
106
|
+
* file that already has one produces an invalid document. We detect that up
|
|
107
|
+
* front and surface it as a conflict instead of writing a broken file.
|
|
108
|
+
*/
|
|
109
|
+
export function collidingTables(doc, fragment) {
|
|
110
|
+
return Object.keys(fragment).filter((key) => {
|
|
111
|
+
const existing = doc[key];
|
|
112
|
+
// Array-of-tables can always be extended.
|
|
113
|
+
if (Array.isArray(existing) && Array.isArray(fragment[key]))
|
|
114
|
+
return false;
|
|
115
|
+
return existing !== undefined;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=toml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toml.js","sourceRoot":"","sources":["../../src/merge/toml.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,IAAI,aAAa,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/E,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,aAAa,CAAC,IAAI,CAA4B,CAAC;AACxD,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,YAAY,CAC1B,IAAY;IAEZ,IAAI,CAAC;QACH,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC;IACxD,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,QAAiC;IAC1D,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;;;GAa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ED,MAAM,IAAI,KAAK,CAAC,8BAA8B,OAAO,KAAK,UAAU,CAAC,CAAC;AACxE,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,uBAAuB,CACrC,GAA4B,EAC5B,SAAiB;IAEjB,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC;IAC7B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,OAAO,KAAK;SACT,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACb,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAE,KAAiC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CACzF;SACA,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,GAA4B,EAC5B,QAAiC;IAEjC,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;QAC1C,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QAC1B,0CAA0C;QAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QAC1E,OAAO,QAAQ,KAAK,SAAS,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Target } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Claude Code.
|
|
4
|
+
* https://code.claude.com/docs/en/claude-directory
|
|
5
|
+
*
|
|
6
|
+
* .claude/agents/<name>.md .mcp.json -> mcpServers.<name>
|
|
7
|
+
* .claude/skills/<name>/** CLAUDE.md -> marker block
|
|
8
|
+
* .claude/commands/<name>.md .claude/settings.json
|
|
9
|
+
* .claude/rules/<name>.md
|
|
10
|
+
*/
|
|
11
|
+
export declare const claudeCode: Target;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import { blockId } from '../merge/blocks.js';
|
|
3
|
+
import { assetFile, joinTools, markdownFile, settingsActions, skillFiles } from './shared.js';
|
|
4
|
+
import { toList } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Claude Code.
|
|
7
|
+
* https://code.claude.com/docs/en/claude-directory
|
|
8
|
+
*
|
|
9
|
+
* .claude/agents/<name>.md .mcp.json -> mcpServers.<name>
|
|
10
|
+
* .claude/skills/<name>/** CLAUDE.md -> marker block
|
|
11
|
+
* .claude/commands/<name>.md .claude/settings.json
|
|
12
|
+
* .claude/rules/<name>.md
|
|
13
|
+
*/
|
|
14
|
+
export const claudeCode = {
|
|
15
|
+
id: 'claude-code',
|
|
16
|
+
title: 'Claude Code',
|
|
17
|
+
docs: 'https://code.claude.com/docs/en/claude-directory',
|
|
18
|
+
supports: ['subagent', 'skill', 'command', 'rule', 'context', 'mcp', 'settings', 'asset'],
|
|
19
|
+
scopeRoot(scope, cwd) {
|
|
20
|
+
return scope === 'user' ? os.homedir() : cwd;
|
|
21
|
+
},
|
|
22
|
+
// User scope is the home directory itself, so only `.claude` identifies it
|
|
23
|
+
// there. `.mcp.json` is deliberately absent: Pi reads the same file.
|
|
24
|
+
markers(scope) {
|
|
25
|
+
return scope === 'user' ? ['.claude'] : ['.claude', 'CLAUDE.md'];
|
|
26
|
+
},
|
|
27
|
+
actions(resource, ctx) {
|
|
28
|
+
switch (resource.kind) {
|
|
29
|
+
case 'subagent':
|
|
30
|
+
return [
|
|
31
|
+
markdownFile(`.claude/agents/${resource.name}.md`, resource, {
|
|
32
|
+
name: resource.name,
|
|
33
|
+
description: resource.frontmatter.description,
|
|
34
|
+
// Claude Code expects a comma-separated string, not a YAML list.
|
|
35
|
+
tools: joinTools(resource.frontmatter.tools),
|
|
36
|
+
model: resource.frontmatter.model,
|
|
37
|
+
}),
|
|
38
|
+
];
|
|
39
|
+
case 'skill':
|
|
40
|
+
return skillFiles(resource, `.claude/skills/${resource.name}`);
|
|
41
|
+
case 'command':
|
|
42
|
+
return [
|
|
43
|
+
markdownFile(`.claude/commands/${resource.name}.md`, resource, {
|
|
44
|
+
description: resource.frontmatter.description,
|
|
45
|
+
'argument-hint': resource.frontmatter.argumentHint ?? resource.frontmatter['argument-hint'],
|
|
46
|
+
'allowed-tools': joinTools(resource.frontmatter.allowedTools ?? resource.frontmatter['allowed-tools']),
|
|
47
|
+
}),
|
|
48
|
+
];
|
|
49
|
+
case 'rule': {
|
|
50
|
+
const paths = toList(resource.frontmatter.appliesTo ?? resource.frontmatter.paths);
|
|
51
|
+
return [
|
|
52
|
+
markdownFile(`.claude/rules/${resource.name}.md`, resource, {
|
|
53
|
+
description: resource.frontmatter.description,
|
|
54
|
+
// A rule without `paths:` loads at session start.
|
|
55
|
+
paths: paths.length ? paths : undefined,
|
|
56
|
+
}),
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
case 'context':
|
|
60
|
+
return [
|
|
61
|
+
{
|
|
62
|
+
path: ctx.scope === 'user' ? '.claude/CLAUDE.md' : 'CLAUDE.md',
|
|
63
|
+
describe: `CLAUDE.md ← ${resource.name}`,
|
|
64
|
+
payload: {
|
|
65
|
+
kind: 'block',
|
|
66
|
+
blockId: blockId(ctx.bundle, resource.name),
|
|
67
|
+
syntax: 'markdown',
|
|
68
|
+
body: resource.body ?? '',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
case 'mcp':
|
|
73
|
+
return [
|
|
74
|
+
{
|
|
75
|
+
// Project servers live in .mcp.json; user-level ones in ~/.claude.json.
|
|
76
|
+
path: ctx.scope === 'user' ? '.claude.json' : '.mcp.json',
|
|
77
|
+
describe: `mcpServers.${resource.name}`,
|
|
78
|
+
payload: {
|
|
79
|
+
kind: 'json-value',
|
|
80
|
+
pointer: ['mcpServers', resource.name],
|
|
81
|
+
value: resource.data,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
case 'settings':
|
|
86
|
+
return settingsActions(resource, '.claude/settings.json');
|
|
87
|
+
case 'asset':
|
|
88
|
+
return [assetFile(resource, `.claude/${resource.name}`)];
|
|
89
|
+
default:
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=claude-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code.js","sourceRoot":"","sources":["../../src/targets/claude-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9F,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,UAAU,GAAW;IAChC,EAAE,EAAE,aAAa;IACjB,KAAK,EAAE,aAAa;IACpB,IAAI,EAAE,kDAAkD;IACxD,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC;IAEzF,SAAS,CAAC,KAAY,EAAE,GAAW;QACjC,OAAO,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IAC/C,CAAC;IAED,2EAA2E;IAC3E,qEAAqE;IACrE,OAAO,CAAC,KAAY;QAClB,OAAO,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,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 @@
|
|
|
1
|
+
import type { Target } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* GitHub Copilot.
|
|
4
|
+
* https://awesome-copilot.github.com/learning-hub/copilot-configuration-basics/
|
|
5
|
+
*
|
|
6
|
+
* .github/agents/<name>.agent.md .vscode/mcp.json -> servers.<name>
|
|
7
|
+
* .github/skills/<name>/** .github/copilot-instructions.md
|
|
8
|
+
* .github/prompts/<name>.prompt.md .github/copilot/settings.json
|
|
9
|
+
* .github/instructions/<name>.instructions.md
|
|
10
|
+
*
|
|
11
|
+
* User scope maps to ~/.copilot, which holds personal agents and skills.
|
|
12
|
+
*/
|
|
13
|
+
export declare const copilot: Target;
|