orbitmap 0.4.0-next.0 → 0.4.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 +148 -45
- package/dist/adapters/cloud.d.ts +36 -3
- package/dist/adapters/cloud.js +79 -17
- package/dist/adapters/cloud.js.map +1 -1
- package/dist/adapters/factory.d.ts +8 -4
- package/dist/adapters/factory.js +9 -5
- package/dist/adapters/factory.js.map +1 -1
- package/dist/adapters/local/context.d.ts +4 -3
- package/dist/adapters/local/context.js +4 -3
- package/dist/adapters/local/context.js.map +1 -1
- package/dist/commands/assign.js +9 -4
- package/dist/commands/assign.js.map +1 -1
- package/dist/commands/create.js +1 -6
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/ideas.js +1 -6
- package/dist/commands/ideas.js.map +1 -1
- package/dist/commands/init.d.ts +28 -0
- package/dist/commands/init.js +248 -132
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/issues.js +1 -6
- package/dist/commands/issues.js.map +1 -1
- package/dist/commands/setup-agent.d.ts +16 -0
- package/dist/commands/setup-agent.js +38 -5
- package/dist/commands/setup-agent.js.map +1 -1
- package/dist/commands/setup-mcp.js +13 -42
- package/dist/commands/setup-mcp.js.map +1 -1
- package/dist/commands/task.js +3 -13
- package/dist/commands/task.js.map +1 -1
- package/dist/config.d.ts +69 -17
- package/dist/config.js +206 -32
- package/dist/config.js.map +1 -1
- package/dist/doc-cache.d.ts +21 -1
- package/dist/doc-cache.js +72 -12
- package/dist/doc-cache.js.map +1 -1
- package/dist/id-resolve.d.ts +61 -0
- package/dist/id-resolve.js +87 -0
- package/dist/id-resolve.js.map +1 -0
- package/dist/index.js +26 -12
- package/dist/index.js.map +1 -1
- package/dist/mcp-config.d.ts +36 -0
- package/dist/mcp-config.js +51 -0
- package/dist/mcp-config.js.map +1 -0
- package/dist/oauth.d.ts +8 -0
- package/dist/oauth.js +54 -15
- package/dist/oauth.js.map +1 -1
- package/dist/paths.d.ts +97 -0
- package/dist/paths.js +178 -0
- package/dist/paths.js.map +1 -0
- package/dist/project-config.d.ts +75 -0
- package/dist/project-config.js +55 -0
- package/dist/project-config.js.map +1 -0
- package/dist/workspace-resolve.d.ts +56 -24
- package/dist/workspace-resolve.js +106 -25
- package/dist/workspace-resolve.js.map +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,20 @@ const AGENTS = {
|
|
|
10
10
|
windsurf: { label: 'Windsurf', file: '.windsurfrules' },
|
|
11
11
|
generic: { label: 'Other / Generic', file: 'AGENTS.md' },
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Menu order for "which agent are you using?" — shared with `init`, which asks the same
|
|
15
|
+
* question through its own readline interface (see the note on {@link pickAgent}).
|
|
16
|
+
* The first entry is also the documented default when a caller needs one.
|
|
17
|
+
*/
|
|
18
|
+
export const AGENT_MENU_ORDER = [
|
|
19
|
+
'claude',
|
|
20
|
+
'gemini',
|
|
21
|
+
'codex',
|
|
22
|
+
'cursor',
|
|
23
|
+
'windsurf',
|
|
24
|
+
'generic',
|
|
25
|
+
];
|
|
26
|
+
const MENU_ORDER = [...AGENT_MENU_ORDER];
|
|
14
27
|
// Where the Claude skills are installed (project-level skill directory).
|
|
15
28
|
const SKILLS_ROOT = path.join('.claude', 'skills');
|
|
16
29
|
/** Relative path of a skill's SKILL.md, e.g. `.claude/skills/orbitmap/SKILL.md`. */
|
|
@@ -149,6 +162,26 @@ function setupGeneric(cwd, agentType) {
|
|
|
149
162
|
export function agentLabel(agentType) {
|
|
150
163
|
return AGENTS[agentType].label;
|
|
151
164
|
}
|
|
165
|
+
/** The config file an agent type's instruction block is written to (e.g. `CLAUDE.md`). */
|
|
166
|
+
export function agentConfigFile(agentType) {
|
|
167
|
+
return AGENTS[agentType].file;
|
|
168
|
+
}
|
|
169
|
+
/** Every accepted `--agent` value, in menu order, for help text and error messages. */
|
|
170
|
+
export function agentTypeNames() {
|
|
171
|
+
return AGENT_MENU_ORDER.join(', ');
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Parse a user-supplied `--agent` value. Returns `null` for anything unknown so the
|
|
175
|
+
* caller can print its own error — `init` and `setup-agent` both accept the flag and
|
|
176
|
+
* must reject the same set of values the same way.
|
|
177
|
+
*/
|
|
178
|
+
export function parseAgentType(value) {
|
|
179
|
+
const key = value.trim().toLowerCase();
|
|
180
|
+
// `in` would also match inherited members, so `--agent constructor` (or `tostring`,
|
|
181
|
+
// `valueof`, `__proto__`) would parse as a valid type and then blow up in `path.join`
|
|
182
|
+
// with an `undefined` filename. Own properties only.
|
|
183
|
+
return Object.hasOwn(AGENTS, key) ? key : null;
|
|
184
|
+
}
|
|
152
185
|
/**
|
|
153
186
|
* Install the OrbitMap skills for one agent, non-interactively and idempotently.
|
|
154
187
|
* Claude Code → `.claude/skills/<name>/SKILL.md` × 4 + the CLAUDE.md hook block;
|
|
@@ -167,13 +200,13 @@ export function installAgentSkills(cwd, agentType) {
|
|
|
167
200
|
export async function setupAgentCommand(options) {
|
|
168
201
|
let agentType;
|
|
169
202
|
if (options.agent) {
|
|
170
|
-
const
|
|
171
|
-
if (!
|
|
172
|
-
console.error(`Error: Unknown agent type "${options.agent}". Valid types: ${
|
|
203
|
+
const parsed = parseAgentType(options.agent);
|
|
204
|
+
if (!parsed) {
|
|
205
|
+
console.error(`Error: Unknown agent type "${options.agent}". Valid types: ${agentTypeNames()}`);
|
|
173
206
|
process.exitCode = 1;
|
|
174
207
|
return;
|
|
175
208
|
}
|
|
176
|
-
agentType =
|
|
209
|
+
agentType = parsed;
|
|
177
210
|
}
|
|
178
211
|
else {
|
|
179
212
|
const detected = detectAgent();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-agent.js","sourceRoot":"","sources":["../../src/commands/setup-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,QAAQ,MAAM,eAA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,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,CAAC,KAAK,CAAC,8BAA8B,OAAO,CAAC,KAAK,mBAAmB,cAAc,EAAE,EAAE,CAAC,CAAC;YAChG,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACrB,OAAO;QACT,CAAC;QACD,SAAS,GAAG,MAAM,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;QAC/B,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,qBAAqB,CAAC,CAAC;YACrF,IAAI,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,EAAE,CAAC;gBACjC,SAAS,GAAG,MAAM,SAAS,EAAE,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,SAAS,GAAG,QAAQ,CAAC;YACvB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,SAAS,GAAG,MAAM,SAAS,EAAE,CAAC;QAChC,CAAC;IACH,CAAC;IAED,kBAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import readline from 'node:readline';
|
|
4
|
-
import { validateProfile
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const GITIGNORE_FILE = '.gitignore';
|
|
4
|
+
import { validateProfile } from '../oauth.js';
|
|
5
|
+
import { ensureGitignore } from '../doc-cache.js';
|
|
6
|
+
import { buildOrbitmapBlock, maskBlockForPrint, MCP_FILE, } from '../mcp-config.js';
|
|
8
7
|
async function prompt(question, defaultValue) {
|
|
9
8
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
10
9
|
return new Promise((resolve) => {
|
|
@@ -53,32 +52,6 @@ async function promptAuthMethod() {
|
|
|
53
52
|
console.log('Please enter 1 or 2.');
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
|
-
function buildMcpUrl(profile) {
|
|
57
|
-
const profilePath = profileToPath(profile);
|
|
58
|
-
return profilePath === '/' ? `${MCP_BASE_URL}/` : `${MCP_BASE_URL}${profilePath}`;
|
|
59
|
-
}
|
|
60
|
-
function buildOrbitmapBlock(params) {
|
|
61
|
-
const url = buildMcpUrl(params.profile);
|
|
62
|
-
if (params.token) {
|
|
63
|
-
const headers = {
|
|
64
|
-
Authorization: `Bearer ${params.token}`,
|
|
65
|
-
};
|
|
66
|
-
if (params.areaSlug) {
|
|
67
|
-
headers['X-Orbitmap-Area'] = params.areaSlug;
|
|
68
|
-
}
|
|
69
|
-
return { type: 'http', url, headers };
|
|
70
|
-
}
|
|
71
|
-
return { type: 'http', url };
|
|
72
|
-
}
|
|
73
|
-
function maskBlockForPrint(block) {
|
|
74
|
-
if (!block.headers)
|
|
75
|
-
return block;
|
|
76
|
-
const maskedHeaders = { ...block.headers };
|
|
77
|
-
if (maskedHeaders.Authorization?.startsWith('Bearer ')) {
|
|
78
|
-
maskedHeaders.Authorization = 'Bearer orbitmap_****';
|
|
79
|
-
}
|
|
80
|
-
return { ...block, headers: maskedHeaders };
|
|
81
|
-
}
|
|
82
55
|
function loadMcpConfig(filePath) {
|
|
83
56
|
if (!fs.existsSync(filePath)) {
|
|
84
57
|
return { config: { mcpServers: {} }, existed: false };
|
|
@@ -100,16 +73,6 @@ function loadMcpConfig(filePath) {
|
|
|
100
73
|
}
|
|
101
74
|
return { config, existed: true };
|
|
102
75
|
}
|
|
103
|
-
function gitignoreCoversMcpFile(cwd) {
|
|
104
|
-
const gitignorePath = path.join(cwd, GITIGNORE_FILE);
|
|
105
|
-
if (!fs.existsSync(gitignorePath))
|
|
106
|
-
return false;
|
|
107
|
-
const content = fs.readFileSync(gitignorePath, 'utf-8');
|
|
108
|
-
return content
|
|
109
|
-
.split(/\r?\n/)
|
|
110
|
-
.map((line) => line.trim())
|
|
111
|
-
.some((line) => line === MCP_FILE || line === `/${MCP_FILE}`);
|
|
112
|
-
}
|
|
113
76
|
export async function setupMcpCommand(options = {}) {
|
|
114
77
|
if (options.token && options.oauth) {
|
|
115
78
|
console.error('Error: --token and --oauth are mutually exclusive.');
|
|
@@ -193,8 +156,16 @@ export async function setupMcpCommand(options = {}) {
|
|
|
193
156
|
console.log(`\nFile: ${mcpFilePath}`);
|
|
194
157
|
console.log(`Profile: ${profile} | URL: ${block.url}`);
|
|
195
158
|
console.log('\n"orbitmap": ' + JSON.stringify(maskBlockForPrint(block), null, 2));
|
|
196
|
-
if (authMode === 'token'
|
|
197
|
-
|
|
159
|
+
if (authMode === 'token') {
|
|
160
|
+
// .mcp.json now carries a Bearer token — write it into .gitignore rather than just
|
|
161
|
+
// warning about it (the warning here used to be the whole mitigation, and it was
|
|
162
|
+
// routinely ignored: this same file pattern is committed with its token in
|
|
163
|
+
// orbitmap-mcp today). `ensureGitignore` is idempotent and reports what it actually
|
|
164
|
+
// wrote, so a re-run stays quiet instead of claiming an edit it did not make.
|
|
165
|
+
const added = ensureGitignore([MCP_FILE], cwd);
|
|
166
|
+
if (added.length > 0) {
|
|
167
|
+
console.log(`Added ${MCP_FILE} to .gitignore (it contains a Bearer token).`);
|
|
168
|
+
}
|
|
198
169
|
}
|
|
199
170
|
}
|
|
200
171
|
//# sourceMappingURL=setup-mcp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-mcp.js","sourceRoot":"","sources":["../../src/commands/setup-mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,eAAe,
|
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E,QAAQ,EAAE,KAAK,EAAE,CAAC;IAE9D,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;IAE/E,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;IAClD,CAAC;SAAM,IAAI,OAAO,EAAE,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,WAAW,QAAQ,0BAA0B,CAAC,CAAC;IAC7D,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,WAAW,QAAQ,uBAAuB,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,WAAW,WAAW,EAAE,CAAC,CAAC;IACtC,OAAO,CAAC,GAAG,CAAC,YAAY,OAAO,WAAW,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IACvD,OAAO,CAAC,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAElF,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,mFAAmF;QACnF,iFAAiF;QACjF,2EAA2E;QAC3E,oFAAoF;QACpF,8EAA8E;QAC9E,MAAM,KAAK,GAAG,eAAe,CAAC,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;QAC/C,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,OAAO,CAAC,GAAG,CAAC,SAAS,QAAQ,8CAA8C,CAAC,CAAC;QAC/E,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/commands/task.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { createAdapter } from '../adapters/factory.js';
|
|
2
2
|
import { formatOutput, printError, formatTable } from '../output.js';
|
|
3
|
-
function isObjectNumber(id) {
|
|
4
|
-
return /^([A-Z]{2}-)?[a-z0-9]{6}$/.test(id);
|
|
5
|
-
}
|
|
6
|
-
function stripPrefix(id) {
|
|
7
|
-
return id.replace(/^[A-Z]{2}-/, '');
|
|
8
|
-
}
|
|
9
3
|
function formatDocLine(d) {
|
|
10
4
|
let line = `${d.title} (${d.type}`;
|
|
11
5
|
if (d.sections_count !== undefined)
|
|
@@ -79,13 +73,9 @@ export function printTaskDetail(response) {
|
|
|
79
73
|
export async function taskCommand(idOrNumber, options) {
|
|
80
74
|
try {
|
|
81
75
|
const client = await createAdapter(options.area);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
response = (await client.getTask(idOrNumber));
|
|
88
|
-
}
|
|
76
|
+
// `getTask` accepts a uuid, `TS-uw9yh5` or the bare code and routes a by-number reference
|
|
77
|
+
// to the by-number endpoint itself — one request either way (see `id-resolve.ts`).
|
|
78
|
+
const response = (await client.getTask(idOrNumber));
|
|
89
79
|
if (options.json) {
|
|
90
80
|
console.log(formatOutput(response, true));
|
|
91
81
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/commands/task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAuErE,SAAS,
|
|
1
|
+
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/commands/task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAuErE,SAAS,aAAa,CAAC,CAAW;IAChC,IAAI,IAAI,GAAG,GAAG,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC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OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;YAC1C,OAAO;QACT,CAAC;QAED,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAChC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,22 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
1
|
+
import { type OrbitMapConfig } from './project-config.js';
|
|
2
|
+
/**
|
|
3
|
+
* The **global** `~/.orbitmap/config.json`: loading it, migrating it forward, saving it,
|
|
4
|
+
* and resolving cloud credentials from it. The config *schema* and the project-scoped
|
|
5
|
+
* `.orbitmap/config.json` walk-up live in `project-config.ts`; the paths themselves live in
|
|
6
|
+
* `paths.ts`. See `docs/adr/0002-project-scoped-config.md`.
|
|
7
|
+
*/
|
|
8
|
+
export type { OrbitMapConfig, OrbitMapMode } from './project-config.js';
|
|
9
|
+
export { resolveProjectConfigField, type ResolvedProjectField } from './project-config.js';
|
|
10
|
+
/**
|
|
11
|
+
* Version stamped into every config file this module writes (ADR 0002). It is also the
|
|
12
|
+
* migration gate: a global config already carrying this version has been through
|
|
13
|
+
* {@link migrateGlobalConfig} and is never re-examined, on this run or any later one.
|
|
14
|
+
*/
|
|
15
|
+
export declare const CURRENT_SCHEMA_VERSION = 1;
|
|
16
|
+
/**
|
|
17
|
+
* The only supported Agent API host. Every default in the CLI resolves here — do not
|
|
18
|
+
* hardcode a base URL anywhere else, and never ship a hosting-provider origin
|
|
19
|
+
* (it lets callers bypass whatever fronts the public domain).
|
|
20
|
+
*/
|
|
21
|
+
export declare const DEFAULT_API_HOST = "https://app.orbitmap.ai";
|
|
22
|
+
/** Default Agent API base URL: {@link DEFAULT_API_HOST} + the `/api/agent` prefix. */
|
|
23
|
+
export declare const DEFAULT_API_URL = "https://app.orbitmap.ai/api/agent";
|
|
24
|
+
/** Reset the once-per-process migration latch. Tests only. */
|
|
25
|
+
export declare function resetConfigMigrationForTests(): void;
|
|
26
|
+
/** Load `~/.orbitmap/config.json` (or the XDG/legacy equivalent). Runs the one-time
|
|
27
|
+
* migration in {@link migrateGlobalConfig} as a side effect. */
|
|
14
28
|
export declare function loadConfig(): Promise<OrbitMapConfig>;
|
|
15
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Write the global `~/.orbitmap/config.json` (or its relocated equivalent).
|
|
31
|
+
*
|
|
32
|
+
* A **merge**, not a replace: keys already in the file that `config` does not set are kept
|
|
33
|
+
* (see {@link mergeIntoFile}). Never writes `api_key` — route secrets through
|
|
34
|
+
* `saveAgentProfile` in `oauth.ts` instead.
|
|
35
|
+
*/
|
|
36
|
+
export declare function saveGlobalConfig(config: OrbitMapConfig): Promise<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Write `<dir>/.orbitmap/config.json` (`dir` defaults to `process.cwd()`) and return its
|
|
39
|
+
* path. Committable — never write `api_key` or any other secret here.
|
|
40
|
+
*
|
|
41
|
+
* A **merge**, like {@link saveGlobalConfig}: this file is meant to be committed, so a
|
|
42
|
+
* teammate re-running `orbitmap init` in a checkout must not silently drop the `mode` (or
|
|
43
|
+
* any future field) the repository already agreed on — a loss that would then propagate to
|
|
44
|
+
* everyone through git.
|
|
45
|
+
*/
|
|
46
|
+
export declare function saveProjectConfig(config: OrbitMapConfig, dir?: string): Promise<string>;
|
|
16
47
|
export interface ResolvedAuth {
|
|
17
48
|
apiKey: string;
|
|
18
49
|
apiUrl: string;
|
|
19
|
-
area?: string;
|
|
20
50
|
}
|
|
21
|
-
export
|
|
22
|
-
|
|
51
|
+
export interface ResolveAuthOptions {
|
|
52
|
+
/** Directory the project-config walk-up starts from (defaults to `process.cwd()`). */
|
|
53
|
+
cwd?: string;
|
|
54
|
+
/** Pre-loaded global config, to avoid a second read of the same file. */
|
|
55
|
+
config?: OrbitMapConfig;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Resolve cloud-mode credentials. Per-field layering (ADR 0002), first match wins:
|
|
59
|
+
*
|
|
60
|
+
* - **API key**: `ORBITMAP_API_KEY` env → the resolved agent's profile in
|
|
61
|
+
* `~/.orbitmap/credentials.json` → a legacy `api_key` still sitting in the global config
|
|
62
|
+
* because {@link migrateGlobalConfig} could not write (see there).
|
|
63
|
+
* - **agent** (which profile to use, when the key isn't given directly by env):
|
|
64
|
+
* `ORBITMAP_AGENT` env → nearest `.orbitmap/config.json` that sets `agent` → global
|
|
65
|
+
* config `agent` → `"default"`.
|
|
66
|
+
* - **API URL**: `ORBITMAP_API_URL` env → {@link DEFAULT_API_URL}. There is deliberately no
|
|
67
|
+
* config-file override any more — a single supported host means nothing should be able to
|
|
68
|
+
* pin a stale one (see ADR 0002).
|
|
69
|
+
*
|
|
70
|
+
* **Area is deliberately not resolved here.** There is exactly one area ladder, `resolveArea`
|
|
71
|
+
* in `workspace-resolve.ts`; a second, shorter copy here used to disagree with it about the
|
|
72
|
+
* `link.json` rung. `createClient` applies the resolved area.
|
|
73
|
+
*/
|
|
74
|
+
export declare function resolveAuth(options?: ResolveAuthOptions): Promise<ResolvedAuth>;
|
package/dist/config.js
CHANGED
|
@@ -1,43 +1,217 @@
|
|
|
1
|
-
import { readFile, writeFile, mkdir } from 'node:fs/promises';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
1
|
+
import { readFile, writeFile, rename, mkdir } from 'node:fs/promises';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { CONFIG_FILENAME, credentialsPath, globalConfigReadPath, globalConfigWritePath, ORBITMAP_DIR, } from './paths.js';
|
|
4
|
+
import { parseConfig, resolveProjectConfigField, } from './project-config.js';
|
|
5
|
+
import { loadAgentProfile, saveAgentProfile } from './oauth.js';
|
|
6
|
+
export { resolveProjectConfigField } from './project-config.js';
|
|
7
|
+
/**
|
|
8
|
+
* Version stamped into every config file this module writes (ADR 0002). It is also the
|
|
9
|
+
* migration gate: a global config already carrying this version has been through
|
|
10
|
+
* {@link migrateGlobalConfig} and is never re-examined, on this run or any later one.
|
|
11
|
+
*/
|
|
12
|
+
export const CURRENT_SCHEMA_VERSION = 1;
|
|
13
|
+
/** Agent profile a pre-ADR-0002 global `api_key` is migrated into. */
|
|
14
|
+
const LEGACY_AGENT_PROFILE = 'default';
|
|
15
|
+
/**
|
|
16
|
+
* The only supported Agent API host. Every default in the CLI resolves here — do not
|
|
17
|
+
* hardcode a base URL anywhere else, and never ship a hosting-provider origin
|
|
18
|
+
* (it lets callers bypass whatever fronts the public domain).
|
|
19
|
+
*/
|
|
20
|
+
export const DEFAULT_API_HOST = 'https://app.orbitmap.ai';
|
|
21
|
+
/** Default Agent API base URL: {@link DEFAULT_API_HOST} + the `/api/agent` prefix. */
|
|
22
|
+
export const DEFAULT_API_URL = `${DEFAULT_API_HOST}/api/agent`;
|
|
23
|
+
// ── Raw file I/O ────────────────────────────────────────────────────────────
|
|
24
|
+
/** The file's JSON object exactly as written, or `undefined` when it is missing,
|
|
25
|
+
* unreadable or not a JSON object. Used to preserve keys this version does not know. */
|
|
26
|
+
async function readRawConfigFile(file) {
|
|
7
27
|
try {
|
|
8
|
-
const
|
|
9
|
-
|
|
28
|
+
const parsed = JSON.parse(await readFile(file, 'utf-8'));
|
|
29
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed))
|
|
30
|
+
return undefined;
|
|
31
|
+
return parsed;
|
|
10
32
|
}
|
|
11
33
|
catch {
|
|
12
|
-
return
|
|
34
|
+
return undefined;
|
|
13
35
|
}
|
|
14
36
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Write JSON to `file` atomically: a sibling temp file plus a rename, which is atomic on
|
|
39
|
+
* every filesystem the CLI targets. `loadConfig()` performs a write as a side effect of the
|
|
40
|
+
* ADR 0002 migration, so two CLI processes starting at once can both reach this — with a
|
|
41
|
+
* plain `writeFile` the loser could observe (and persist) a half-written file.
|
|
42
|
+
*/
|
|
43
|
+
async function writeJsonAtomic(file, data) {
|
|
44
|
+
await mkdir(dirname(file), { recursive: true });
|
|
45
|
+
const temp = `${file}.${process.pid}.tmp`;
|
|
46
|
+
await writeFile(temp, JSON.stringify(data, null, 2) + '\n', 'utf-8');
|
|
47
|
+
await rename(temp, file);
|
|
18
48
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Merge `patch` into whatever `file` already holds and write the result.
|
|
51
|
+
*
|
|
52
|
+
* Two rules, both about not destroying data the CLI did not write:
|
|
53
|
+
*
|
|
54
|
+
* - **Unknown keys survive.** The on-disk object is the base; only the keys `patch`
|
|
55
|
+
* actually sets are overwritten. A key from a future version (or a hand-written note)
|
|
56
|
+
* is never erased by a save — least of all by the migration, which is triggered by what
|
|
57
|
+
* the user experiences as a read.
|
|
58
|
+
* - **`api_key` never survives.** It is the one key this module actively removes: ADR 0002
|
|
59
|
+
* moved it into `credentials.json`, and leaving a copy behind in a committable-shaped
|
|
60
|
+
* file is the failure mode the ADR exists to end.
|
|
61
|
+
*
|
|
62
|
+
* `fallbackFile` (optional) is read when `file` itself does not exist yet — used when the
|
|
63
|
+
* global config is read from the legacy `~/.orbitmap` location but written to a relocated
|
|
64
|
+
* one, so the relocated copy inherits the legacy file's unknown keys.
|
|
65
|
+
*/
|
|
66
|
+
async function mergeIntoFile(file, patch, fallbackFile) {
|
|
67
|
+
const base = (await readRawConfigFile(file)) ??
|
|
68
|
+
(fallbackFile && fallbackFile !== file ? await readRawConfigFile(fallbackFile) : undefined) ??
|
|
69
|
+
{};
|
|
70
|
+
const merged = { ...base };
|
|
71
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
72
|
+
if (value !== undefined)
|
|
73
|
+
merged[key] = value;
|
|
74
|
+
}
|
|
75
|
+
delete merged['api_key'];
|
|
76
|
+
merged['schema_version'] = CURRENT_SCHEMA_VERSION;
|
|
77
|
+
await writeJsonAtomic(file, merged);
|
|
78
|
+
}
|
|
79
|
+
// ── Global config ───────────────────────────────────────────────────────────
|
|
80
|
+
let globalMigrationAttempted = false;
|
|
81
|
+
/** Reset the once-per-process migration latch. Tests only. */
|
|
82
|
+
export function resetConfigMigrationForTests() {
|
|
83
|
+
globalMigrationAttempted = false;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* One-time migration of the global config to {@link CURRENT_SCHEMA_VERSION} (ADR 0002).
|
|
87
|
+
*
|
|
88
|
+
* `api_key` used to live in the config file in plain text. It moves into
|
|
89
|
+
* `~/.orbitmap/credentials.json` under the `"default"` agent profile and is deleted from
|
|
90
|
+
* every config file it appears in — including the legacy `~/.orbitmap/config.json` when
|
|
91
|
+
* `ORBITMAP_CONFIG_HOME`/`XDG_CONFIG_HOME` moved the *written* file elsewhere, which would
|
|
92
|
+
* otherwise leave the plaintext secret sitting on disk forever under a message claiming it
|
|
93
|
+
* had been moved.
|
|
94
|
+
*
|
|
95
|
+
* The gate is the `schema_version` stamped by {@link mergeIntoFile}: once the file carries
|
|
96
|
+
* the current version, no later process looks at it again. The in-process flag only avoids
|
|
97
|
+
* repeating the work (and the warning) within a single run.
|
|
98
|
+
*
|
|
99
|
+
* Mutates `config` in place so the caller's already-parsed object reflects the migration.
|
|
100
|
+
* **On failure the legacy `api_key` is left in `config`** — `resolveAuth` falls back to it,
|
|
101
|
+
* so a machine where the write cannot happen (read-only `$HOME`, `credentials.json` owned
|
|
102
|
+
* by another user, a full disk) keeps working with the key it already has on disk instead
|
|
103
|
+
* of reporting "Missing API key" for a key that is right there.
|
|
104
|
+
*/
|
|
105
|
+
async function migrateGlobalConfig(config) {
|
|
106
|
+
if ((config.schema_version ?? 0) >= CURRENT_SCHEMA_VERSION)
|
|
107
|
+
return;
|
|
108
|
+
if (globalMigrationAttempted)
|
|
109
|
+
return;
|
|
110
|
+
globalMigrationAttempted = true;
|
|
111
|
+
const legacyKey = config.api_key;
|
|
112
|
+
const readPath = globalConfigReadPath();
|
|
113
|
+
const writePath = globalConfigWritePath();
|
|
114
|
+
try {
|
|
115
|
+
if (legacyKey)
|
|
116
|
+
await saveAgentProfile(LEGACY_AGENT_PROFILE, { api_key: legacyKey });
|
|
117
|
+
delete config.api_key;
|
|
118
|
+
await mergeIntoFile(writePath, config, readPath);
|
|
119
|
+
// The relocated file is now authoritative, but the legacy one still holds the secret.
|
|
120
|
+
if (legacyKey && readPath !== writePath)
|
|
121
|
+
await mergeIntoFile(readPath, config);
|
|
122
|
+
if (legacyKey) {
|
|
123
|
+
const also = readPath !== writePath ? ` and removed from ${readPath}` : '';
|
|
124
|
+
console.warn(`[orbitmap] Migrated the agent API key out of ${writePath}${also} into ` +
|
|
125
|
+
`${credentialsPath()} (profile "${LEGACY_AGENT_PROFILE}"). ` +
|
|
126
|
+
'See docs/adr/0002-project-scoped-config.md.');
|
|
127
|
+
}
|
|
27
128
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
129
|
+
catch (error) {
|
|
130
|
+
// Retry on the next run; the version stamp never landed, so the gate is still open.
|
|
131
|
+
globalMigrationAttempted = false;
|
|
132
|
+
if (!legacyKey)
|
|
133
|
+
return; // Nothing was at risk — only the version stamp failed to land.
|
|
134
|
+
// Loud, not silent: the key stays readable this run (restored here), but the user has
|
|
135
|
+
// to know their config file still holds a plaintext secret.
|
|
136
|
+
config.api_key = legacyKey;
|
|
137
|
+
console.warn(`[orbitmap] Could not migrate the agent API key out of ${readPath}: ` +
|
|
138
|
+
`${error instanceof Error ? error.message : String(error)}. The key is still in ` +
|
|
139
|
+
'plain text in that file and is being used from there for this run; fix the ' +
|
|
140
|
+
'permissions (or set ORBITMAP_CONFIG_HOME to a writable directory) and re-run.');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/** Load `~/.orbitmap/config.json` (or the XDG/legacy equivalent). Runs the one-time
|
|
144
|
+
* migration in {@link migrateGlobalConfig} as a side effect. */
|
|
145
|
+
export async function loadConfig() {
|
|
146
|
+
const raw = await readRawConfigFile(globalConfigReadPath());
|
|
147
|
+
if (!raw)
|
|
148
|
+
return {};
|
|
149
|
+
const config = parseConfig(raw);
|
|
150
|
+
await migrateGlobalConfig(config);
|
|
151
|
+
return config;
|
|
33
152
|
}
|
|
34
|
-
|
|
35
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Write the global `~/.orbitmap/config.json` (or its relocated equivalent).
|
|
155
|
+
*
|
|
156
|
+
* A **merge**, not a replace: keys already in the file that `config` does not set are kept
|
|
157
|
+
* (see {@link mergeIntoFile}). Never writes `api_key` — route secrets through
|
|
158
|
+
* `saveAgentProfile` in `oauth.ts` instead.
|
|
159
|
+
*/
|
|
160
|
+
export async function saveGlobalConfig(config) {
|
|
161
|
+
const file = globalConfigWritePath();
|
|
162
|
+
await mergeIntoFile(file, config, globalConfigReadPath());
|
|
163
|
+
return file;
|
|
164
|
+
}
|
|
165
|
+
// ── Project config ──────────────────────────────────────────────
|
|
166
|
+
/**
|
|
167
|
+
* Write `<dir>/.orbitmap/config.json` (`dir` defaults to `process.cwd()`) and return its
|
|
168
|
+
* path. Committable — never write `api_key` or any other secret here.
|
|
169
|
+
*
|
|
170
|
+
* A **merge**, like {@link saveGlobalConfig}: this file is meant to be committed, so a
|
|
171
|
+
* teammate re-running `orbitmap init` in a checkout must not silently drop the `mode` (or
|
|
172
|
+
* any future field) the repository already agreed on — a loss that would then propagate to
|
|
173
|
+
* everyone through git.
|
|
174
|
+
*/
|
|
175
|
+
export async function saveProjectConfig(config, dir = process.cwd()) {
|
|
176
|
+
const file = join(resolve(dir), ORBITMAP_DIR, CONFIG_FILENAME);
|
|
177
|
+
await mergeIntoFile(file, config);
|
|
178
|
+
return file;
|
|
36
179
|
}
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
180
|
+
/**
|
|
181
|
+
* Resolve cloud-mode credentials. Per-field layering (ADR 0002), first match wins:
|
|
182
|
+
*
|
|
183
|
+
* - **API key**: `ORBITMAP_API_KEY` env → the resolved agent's profile in
|
|
184
|
+
* `~/.orbitmap/credentials.json` → a legacy `api_key` still sitting in the global config
|
|
185
|
+
* because {@link migrateGlobalConfig} could not write (see there).
|
|
186
|
+
* - **agent** (which profile to use, when the key isn't given directly by env):
|
|
187
|
+
* `ORBITMAP_AGENT` env → nearest `.orbitmap/config.json` that sets `agent` → global
|
|
188
|
+
* config `agent` → `"default"`.
|
|
189
|
+
* - **API URL**: `ORBITMAP_API_URL` env → {@link DEFAULT_API_URL}. There is deliberately no
|
|
190
|
+
* config-file override any more — a single supported host means nothing should be able to
|
|
191
|
+
* pin a stale one (see ADR 0002).
|
|
192
|
+
*
|
|
193
|
+
* **Area is deliberately not resolved here.** There is exactly one area ladder, `resolveArea`
|
|
194
|
+
* in `workspace-resolve.ts`; a second, shorter copy here used to disagree with it about the
|
|
195
|
+
* `link.json` rung. `createClient` applies the resolved area.
|
|
42
196
|
*/
|
|
197
|
+
export async function resolveAuth(options = {}) {
|
|
198
|
+
const cwd = options.cwd ?? process.cwd();
|
|
199
|
+
const config = options.config ?? (await loadConfig());
|
|
200
|
+
const apiUrl = process.env['ORBITMAP_API_URL'] || DEFAULT_API_URL;
|
|
201
|
+
let apiKey = process.env['ORBITMAP_API_KEY'];
|
|
202
|
+
if (!apiKey) {
|
|
203
|
+
const agent = process.env['ORBITMAP_AGENT'] ||
|
|
204
|
+
resolveProjectConfigField('agent', cwd)?.value ||
|
|
205
|
+
config.agent ||
|
|
206
|
+
LEGACY_AGENT_PROFILE;
|
|
207
|
+
apiKey = (await loadAgentProfile(agent))?.api_key;
|
|
208
|
+
}
|
|
209
|
+
// Last resort: an unmigrated global config (the migration write failed — it warned).
|
|
210
|
+
if (!apiKey)
|
|
211
|
+
apiKey = config.api_key;
|
|
212
|
+
if (!apiKey) {
|
|
213
|
+
throw new Error('Missing API key. Set ORBITMAP_API_KEY env var or run `orbitmap init`.');
|
|
214
|
+
}
|
|
215
|
+
return { apiKey, apiUrl };
|
|
216
|
+
}
|
|
43
217
|
//# sourceMappingURL=config.js.map
|