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.
Files changed (175) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1547 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +584 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/commands/config.d.ts +7 -0
  7. package/dist/commands/config.js +49 -0
  8. package/dist/commands/config.js.map +1 -0
  9. package/dist/commands/context.d.ts +24 -0
  10. package/dist/commands/context.js +329 -0
  11. package/dist/commands/context.js.map +1 -0
  12. package/dist/commands/export.d.ts +19 -0
  13. package/dist/commands/export.js +116 -0
  14. package/dist/commands/export.js.map +1 -0
  15. package/dist/commands/import.d.ts +33 -0
  16. package/dist/commands/import.js +81 -0
  17. package/dist/commands/import.js.map +1 -0
  18. package/dist/commands/info.d.ts +19 -0
  19. package/dist/commands/info.js +235 -0
  20. package/dist/commands/info.js.map +1 -0
  21. package/dist/commands/init.d.ts +5 -0
  22. package/dist/commands/init.js +116 -0
  23. package/dist/commands/init.js.map +1 -0
  24. package/dist/commands/install.d.ts +119 -0
  25. package/dist/commands/install.js +533 -0
  26. package/dist/commands/install.js.map +1 -0
  27. package/dist/commands/list.d.ts +9 -0
  28. package/dist/commands/list.js +102 -0
  29. package/dist/commands/list.js.map +1 -0
  30. package/dist/commands/params.d.ts +58 -0
  31. package/dist/commands/params.js +366 -0
  32. package/dist/commands/params.js.map +1 -0
  33. package/dist/commands/refs.d.ts +60 -0
  34. package/dist/commands/refs.js +329 -0
  35. package/dist/commands/refs.js.map +1 -0
  36. package/dist/commands/registry.d.ts +18 -0
  37. package/dist/commands/registry.js +173 -0
  38. package/dist/commands/registry.js.map +1 -0
  39. package/dist/commands/status.d.ts +10 -0
  40. package/dist/commands/status.js +83 -0
  41. package/dist/commands/status.js.map +1 -0
  42. package/dist/commands/targets.d.ts +8 -0
  43. package/dist/commands/targets.js +61 -0
  44. package/dist/commands/targets.js.map +1 -0
  45. package/dist/commands/uninstall.d.ts +71 -0
  46. package/dist/commands/uninstall.js +322 -0
  47. package/dist/commands/uninstall.js.map +1 -0
  48. package/dist/commands/update.d.ts +66 -0
  49. package/dist/commands/update.js +384 -0
  50. package/dist/commands/update.js.map +1 -0
  51. package/dist/commands/validate.d.ts +3 -0
  52. package/dist/commands/validate.js +38 -0
  53. package/dist/commands/validate.js.map +1 -0
  54. package/dist/core/bundle.d.ts +49 -0
  55. package/dist/core/bundle.js +326 -0
  56. package/dist/core/bundle.js.map +1 -0
  57. package/dist/core/config.d.ts +65 -0
  58. package/dist/core/config.js +112 -0
  59. package/dist/core/config.js.map +1 -0
  60. package/dist/core/conflicts.d.ts +67 -0
  61. package/dist/core/conflicts.js +300 -0
  62. package/dist/core/conflicts.js.map +1 -0
  63. package/dist/core/context.d.ts +139 -0
  64. package/dist/core/context.js +432 -0
  65. package/dist/core/context.js.map +1 -0
  66. package/dist/core/deps.d.ts +62 -0
  67. package/dist/core/deps.js +339 -0
  68. package/dist/core/deps.js.map +1 -0
  69. package/dist/core/errors.d.ts +21 -0
  70. package/dist/core/errors.js +26 -0
  71. package/dist/core/errors.js.map +1 -0
  72. package/dist/core/executor.d.ts +9 -0
  73. package/dist/core/executor.js +139 -0
  74. package/dist/core/executor.js.map +1 -0
  75. package/dist/core/flavors.d.ts +128 -0
  76. package/dist/core/flavors.js +386 -0
  77. package/dist/core/flavors.js.map +1 -0
  78. package/dist/core/frontmatter.d.ts +6 -0
  79. package/dist/core/frontmatter.js +20 -0
  80. package/dist/core/frontmatter.js.map +1 -0
  81. package/dist/core/fsx.d.ts +40 -0
  82. package/dist/core/fsx.js +180 -0
  83. package/dist/core/fsx.js.map +1 -0
  84. package/dist/core/github.d.ts +37 -0
  85. package/dist/core/github.js +157 -0
  86. package/dist/core/github.js.map +1 -0
  87. package/dist/core/harnesses.d.ts +142 -0
  88. package/dist/core/harnesses.js +215 -0
  89. package/dist/core/harnesses.js.map +1 -0
  90. package/dist/core/hash.d.ts +12 -0
  91. package/dist/core/hash.js +34 -0
  92. package/dist/core/hash.js.map +1 -0
  93. package/dist/core/logger.d.ts +16 -0
  94. package/dist/core/logger.js +36 -0
  95. package/dist/core/logger.js.map +1 -0
  96. package/dist/core/overlap.d.ts +79 -0
  97. package/dist/core/overlap.js +155 -0
  98. package/dist/core/overlap.js.map +1 -0
  99. package/dist/core/parameters.d.ts +249 -0
  100. package/dist/core/parameters.js +944 -0
  101. package/dist/core/parameters.js.map +1 -0
  102. package/dist/core/paths.d.ts +20 -0
  103. package/dist/core/paths.js +35 -0
  104. package/dist/core/paths.js.map +1 -0
  105. package/dist/core/planner.d.ts +36 -0
  106. package/dist/core/planner.js +364 -0
  107. package/dist/core/planner.js.map +1 -0
  108. package/dist/core/prompt.d.ts +52 -0
  109. package/dist/core/prompt.js +197 -0
  110. package/dist/core/prompt.js.map +1 -0
  111. package/dist/core/refmap.d.ts +91 -0
  112. package/dist/core/refmap.js +331 -0
  113. package/dist/core/refmap.js.map +1 -0
  114. package/dist/core/refs.d.ts +297 -0
  115. package/dist/core/refs.js +801 -0
  116. package/dist/core/refs.js.map +1 -0
  117. package/dist/core/registry.d.ts +119 -0
  118. package/dist/core/registry.js +363 -0
  119. package/dist/core/registry.js.map +1 -0
  120. package/dist/core/rename.d.ts +36 -0
  121. package/dist/core/rename.js +74 -0
  122. package/dist/core/rename.js.map +1 -0
  123. package/dist/core/rollback.d.ts +38 -0
  124. package/dist/core/rollback.js +226 -0
  125. package/dist/core/rollback.js.map +1 -0
  126. package/dist/core/semver.d.ts +56 -0
  127. package/dist/core/semver.js +214 -0
  128. package/dist/core/semver.js.map +1 -0
  129. package/dist/core/state.d.ts +99 -0
  130. package/dist/core/state.js +196 -0
  131. package/dist/core/state.js.map +1 -0
  132. package/dist/core/store.d.ts +30 -0
  133. package/dist/core/store.js +54 -0
  134. package/dist/core/store.js.map +1 -0
  135. package/dist/core/types.d.ts +515 -0
  136. package/dist/core/types.js +49 -0
  137. package/dist/core/types.js.map +1 -0
  138. package/dist/index.d.ts +16 -0
  139. package/dist/index.js +16 -0
  140. package/dist/index.js.map +1 -0
  141. package/dist/merge/blocks.d.ts +48 -0
  142. package/dist/merge/blocks.js +0 -0
  143. package/dist/merge/blocks.js.map +1 -0
  144. package/dist/merge/json-merge.d.ts +66 -0
  145. package/dist/merge/json-merge.js +176 -0
  146. package/dist/merge/json-merge.js.map +1 -0
  147. package/dist/merge/toml.d.ts +48 -0
  148. package/dist/merge/toml.js +118 -0
  149. package/dist/merge/toml.js.map +1 -0
  150. package/dist/targets/claude-code.d.ts +11 -0
  151. package/dist/targets/claude-code.js +94 -0
  152. package/dist/targets/claude-code.js.map +1 -0
  153. package/dist/targets/copilot.d.ts +13 -0
  154. package/dist/targets/copilot.js +126 -0
  155. package/dist/targets/copilot.js.map +1 -0
  156. package/dist/targets/index.d.ts +20 -0
  157. package/dist/targets/index.js +60 -0
  158. package/dist/targets/index.js.map +1 -0
  159. package/dist/targets/opencode.d.ts +32 -0
  160. package/dist/targets/opencode.js +172 -0
  161. package/dist/targets/opencode.js.map +1 -0
  162. package/dist/targets/pi.d.ts +42 -0
  163. package/dist/targets/pi.js +134 -0
  164. package/dist/targets/pi.js.map +1 -0
  165. package/dist/targets/reasonix.d.ts +27 -0
  166. package/dist/targets/reasonix.js +192 -0
  167. package/dist/targets/reasonix.js.map +1 -0
  168. package/dist/targets/shared.d.ts +33 -0
  169. package/dist/targets/shared.js +109 -0
  170. package/dist/targets/shared.js.map +1 -0
  171. package/dist/targets/types.d.ts +40 -0
  172. package/dist/targets/types.js +17 -0
  173. package/dist/targets/types.js.map +1 -0
  174. package/docs/authoring-bundles.md +828 -0
  175. package/package.json +74 -0
@@ -0,0 +1,126 @@
1
+ import os from 'node:os';
2
+ import path from 'node:path';
3
+ import { blockId } from '../merge/blocks.js';
4
+ import { assetFile, markdownFile, settingsActions, skillFiles } from './shared.js';
5
+ import { toList } from './types.js';
6
+ /**
7
+ * GitHub Copilot.
8
+ * https://awesome-copilot.github.com/learning-hub/copilot-configuration-basics/
9
+ *
10
+ * .github/agents/<name>.agent.md .vscode/mcp.json -> servers.<name>
11
+ * .github/skills/<name>/** .github/copilot-instructions.md
12
+ * .github/prompts/<name>.prompt.md .github/copilot/settings.json
13
+ * .github/instructions/<name>.instructions.md
14
+ *
15
+ * User scope maps to ~/.copilot, which holds personal agents and skills.
16
+ */
17
+ export const copilot = {
18
+ id: 'copilot',
19
+ title: 'GitHub Copilot',
20
+ docs: 'https://awesome-copilot.github.com/learning-hub/copilot-configuration-basics/',
21
+ supports: ['subagent', 'skill', 'command', 'rule', 'context', 'mcp', 'settings', 'asset'],
22
+ scopeRoot(scope, cwd) {
23
+ return scope === 'user' ? path.join(os.homedir(), '.copilot') : cwd;
24
+ },
25
+ // `.github` on its own means nothing -- every repository has one -- so the
26
+ // markers are the directories inside it that only Copilot reads.
27
+ markers(scope) {
28
+ return scope === 'user'
29
+ ? ['.']
30
+ : [
31
+ '.github/agents',
32
+ '.github/prompts',
33
+ '.github/instructions',
34
+ '.github/skills',
35
+ '.github/copilot',
36
+ '.github/copilot-instructions.md',
37
+ '.vscode/mcp.json',
38
+ ];
39
+ },
40
+ actions(resource, ctx) {
41
+ // At user scope the root is already ~/.copilot, so we drop the .github prefix.
42
+ const base = ctx.scope === 'user' ? '' : '.github/';
43
+ switch (resource.kind) {
44
+ case 'subagent':
45
+ return [
46
+ markdownFile(`${base}agents/${resource.name}.agent.md`, resource, {
47
+ name: resource.name,
48
+ description: resource.frontmatter.description,
49
+ // Copilot agent files take a YAML list of tools.
50
+ tools: listOrUndefined(resource.frontmatter.tools),
51
+ model: resource.frontmatter.model,
52
+ }),
53
+ ];
54
+ case 'skill':
55
+ return skillFiles(resource, `${base}skills/${resource.name}`);
56
+ case 'command':
57
+ return [
58
+ markdownFile(`${base}prompts/${resource.name}.prompt.md`, resource, {
59
+ description: resource.frontmatter.description,
60
+ mode: resource.frontmatter.mode ?? 'agent',
61
+ tools: listOrUndefined(resource.frontmatter.allowedTools ?? resource.frontmatter.tools),
62
+ model: resource.frontmatter.model,
63
+ }),
64
+ ];
65
+ case 'rule': {
66
+ const globs = toList(resource.frontmatter.appliesTo ?? resource.frontmatter.paths);
67
+ return [
68
+ markdownFile(`${base}instructions/${resource.name}.instructions.md`, resource, {
69
+ description: resource.frontmatter.description,
70
+ // Copilot expects a single comma-separated glob string; '**' means all files.
71
+ applyTo: globs.length ? globs.join(', ') : '**',
72
+ }),
73
+ ];
74
+ }
75
+ case 'context':
76
+ return [
77
+ {
78
+ path: `${base}copilot-instructions.md`,
79
+ describe: `copilot-instructions.md ← ${resource.name}`,
80
+ payload: {
81
+ kind: 'block',
82
+ blockId: blockId(ctx.bundle, resource.name),
83
+ syntax: 'markdown',
84
+ body: resource.body ?? '',
85
+ },
86
+ },
87
+ ];
88
+ case 'mcp':
89
+ return [
90
+ {
91
+ // VS Code Copilot reads MCP servers from .vscode/mcp.json under `servers`.
92
+ path: ctx.scope === 'user' ? 'mcp.json' : '.vscode/mcp.json',
93
+ describe: `servers.${resource.name}`,
94
+ payload: {
95
+ kind: 'json-value',
96
+ pointer: ['servers', resource.name],
97
+ value: toCopilotServer(resource.data),
98
+ },
99
+ },
100
+ ];
101
+ case 'settings':
102
+ return settingsActions(resource, ctx.scope === 'user' ? 'config.json' : '.github/copilot/settings.json');
103
+ case 'asset':
104
+ return [assetFile(resource, `${base}assets/${resource.name}`)];
105
+ default:
106
+ return [];
107
+ }
108
+ },
109
+ };
110
+ function listOrUndefined(value) {
111
+ const list = toList(value);
112
+ return list.length ? list : undefined;
113
+ }
114
+ /**
115
+ * Copilot's MCP entries use `type: 'stdio' | 'http'` where Claude infers it
116
+ * from the presence of `command` vs `url`. Fill it in when it is missing.
117
+ */
118
+ function toCopilotServer(data) {
119
+ if (!data || typeof data !== 'object' || Array.isArray(data))
120
+ return data;
121
+ const server = { ...data };
122
+ if (!server.type)
123
+ server.type = typeof server.url === 'string' ? 'http' : 'stdio';
124
+ return server;
125
+ }
126
+ //# sourceMappingURL=copilot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copilot.js","sourceRoot":"","sources":["../../src/targets/copilot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEnF,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,OAAO,GAAW;IAC7B,EAAE,EAAE,SAAS;IACb,KAAK,EAAE,gBAAgB;IACvB,IAAI,EAAE,+EAA+E;IACrF,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,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACtE,CAAC;IAED,2EAA2E;IAC3E,iEAAiE;IACjE,OAAO,CAAC,KAAY;QAClB,OAAO,KAAK,KAAK,MAAM;YACrB,CAAC,CAAC,CAAC,GAAG,CAAC;YACP,CAAC,CAAC;gBACE,gBAAgB;gBAChB,iBAAiB;gBACjB,sBAAsB;gBACtB,gBAAgB;gBAChB,iBAAiB;gBACjB,iCAAiC;gBACjC,kBAAkB;aACnB,CAAC;IACR,CAAC;IAED,OAAO,CAAC,QAAwB,EAAE,GAAkB;QAClD,+EAA+E;QAC/E,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,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gBACE,OAAO,EAAE,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAC;AAEF,SAAS,eAAe,CAAC,KAAc;IACrC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACxC,CAAC;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,IAAa;IACpC,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1E,MAAM,MAAM,GAAG,EAAE,GAAI,IAAgC,EAAE,CAAC;IACxD,IAAI,CAAC,MAAM,CAAC,IAAI;QAAE,MAAM,CAAC,IAAI,GAAG,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAClF,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { TargetId } from '../core/types.js';
2
+ import type { Target } from './types.js';
3
+ export declare const TARGETS: Target[];
4
+ export declare const TARGET_IDS: TargetId[];
5
+ /**
6
+ * Turn whatever the user typed into a target id.
7
+ *
8
+ * Exact ids first, then the aliases, then any unambiguous prefix -- so `-t
9
+ * claude pi`, `-t reason op` and `-t claude-code` all say what they look like
10
+ * they say. A prefix matching two harnesses is an error naming both rather
11
+ * than a guess: `-t c` could be Claude Code or Copilot, and picking one would
12
+ * write a bundle into the wrong harness.
13
+ */
14
+ export declare function resolveTargetId(value: string): TargetId;
15
+ /**
16
+ * The adapter for a target. Accepts the same shorthands `resolveTargetId` does,
17
+ * so a name from the command line and an id from the ledger both work here.
18
+ */
19
+ export declare function getTarget(id: string): Target;
20
+ export type { Target } from './types.js';
@@ -0,0 +1,60 @@
1
+ import { HcmError } from '../core/errors.js';
2
+ import { claudeCode } from './claude-code.js';
3
+ import { copilot } from './copilot.js';
4
+ import { opencode } from './opencode.js';
5
+ import { pi } from './pi.js';
6
+ import { reasonix } from './reasonix.js';
7
+ export const TARGETS = [claudeCode, copilot, reasonix, opencode, pi];
8
+ export const TARGET_IDS = TARGETS.map((target) => target.id);
9
+ /**
10
+ * Names for a harness that are not its id.
11
+ *
12
+ * Ids are what the ledger records and what `hcm targets` prints, so they stay
13
+ * exactly as they are -- but nobody wants to type `claude-code` five times on
14
+ * one command line. Only names that could not mean anything else are here;
15
+ * everything else is left to the prefix matching below, which grows a new
16
+ * shorthand for free whenever a harness is added.
17
+ */
18
+ const TARGET_ALIASES = {
19
+ claude: 'claude-code',
20
+ cc: 'claude-code',
21
+ gh: 'copilot',
22
+ 'github-copilot': 'copilot',
23
+ oc: 'opencode',
24
+ };
25
+ /**
26
+ * Turn whatever the user typed into a target id.
27
+ *
28
+ * Exact ids first, then the aliases, then any unambiguous prefix -- so `-t
29
+ * claude pi`, `-t reason op` and `-t claude-code` all say what they look like
30
+ * they say. A prefix matching two harnesses is an error naming both rather
31
+ * than a guess: `-t c` could be Claude Code or Copilot, and picking one would
32
+ * write a bundle into the wrong harness.
33
+ */
34
+ export function resolveTargetId(value) {
35
+ const wanted = value.trim().toLowerCase();
36
+ const exact = TARGET_IDS.find((id) => id === wanted);
37
+ if (exact)
38
+ return exact;
39
+ const alias = TARGET_ALIASES[wanted];
40
+ if (alias)
41
+ return alias;
42
+ const prefixed = TARGET_IDS.filter((id) => id.startsWith(wanted));
43
+ if (prefixed.length === 1)
44
+ return prefixed[0];
45
+ if (prefixed.length > 1) {
46
+ throw new HcmError(`"${value}" matches more than one harness: ${prefixed.join(', ')}`, 'Type enough of the name to tell them apart.');
47
+ }
48
+ throw new HcmError(`Unknown target "${value}"`, `Known targets: ${TARGET_IDS.join(', ')}, or "all".\n` +
49
+ 'If that was meant to be a bundle, note that bundle names come before ' +
50
+ '--target, which takes every value after it.');
51
+ }
52
+ /**
53
+ * The adapter for a target. Accepts the same shorthands `resolveTargetId` does,
54
+ * so a name from the command line and an id from the ledger both work here.
55
+ */
56
+ export function getTarget(id) {
57
+ const resolved = resolveTargetId(id);
58
+ return TARGETS.find((candidate) => candidate.id === resolved);
59
+ }
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/targets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,MAAM,CAAC,MAAM,OAAO,GAAa,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;AAE/E,MAAM,CAAC,MAAM,UAAU,GAAe,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEzE;;;;;;;;GAQG;AACH,MAAM,cAAc,GAA6B;IAC/C,MAAM,EAAE,aAAa;IACrB,EAAE,EAAE,aAAa;IACjB,EAAE,EAAE,SAAS;IACb,gBAAgB,EAAE,SAAS;IAC3B,EAAE,EAAE,UAAU;CACf,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAE1C,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC;IACrD,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC;IAExB,MAAM,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC;IAExB,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IAClE,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC,CAAC,CAAa,CAAC;IAE1D,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,QAAQ,CAChB,IAAI,KAAK,oCAAoC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAClE,6CAA6C,CAC9C,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,QAAQ,CAChB,mBAAmB,KAAK,GAAG,EAC3B,kBAAkB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe;QACpD,uEAAuE;QACvE,6CAA6C,CAChD,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,EAAU;IAClC,MAAM,QAAQ,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC;IACrC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,QAAQ,CAAW,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { Target } from './types.js';
2
+ /**
3
+ * OpenCode.
4
+ * https://opencode.ai/docs/config/
5
+ *
6
+ * .opencode/agents/<name>.md opencode.json -> mcp.<name>
7
+ * .opencode/skills/<name>/** opencode.json -> instructions[]
8
+ * .opencode/commands/<name>.md AGENTS.md -> marker block
9
+ * .opencode/rules/<name>.md
10
+ *
11
+ * User scope is ~/.config/opencode, which mirrors the project layout without
12
+ * the `.opencode` prefix. Both scopes keep `opencode.json` at the root of the
13
+ * scope, and paths inside it resolve relative to that file -- which is what
14
+ * makes one `instructions` entry work unchanged in either scope.
15
+ *
16
+ * Two things differ from the other harnesses:
17
+ *
18
+ * - There is no glob-scoped rule format. Extra instruction files are listed in
19
+ * `instructions`, loaded whole, so a rule becomes a file *plus* an entry in
20
+ * that array -- appended, never replaced, so bundles do not fight over it.
21
+ * - Subagent tool access is a `permission` object keyed by OpenCode's own
22
+ * categories (edit, bash, read, ...), not a list of tool names, so a
23
+ * canonical `tools:` allowlist has no faithful translation and is dropped.
24
+ * Restrict tools in the target's own config if you need it.
25
+ */
26
+ export declare const opencode: Target;
27
+ /**
28
+ * OpenCode's config directory: `$OPENCODE_CONFIG_DIR`, else `opencode` under
29
+ * `$XDG_CONFIG_HOME`, else `~/.config/opencode` -- on Windows too, which is
30
+ * why this does not go looking at %APPDATA%.
31
+ */
32
+ export declare function opencodeHome(): string;
@@ -0,0 +1,172 @@
1
+ import os from 'node:os';
2
+ import path from 'node:path';
3
+ import { renderMarkdown } from '../core/frontmatter.js';
4
+ import { appliesToPrefix, assetFile, instructionBlock, markdownFile, settingsActions, skillFiles, } from './shared.js';
5
+ import { compact } from './types.js';
6
+ /**
7
+ * OpenCode.
8
+ * https://opencode.ai/docs/config/
9
+ *
10
+ * .opencode/agents/<name>.md opencode.json -> mcp.<name>
11
+ * .opencode/skills/<name>/** opencode.json -> instructions[]
12
+ * .opencode/commands/<name>.md AGENTS.md -> marker block
13
+ * .opencode/rules/<name>.md
14
+ *
15
+ * User scope is ~/.config/opencode, which mirrors the project layout without
16
+ * the `.opencode` prefix. Both scopes keep `opencode.json` at the root of the
17
+ * scope, and paths inside it resolve relative to that file -- which is what
18
+ * makes one `instructions` entry work unchanged in either scope.
19
+ *
20
+ * Two things differ from the other harnesses:
21
+ *
22
+ * - There is no glob-scoped rule format. Extra instruction files are listed in
23
+ * `instructions`, loaded whole, so a rule becomes a file *plus* an entry in
24
+ * that array -- appended, never replaced, so bundles do not fight over it.
25
+ * - Subagent tool access is a `permission` object keyed by OpenCode's own
26
+ * categories (edit, bash, read, ...), not a list of tool names, so a
27
+ * canonical `tools:` allowlist has no faithful translation and is dropped.
28
+ * Restrict tools in the target's own config if you need it.
29
+ */
30
+ export const opencode = {
31
+ id: 'opencode',
32
+ title: 'OpenCode',
33
+ docs: 'https://opencode.ai/docs/config/',
34
+ supports: ['subagent', 'skill', 'command', 'rule', 'context', 'mcp', 'settings', 'asset'],
35
+ scopeRoot(scope, cwd) {
36
+ return scope === 'user' ? opencodeHome() : cwd;
37
+ },
38
+ // Not `AGENTS.md`: Pi reads that too, so it identifies neither of them.
39
+ markers(scope) {
40
+ return scope === 'user' ? ['.'] : ['.opencode', 'opencode.json'];
41
+ },
42
+ actions(resource, ctx) {
43
+ // At user scope the root is already ~/.config/opencode, so the prefix goes.
44
+ const base = ctx.scope === 'user' ? '' : '.opencode/';
45
+ const configFile = 'opencode.json';
46
+ switch (resource.kind) {
47
+ // The filename is the agent id, so there is no `name` field to write.
48
+ case 'subagent':
49
+ return [
50
+ markdownFile(`${base}agents/${resource.name}.md`, resource, {
51
+ description: resource.frontmatter.description,
52
+ // Without this the file would define a primary agent -- one you Tab
53
+ // into -- rather than something a primary agent delegates to.
54
+ mode: 'subagent',
55
+ model: resource.frontmatter.model,
56
+ temperature: resource.frontmatter.temperature,
57
+ color: resource.frontmatter.color,
58
+ }),
59
+ ];
60
+ case 'skill':
61
+ return skillFiles(resource, `${base}skills/${resource.name}`);
62
+ // The body is the command template; `$ARGUMENTS` and `$1` work as they do
63
+ // in Claude Code, so it passes through untouched.
64
+ case 'command':
65
+ return [
66
+ markdownFile(`${base}commands/${resource.name}.md`, resource, {
67
+ description: resource.frontmatter.description,
68
+ agent: resource.frontmatter.agent,
69
+ model: resource.frontmatter.model,
70
+ subtask: resource.frontmatter.subtask,
71
+ }),
72
+ ];
73
+ case 'rule': {
74
+ const rulePath = `${base}rules/${resource.name}.md`;
75
+ return [
76
+ {
77
+ path: rulePath,
78
+ describe: rulePath,
79
+ payload: {
80
+ kind: 'file',
81
+ contents: renderMarkdown(compact({ description: resource.frontmatter.description }), appliesToPrefix(resource) + (resource.body ?? '')),
82
+ },
83
+ },
84
+ {
85
+ // An array item, so two bundles can list their own rules in the
86
+ // same config and each remove only its own on uninstall.
87
+ path: configFile,
88
+ describe: `instructions[] += ${rulePath}`,
89
+ payload: { kind: 'json-array-item', pointer: ['instructions'], items: [rulePath] },
90
+ },
91
+ ];
92
+ }
93
+ case 'context':
94
+ return [instructionBlock('AGENTS.md', ctx, resource.name, resource.name, resource.body ?? '')];
95
+ case 'mcp':
96
+ return [
97
+ {
98
+ path: configFile,
99
+ describe: `mcp.${resource.name}`,
100
+ payload: {
101
+ kind: 'json-value',
102
+ pointer: ['mcp', resource.name],
103
+ value: toMcpServer(resource.data),
104
+ },
105
+ },
106
+ ];
107
+ case 'settings':
108
+ return settingsActions(resource, configFile);
109
+ case 'asset':
110
+ return [assetFile(resource, `${base}assets/${resource.name}`)];
111
+ default:
112
+ return [];
113
+ }
114
+ },
115
+ };
116
+ /**
117
+ * OpenCode's config directory: `$OPENCODE_CONFIG_DIR`, else `opencode` under
118
+ * `$XDG_CONFIG_HOME`, else `~/.config/opencode` -- on Windows too, which is
119
+ * why this does not go looking at %APPDATA%.
120
+ */
121
+ export function opencodeHome() {
122
+ if (process.env.OPENCODE_CONFIG_DIR)
123
+ return process.env.OPENCODE_CONFIG_DIR;
124
+ const xdg = process.env.XDG_CONFIG_HOME;
125
+ const configRoot = xdg && xdg.trim() ? xdg : path.join(os.homedir(), '.config');
126
+ return path.join(configRoot, 'opencode');
127
+ }
128
+ function asRecord(value) {
129
+ return value && typeof value === 'object' && !Array.isArray(value)
130
+ ? value
131
+ : undefined;
132
+ }
133
+ /**
134
+ * Map a canonical MCP server definition onto OpenCode's shape:
135
+ *
136
+ * { "type": "local", "command": ["npx", "-y", "server"], "environment": {} }
137
+ * { "type": "remote", "url": "https://...", "headers": {} }
138
+ *
139
+ * Two differences from the Claude Code form. `type` is required rather than
140
+ * inferred from `command` vs `url`, and the command is one argv array rather
141
+ * than a command plus `args`. Environment variables are `environment`, not
142
+ * `env`; both spellings are accepted on the way in.
143
+ */
144
+ function toMcpServer(data) {
145
+ const server = asRecord(data);
146
+ if (!server)
147
+ return data;
148
+ if (typeof server.url === 'string') {
149
+ return compact({
150
+ type: 'remote',
151
+ url: server.url,
152
+ headers: server.headers,
153
+ enabled: server.enabled,
154
+ timeout: server.timeout,
155
+ });
156
+ }
157
+ const args = Array.isArray(server.args) ? server.args.map(String) : [];
158
+ const command = Array.isArray(server.command)
159
+ ? server.command.map(String)
160
+ : typeof server.command === 'string'
161
+ ? [server.command, ...args]
162
+ : undefined;
163
+ return compact({
164
+ type: 'local',
165
+ command,
166
+ cwd: server.cwd,
167
+ environment: server.environment ?? server.env,
168
+ enabled: server.enabled,
169
+ timeout: server.timeout,
170
+ });
171
+ }
172
+ //# sourceMappingURL=opencode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode.js","sourceRoot":"","sources":["../../src/targets/opencode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EACL,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,UAAU,GACX,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAW;IAC9B,EAAE,EAAE,UAAU;IACd,KAAK,EAAE,UAAU;IACjB,IAAI,EAAE,kCAAkC;IACxC,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC;IAEzF,SAAS,CAAC,KAA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G,KAAK,QAAQ,EAAE,CAAC;QACnC,OAAO,OAAO,CAAC;YACb,IAAI,EAAE,QAAQ;YACd,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACvE,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;QAC3C,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;QAC5B,CAAC,CAAC,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;YAClC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;YAC3B,CAAC,CAAC,SAAS,CAAC;IAEhB,OAAO,OAAO,CAAC;QACb,IAAI,EAAE,OAAO;QACb,OAAO;QACP,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,GAAG;QAC7C,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { Target } from './types.js';
2
+ /**
3
+ * Pi.
4
+ * https://pi.dev/docs/latest/quickstart
5
+ * Settings: docs/settings.md. Skills: docs/skills.md.
6
+ * Prompt templates: docs/prompt-templates.md.
7
+ *
8
+ * .pi/skills/<name>/** AGENTS.md -> marker block (context, rules)
9
+ * .pi/prompts/<name>.md .pi/settings.json
10
+ * .pi/agents/<name>.md .mcp.json -> mcpServers.<name>
11
+ * (subagents, with --pi-subagents)
12
+ *
13
+ * User scope is ~/.pi/agent, which mirrors the project layout without the `.pi`
14
+ * prefix -- and holds the global `AGENTS.md`, `skills/` and `prompts/`.
15
+ *
16
+ * Pi is deliberately smaller than the other harnesses: it ships no sub-agents
17
+ * and no built-in MCP client, leaving both to extensions (docs/usage.md). Both
18
+ * kinds still install, using the conventions those extensions build on:
19
+ *
20
+ * - A subagent becomes a skill, as it does on Reasonix -- `/skill:<name>`
21
+ * invokes it by name. Pi has no profile-level tool allowlist or model
22
+ * override to carry, so `tools` and `model` are dropped; and with no
23
+ * delegation the prompt runs in the main context rather than its own.
24
+ *
25
+ * Unless `pi-subagents` is installed, that is: with `--pi-subagents` the
26
+ * subagent is written to `.pi/agents/<name>.md` instead, which is the
27
+ * directory that extension scans, and `tools` and `model` survive because
28
+ * it has fields for them. Delegation is real there -- `subagent({ agent })`
29
+ * spawns a child session. https://github.com/nicobailon/pi-subagents
30
+ * - MCP servers go to the same `.mcp.json`, in the same `mcpServers` shape,
31
+ * that every other harness uses -- which is the convention Pi's MCP
32
+ * extensions read. Inert until one is installed, correct once it is.
33
+ *
34
+ * Like Reasonix, Pi has no per-file rule format either: standing instructions
35
+ * are the `AGENTS.md` hierarchy, so rules join context there.
36
+ */
37
+ export declare const pi: Target;
38
+ /**
39
+ * Pi's config directory: `$PI_CODING_AGENT_DIR`, else `~/.pi/agent`
40
+ * (docs/environment-variables.md).
41
+ */
42
+ export declare function piHome(): string;
@@ -0,0 +1,134 @@
1
+ import os from 'node:os';
2
+ import path from 'node:path';
3
+ import { appliesToPrefix, assetFile, instructionBlock, joinTools, markdownFile, settingsActions, skillFiles, } from './shared.js';
4
+ /**
5
+ * Pi.
6
+ * https://pi.dev/docs/latest/quickstart
7
+ * Settings: docs/settings.md. Skills: docs/skills.md.
8
+ * Prompt templates: docs/prompt-templates.md.
9
+ *
10
+ * .pi/skills/<name>/** AGENTS.md -> marker block (context, rules)
11
+ * .pi/prompts/<name>.md .pi/settings.json
12
+ * .pi/agents/<name>.md .mcp.json -> mcpServers.<name>
13
+ * (subagents, with --pi-subagents)
14
+ *
15
+ * User scope is ~/.pi/agent, which mirrors the project layout without the `.pi`
16
+ * prefix -- and holds the global `AGENTS.md`, `skills/` and `prompts/`.
17
+ *
18
+ * Pi is deliberately smaller than the other harnesses: it ships no sub-agents
19
+ * and no built-in MCP client, leaving both to extensions (docs/usage.md). Both
20
+ * kinds still install, using the conventions those extensions build on:
21
+ *
22
+ * - A subagent becomes a skill, as it does on Reasonix -- `/skill:<name>`
23
+ * invokes it by name. Pi has no profile-level tool allowlist or model
24
+ * override to carry, so `tools` and `model` are dropped; and with no
25
+ * delegation the prompt runs in the main context rather than its own.
26
+ *
27
+ * Unless `pi-subagents` is installed, that is: with `--pi-subagents` the
28
+ * subagent is written to `.pi/agents/<name>.md` instead, which is the
29
+ * directory that extension scans, and `tools` and `model` survive because
30
+ * it has fields for them. Delegation is real there -- `subagent({ agent })`
31
+ * spawns a child session. https://github.com/nicobailon/pi-subagents
32
+ * - MCP servers go to the same `.mcp.json`, in the same `mcpServers` shape,
33
+ * that every other harness uses -- which is the convention Pi's MCP
34
+ * extensions read. Inert until one is installed, correct once it is.
35
+ *
36
+ * Like Reasonix, Pi has no per-file rule format either: standing instructions
37
+ * are the `AGENTS.md` hierarchy, so rules join context there.
38
+ */
39
+ export const pi = {
40
+ id: 'pi',
41
+ title: 'Pi',
42
+ docs: 'https://pi.dev/docs/latest/quickstart',
43
+ supports: ['subagent', 'skill', 'command', 'rule', 'context', 'mcp', 'settings', 'asset'],
44
+ notes: [
45
+ 'subagents install as skills; pass --pi-subagents if the pi-subagents',
46
+ 'extension is installed and they will go to agents/ instead',
47
+ ],
48
+ scopeRoot(scope, cwd) {
49
+ return scope === 'user' ? piHome() : cwd;
50
+ },
51
+ // Everything else Pi uses in a project -- `AGENTS.md`, `.mcp.json` -- it
52
+ // shares with another harness, so `.pi` is the only thing that means Pi.
53
+ markers(scope) {
54
+ return scope === 'user' ? ['.'] : ['.pi'];
55
+ },
56
+ actions(resource, ctx) {
57
+ // At user scope the root is already ~/.pi/agent, so the prefix goes.
58
+ const base = ctx.scope === 'user' ? '' : '.pi/';
59
+ switch (resource.kind) {
60
+ // Stock Pi has no agents directory: a subagent is filed as a skill,
61
+ // sharing the directory and the file format. Pi follows the Agent Skills
62
+ // standard (docs/skills.md), whose frontmatter is just `name` and
63
+ // `description` -- so nothing else from the subagent's frontmatter has a
64
+ // home here. With `pi-subagents` installed there is somewhere better.
65
+ case 'subagent':
66
+ return ctx.options.piSubagents
67
+ ? [
68
+ markdownFile(`${base}agents/${resource.name}.md`, resource, {
69
+ name: resource.name,
70
+ description: resource.frontmatter.description,
71
+ // The extension takes a comma-separated list or a YAML block
72
+ // list; the comma form matches what Claude Code is given.
73
+ tools: joinTools(resource.frontmatter.tools),
74
+ model: resource.frontmatter.model,
75
+ }),
76
+ ]
77
+ : [
78
+ markdownFile(`${base}skills/${resource.name}/SKILL.md`, resource, {
79
+ name: resource.name,
80
+ description: resource.frontmatter.description,
81
+ }),
82
+ ];
83
+ case 'skill':
84
+ return skillFiles(resource, `${base}skills/${resource.name}`);
85
+ // Pi calls these prompt templates: `/<name>` expands the body, with the
86
+ // same `$1` / `$ARGUMENTS` substitution the other harnesses use.
87
+ case 'command':
88
+ return [
89
+ markdownFile(`${base}prompts/${resource.name}.md`, resource, {
90
+ description: resource.frontmatter.description,
91
+ 'argument-hint': resource.frontmatter.argumentHint ?? resource.frontmatter['argument-hint'],
92
+ }),
93
+ ];
94
+ case 'rule':
95
+ return [
96
+ instructionBlock('AGENTS.md', ctx, `rules/${resource.name}`, resource.name, appliesToPrefix(resource) + (resource.body ?? '')),
97
+ ];
98
+ case 'context':
99
+ return [instructionBlock('AGENTS.md', ctx, resource.name, resource.name, resource.body ?? '')];
100
+ // Pi has no MCP client of its own, but the extensions that add one read
101
+ // the shared `.mcp.json` convention, so the definition is written as-is.
102
+ // At user scope that is `.mcp.json` inside the Pi config directory, which
103
+ // is where Pi resolves its other relative resource paths from.
104
+ case 'mcp':
105
+ return [
106
+ {
107
+ path: '.mcp.json',
108
+ describe: `mcpServers.${resource.name}`,
109
+ payload: {
110
+ kind: 'json-value',
111
+ pointer: ['mcpServers', resource.name],
112
+ value: resource.data,
113
+ },
114
+ },
115
+ ];
116
+ case 'settings':
117
+ return settingsActions(resource, `${base}settings.json`);
118
+ case 'asset':
119
+ return [assetFile(resource, `${base}assets/${resource.name}`)];
120
+ default:
121
+ return [];
122
+ }
123
+ },
124
+ };
125
+ /**
126
+ * Pi's config directory: `$PI_CODING_AGENT_DIR`, else `~/.pi/agent`
127
+ * (docs/environment-variables.md).
128
+ */
129
+ export function piHome() {
130
+ if (process.env.PI_CODING_AGENT_DIR)
131
+ return process.env.PI_CODING_AGENT_DIR;
132
+ return path.join(os.homedir(), '.pi', 'agent');
133
+ }
134
+ //# sourceMappingURL=pi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.js","sourceRoot":"","sources":["../../src/targets/pi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,eAAe,EACf,UAAU,GACX,MAAM,aAAa,CAAC;AAGrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,EAAE,GAAW;IACxB,EAAE,EAAE,IAAI;IACR,KAAK,EAAE,IAAI;IACX,IAAI,EAAE,uCAAuC;IAC7C,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC;IACzF,KAAK,EAAE;QACL,sEAAsE;QACtE,4DAA4D;KAC7D;IAED,SAAS,CAAC,KAAY,EAAE,GAAW;QACjC,OAA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ACV,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,IAAI,UAAU,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YAEjE;gBACE,OAAO,EAAE,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,MAAM;IACpB,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAC5E,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { Target } from './types.js';
2
+ /**
3
+ * Reasonix.
4
+ * https://github.com/esengine/DeepSeek-Reasonix/blob/main-v2/docs/GUIDE.md
5
+ * Config schema: docs/SPEC.md section 5 (Configuration TOML).
6
+ * Paths: docs/CONFIG_PATHS.md. Subagents: docs/SUBAGENT_PROFILES.md.
7
+ *
8
+ * .reasonix/skills/<name>/** REASONIX.md -> marker block (context, rules)
9
+ * .reasonix/commands/<name>.md reasonix.toml -> [[plugins]] (MCP)
10
+ * reasonix.toml -> [tables] (settings)
11
+ *
12
+ * Two things differ from the other harnesses:
13
+ *
14
+ * - There is no agents directory. A subagent is a Skill carrying
15
+ * `runAs: subagent`, so subagents and skills share `skills/`.
16
+ * - There is no per-file rule format either -- standing instructions are the
17
+ * REASONIX.md hierarchy -- so rules join context in REASONIX.md.
18
+ *
19
+ * Reasonix keeps its config in TOML, which has comments -- so unlike the JSON
20
+ * targets we write marker-delimited blocks and never rewrite the whole file.
21
+ */
22
+ export declare const reasonix: Target;
23
+ /**
24
+ * Reasonix home: %AppData%\reasonix on Windows, ~/.reasonix elsewhere,
25
+ * overridden by REASONIX_HOME (docs/CONFIG_PATHS.md).
26
+ */
27
+ export declare function reasonixHome(): string;