orbitmap 0.3.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 +546 -212
- package/dist/adapters/cloud.d.ts +367 -0
- package/dist/adapters/cloud.js +582 -0
- package/dist/adapters/cloud.js.map +1 -0
- package/dist/adapters/factory.d.ts +15 -0
- package/dist/adapters/factory.js +31 -0
- package/dist/adapters/factory.js.map +1 -0
- package/dist/adapters/local/adapter.d.ts +351 -0
- package/dist/adapters/local/adapter.js +346 -0
- package/dist/adapters/local/adapter.js.map +1 -0
- package/dist/adapters/local/context.d.ts +112 -0
- package/dist/adapters/local/context.js +137 -0
- package/dist/adapters/local/context.js.map +1 -0
- package/dist/adapters/local/entities/documents.d.ts +85 -0
- package/dist/adapters/local/entities/documents.js +251 -0
- package/dist/adapters/local/entities/documents.js.map +1 -0
- package/dist/adapters/local/entities/planning.d.ts +108 -0
- package/dist/adapters/local/entities/planning.js +540 -0
- package/dist/adapters/local/entities/planning.js.map +1 -0
- package/dist/adapters/local/entities/tasks.d.ts +95 -0
- package/dist/adapters/local/entities/tasks.js +442 -0
- package/dist/adapters/local/entities/tasks.js.map +1 -0
- package/dist/adapters/local/entities/work-items.d.ts +110 -0
- package/dist/adapters/local/entities/work-items.js +623 -0
- package/dist/adapters/local/entities/work-items.js.map +1 -0
- package/dist/adapters/local/rules.d.ts +172 -0
- package/dist/adapters/local/rules.js +319 -0
- package/dist/adapters/local/rules.js.map +1 -0
- package/dist/adapters/local/shapes.d.ts +209 -0
- package/dist/adapters/local/shapes.js +558 -0
- package/dist/adapters/local/shapes.js.map +1 -0
- package/dist/adapters/local/store.d.ts +200 -0
- package/dist/adapters/local/store.js +665 -0
- package/dist/adapters/local/store.js.map +1 -0
- package/dist/adapters/local/types.d.ts +226 -0
- package/dist/adapters/local/types.js +41 -0
- package/dist/adapters/local/types.js.map +1 -0
- package/dist/adapters/types.d.ts +332 -0
- package/dist/adapters/types.js +2 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/agent-instructions.d.ts +25 -9
- package/dist/agent-instructions.js +285 -237
- package/dist/agent-instructions.js.map +1 -1
- package/dist/api-client.d.ts +8 -239
- package/dist/api-client.js +8 -403
- package/dist/api-client.js.map +1 -1
- package/dist/commands/agents.d.ts +1 -1
- package/dist/commands/agents.js +10 -10
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/areas.d.ts +3 -0
- package/dist/commands/areas.js +29 -0
- package/dist/commands/areas.js.map +1 -0
- package/dist/commands/assign.d.ts +3 -2
- package/dist/commands/assign.js +52 -15
- package/dist/commands/assign.js.map +1 -1
- package/dist/commands/context.d.ts +1 -1
- package/dist/commands/context.js +18 -12
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/create-area.d.ts +7 -0
- package/dist/commands/create-area.js +29 -0
- package/dist/commands/create-area.js.map +1 -0
- package/dist/commands/create.d.ts +3 -1
- package/dist/commands/create.js +5 -8
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/dep.d.ts +2 -2
- package/dist/commands/dep.js +3 -3
- package/dist/commands/dep.js.map +1 -1
- package/dist/commands/doc-import.d.ts +1 -1
- package/dist/commands/doc-import.js +2 -2
- package/dist/commands/doc-import.js.map +1 -1
- package/dist/commands/doc-patch.d.ts +1 -1
- package/dist/commands/doc-patch.js +2 -2
- package/dist/commands/doc-patch.js.map +1 -1
- package/dist/commands/doc-share.d.ts +6 -6
- package/dist/commands/doc-share.js +13 -13
- package/dist/commands/doc-share.js.map +1 -1
- package/dist/commands/doc-update.d.ts +1 -1
- package/dist/commands/doc-update.js +2 -2
- package/dist/commands/doc-update.js.map +1 -1
- package/dist/commands/doc.d.ts +1 -1
- package/dist/commands/doc.js +5 -4
- package/dist/commands/doc.js.map +1 -1
- package/dist/commands/docs-cache.d.ts +2 -2
- package/dist/commands/docs-cache.js +3 -3
- package/dist/commands/docs-cache.js.map +1 -1
- package/dist/commands/docs.d.ts +1 -1
- package/dist/commands/docs.js +2 -2
- package/dist/commands/docs.js.map +1 -1
- package/dist/commands/get.d.ts +1 -1
- package/dist/commands/get.js +43 -3
- package/dist/commands/get.js.map +1 -1
- package/dist/commands/ideas.d.ts +4 -4
- package/dist/commands/ideas.js +6 -11
- package/dist/commands/ideas.js.map +1 -1
- package/dist/commands/init.d.ts +45 -3
- package/dist/commands/init.js +452 -104
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/intent.d.ts +41 -0
- package/dist/commands/intent.js +237 -0
- package/dist/commands/intent.js.map +1 -0
- package/dist/commands/issues.d.ts +6 -5
- package/dist/commands/issues.js +8 -12
- package/dist/commands/issues.js.map +1 -1
- package/dist/commands/log.d.ts +1 -1
- package/dist/commands/log.js +2 -2
- package/dist/commands/log.js.map +1 -1
- package/dist/commands/mission.d.ts +42 -0
- package/dist/commands/mission.js +219 -0
- package/dist/commands/mission.js.map +1 -0
- package/dist/commands/orbit.d.ts +40 -3
- package/dist/commands/orbit.js +231 -58
- package/dist/commands/orbit.js.map +1 -1
- package/dist/commands/overview.d.ts +2 -2
- package/dist/commands/overview.js +25 -28
- package/dist/commands/overview.js.map +1 -1
- package/dist/commands/setup-agent.d.ts +27 -0
- package/dist/commands/setup-agent.js +85 -30
- package/dist/commands/setup-agent.js.map +1 -1
- package/dist/commands/setup-mcp.d.ts +1 -1
- package/dist/commands/setup-mcp.js +20 -49
- package/dist/commands/setup-mcp.js.map +1 -1
- package/dist/commands/start.d.ts +1 -1
- package/dist/commands/start.js +2 -2
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/status.d.ts +2 -1
- package/dist/commands/status.js +3 -3
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/subtask.d.ts +1 -1
- package/dist/commands/subtask.js +2 -2
- package/dist/commands/subtask.js.map +1 -1
- package/dist/commands/task-edit-content.d.ts +1 -1
- package/dist/commands/task-edit-content.js +2 -2
- package/dist/commands/task-edit-content.js.map +1 -1
- package/dist/commands/task.d.ts +10 -3
- package/dist/commands/task.js +19 -21
- package/dist/commands/task.js.map +1 -1
- package/dist/commands/tasks.d.ts +1 -1
- package/dist/commands/tasks.js +2 -2
- package/dist/commands/tasks.js.map +1 -1
- package/dist/commands/vibes.d.ts +4 -4
- package/dist/commands/vibes.js +5 -5
- package/dist/commands/vibes.js.map +1 -1
- package/dist/config.d.ts +69 -9
- package/dist/config.js +206 -23
- package/dist/config.js.map +1 -1
- package/dist/doc-cache.d.ts +23 -3
- package/dist/doc-cache.js +72 -12
- package/dist/doc-cache.js.map +1 -1
- package/dist/errors.d.ts +19 -2
- package/dist/errors.js +35 -0
- package/dist/errors.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 +477 -104
- 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/output.js +7 -2
- package/dist/output.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 +158 -0
- package/dist/workspace-resolve.js +284 -0
- package/dist/workspace-resolve.js.map +1 -0
- package/package.json +53 -50
package/dist/config.js
CHANGED
|
@@ -1,34 +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;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
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);
|
|
48
|
+
}
|
|
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;
|
|
13
74
|
}
|
|
75
|
+
delete merged['api_key'];
|
|
76
|
+
merged['schema_version'] = CURRENT_SCHEMA_VERSION;
|
|
77
|
+
await writeJsonAtomic(file, merged);
|
|
14
78
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
}
|
|
128
|
+
}
|
|
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
|
+
}
|
|
18
142
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
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;
|
|
152
|
+
}
|
|
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;
|
|
179
|
+
}
|
|
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.
|
|
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;
|
|
25
212
|
if (!apiKey) {
|
|
26
213
|
throw new Error('Missing API key. Set ORBITMAP_API_KEY env var or run `orbitmap init`.');
|
|
27
214
|
}
|
|
28
|
-
|
|
29
|
-
return { apiKey, apiUrl, projectId };
|
|
30
|
-
}
|
|
31
|
-
export function resolveProjectId(explicit, envOrConfig) {
|
|
32
|
-
return explicit || process.env['ORBITMAP_PROJECT_ID'] || envOrConfig;
|
|
215
|
+
return { apiKey, apiUrl };
|
|
33
216
|
}
|
|
34
217
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EACL,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,WAAW,EACX,yBAAyB,GAE1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAUhE,OAAO,EAAE,yBAAyB,EAA6B,MAAM,qBAAqB,CAAC;AAE3F;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAExC,sEAAsE;AACtE,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AAE1D,sFAAsF;AACtF,MAAM,CAAC,MAAM,e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AC;AAC5B,CAAC"}
|
package/dist/doc-cache.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WorkspaceAdapter } from './adapters/types.js';
|
|
2
2
|
export interface ManifestEntry {
|
|
3
3
|
doc_id: string;
|
|
4
4
|
version: number;
|
|
@@ -17,8 +17,28 @@ export interface DownloadResult {
|
|
|
17
17
|
export declare function getCacheDir(): string;
|
|
18
18
|
export declare function readManifest(): Manifest;
|
|
19
19
|
export declare function writeManifest(manifest: Manifest): void;
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Append any of `entries` missing from `<cwd>/.gitignore` (creating the file if needed) and
|
|
22
|
+
* return the entries actually written.
|
|
23
|
+
*
|
|
24
|
+
* Idempotent — entries already present are left alone and nothing is written when there is
|
|
25
|
+
* nothing missing, which is why the return value matters: a caller that announces "added X
|
|
26
|
+
* to .gitignore" would otherwise say so on every re-run. Reused by `setup-mcp.ts` for
|
|
27
|
+
* `.mcp.json`, which carries a Bearer token the same way the doc cache and `link.json`
|
|
28
|
+
* carry no secret but still shouldn't be committed as machine-local state.
|
|
29
|
+
*/
|
|
30
|
+
export declare function ensureGitignore(entries?: string[], cwd?: string): string[];
|
|
31
|
+
/**
|
|
32
|
+
* True when `.gitignore` already has a blanket `.orbitmap/` entry from before ADR 0002.
|
|
33
|
+
* Callers use this to warn instead of silently leaving the project's config untracked.
|
|
34
|
+
*
|
|
35
|
+
* A trailing comment (`.orbitmap/ # doc cache`) and surrounding whitespace are stripped
|
|
36
|
+
* before matching; negations (`!.orbitmap/config.json`) are not — a user who wrote one has
|
|
37
|
+
* already solved the problem this warning is about, so treating the blanket line as
|
|
38
|
+
* shadowing would be a false alarm.
|
|
39
|
+
*/
|
|
40
|
+
export declare function gitignoreShadowsProjectConfig(cwd?: string): boolean;
|
|
41
|
+
export declare function downloadDocument(client: WorkspaceAdapter, idOrSlug: string): Promise<DownloadResult>;
|
|
22
42
|
export declare function cleanupCache(availableDocSlugs: string[]): {
|
|
23
43
|
removed: string[];
|
|
24
44
|
};
|
package/dist/doc-cache.js
CHANGED
|
@@ -22,19 +22,79 @@ export function writeManifest(manifest) {
|
|
|
22
22
|
mkdirSync(dirname(manifestPath), { recursive: true });
|
|
23
23
|
writeFileSync(manifestPath, JSON.stringify(manifest, null, 2), 'utf-8');
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Entries this cache needs ignored when no more specific list is given: the download cache
|
|
27
|
+
* itself and the local-workspace pointer file. Deliberately **not** a blanket `.orbitmap/`
|
|
28
|
+
* — `<project>/.orbitmap/config.json` (ADR 0002) lives in the same directory and is meant
|
|
29
|
+
* to be committed, so ignoring the whole directory would silently swallow it.
|
|
30
|
+
*/
|
|
31
|
+
const DEFAULT_GITIGNORE_ENTRIES = ['.orbitmap/docs/', '.orbitmap/link.json'];
|
|
32
|
+
/**
|
|
33
|
+
* Append any of `entries` missing from `<cwd>/.gitignore` (creating the file if needed) and
|
|
34
|
+
* return the entries actually written.
|
|
35
|
+
*
|
|
36
|
+
* Idempotent — entries already present are left alone and nothing is written when there is
|
|
37
|
+
* nothing missing, which is why the return value matters: a caller that announces "added X
|
|
38
|
+
* to .gitignore" would otherwise say so on every re-run. Reused by `setup-mcp.ts` for
|
|
39
|
+
* `.mcp.json`, which carries a Bearer token the same way the doc cache and `link.json`
|
|
40
|
+
* carry no secret but still shouldn't be committed as machine-local state.
|
|
41
|
+
*/
|
|
42
|
+
export function ensureGitignore(entries = DEFAULT_GITIGNORE_ENTRIES, cwd = process.cwd()) {
|
|
43
|
+
const gitignorePath = join(cwd, '.gitignore');
|
|
44
|
+
const existing = existsSync(gitignorePath) ? readFileSync(gitignorePath, 'utf-8') : '';
|
|
45
|
+
const existingLines = new Set(existing.split(/\r?\n/).map((line) => line.trim()));
|
|
46
|
+
const missing = entries.filter((entry) => !existingLines.has(entry));
|
|
47
|
+
if (missing.length === 0)
|
|
48
|
+
return [];
|
|
49
|
+
const separator = existing.length > 0 && !existing.endsWith('\n') ? '\n' : '';
|
|
50
|
+
writeFileSync(gitignorePath, `${existing}${separator}${missing.join('\n')}\n`, 'utf-8');
|
|
51
|
+
return missing;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Every `.gitignore` line shape that ignores the whole `.orbitmap/` directory — and
|
|
55
|
+
* therefore also hides the new, committable `.orbitmap/config.json` (ADR 0002).
|
|
56
|
+
*
|
|
57
|
+
* git treats a pattern containing no slash (other than a trailing one) as matching at every
|
|
58
|
+
* level, so `**/.orbitmap/` and `.orbitmap/*` are the same blanket in practice as the plain
|
|
59
|
+
* `.orbitmap/` this CLI used to write.
|
|
60
|
+
*/
|
|
61
|
+
const BLANKET_ORBITMAP_PATTERNS = new Set([
|
|
62
|
+
'.orbitmap',
|
|
63
|
+
'.orbitmap/',
|
|
64
|
+
'.orbitmap/*',
|
|
65
|
+
'.orbitmap/**',
|
|
66
|
+
'/.orbitmap',
|
|
67
|
+
'/.orbitmap/',
|
|
68
|
+
'/.orbitmap/*',
|
|
69
|
+
'/.orbitmap/**',
|
|
70
|
+
'**/.orbitmap',
|
|
71
|
+
'**/.orbitmap/',
|
|
72
|
+
'**/.orbitmap/*',
|
|
73
|
+
'**/.orbitmap/**',
|
|
74
|
+
]);
|
|
75
|
+
/**
|
|
76
|
+
* True when `.gitignore` already has a blanket `.orbitmap/` entry from before ADR 0002.
|
|
77
|
+
* Callers use this to warn instead of silently leaving the project's config untracked.
|
|
78
|
+
*
|
|
79
|
+
* A trailing comment (`.orbitmap/ # doc cache`) and surrounding whitespace are stripped
|
|
80
|
+
* before matching; negations (`!.orbitmap/config.json`) are not — a user who wrote one has
|
|
81
|
+
* already solved the problem this warning is about, so treating the blanket line as
|
|
82
|
+
* shadowing would be a false alarm.
|
|
83
|
+
*/
|
|
84
|
+
export function gitignoreShadowsProjectConfig(cwd = process.cwd()) {
|
|
85
|
+
const gitignorePath = join(cwd, '.gitignore');
|
|
86
|
+
if (!existsSync(gitignorePath))
|
|
87
|
+
return false;
|
|
88
|
+
const lines = readFileSync(gitignorePath, 'utf-8').split(/\r?\n/).map(normalizeGitignoreLine);
|
|
89
|
+
if (lines.some((line) => line === '!.orbitmap/config.json' || line === '!/.orbitmap/config.json')) {
|
|
90
|
+
return false;
|
|
37
91
|
}
|
|
92
|
+
return lines.some((line) => BLANKET_ORBITMAP_PATTERNS.has(line));
|
|
93
|
+
}
|
|
94
|
+
/** Strip a trailing `#` comment and surrounding whitespace from one `.gitignore` line. */
|
|
95
|
+
function normalizeGitignoreLine(line) {
|
|
96
|
+
const withoutComment = line.replace(/(?:^|\s)#.*$/, '');
|
|
97
|
+
return withoutComment.trim();
|
|
38
98
|
}
|
|
39
99
|
export async function downloadDocument(client, idOrSlug) {
|
|
40
100
|
const response = (await client.getDocument(idOrSlug, 'file'));
|
package/dist/doc-cache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doc-cache.js","sourceRoot":"","sources":["../src/doc-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgC1C,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AAC5C,MAAM,aAAa,GAAG,gBAAgB,CAAC;AACvC,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB,MAAM,UAAU,WAAW;IACzB,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,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AAiB,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,OAAO,GAAG,UAAU,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IACjD,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrD,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAS;QAEhC,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,CAAC;QAC7D,IAAI,GAAG,GAAG,YAAY,IAAI,OAAO;YAAE,SAAS;QAE5C,2CAA2C;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC;YACH,IAAI,UAAU,CAAC,QAAQ,CAAC;gBAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;QACjD,CAAC;QAAC,MAAM,CAAC;YACP,8BAA8B;QAChC,CAAC;QACD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC1B,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -6,11 +6,28 @@ export interface ApiErrorBody {
|
|
|
6
6
|
details?: Record<string, string[]>;
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Flat error shape used by billing/usage-limit rejections (402, 429):
|
|
11
|
+
* `error` is a string instead of an object.
|
|
12
|
+
*/
|
|
13
|
+
export interface FlatApiErrorBody {
|
|
14
|
+
error: string;
|
|
15
|
+
message?: string;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
/** No local workspace directory could be resolved (see workspace-resolve.ts). */
|
|
19
|
+
export declare const WORKSPACE_NOT_FOUND = "WORKSPACE_NOT_FOUND";
|
|
20
|
+
/** The command needs an area but none could be resolved (same code the API uses). */
|
|
21
|
+
export declare const AREA_CONTEXT_REQUIRED = "AREA_CONTEXT_REQUIRED";
|
|
9
22
|
export declare class OrbitMapAPIError extends Error {
|
|
10
23
|
readonly code: string;
|
|
11
24
|
readonly status: number;
|
|
12
|
-
readonly details?: Record<string,
|
|
13
|
-
constructor(message: string, code: string, status: number, details?: Record<string,
|
|
25
|
+
readonly details?: Record<string, unknown>;
|
|
26
|
+
constructor(message: string, code: string, status: number, details?: Record<string, unknown>);
|
|
14
27
|
static fromResponse(body: ApiErrorBody): OrbitMapAPIError;
|
|
28
|
+
static fromFlatResponse(body: FlatApiErrorBody, httpStatus: number): OrbitMapAPIError;
|
|
29
|
+
static workspaceNotFound(message?: string): OrbitMapAPIError;
|
|
30
|
+
static areaContextRequired(message?: string, details?: Record<string, unknown>): OrbitMapAPIError;
|
|
15
31
|
static isApiErrorBody(body: unknown): body is ApiErrorBody;
|
|
32
|
+
static isFlatApiErrorBody(body: unknown): body is FlatApiErrorBody;
|
|
16
33
|
}
|
package/dist/errors.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/** No local workspace directory could be resolved (see workspace-resolve.ts). */
|
|
2
|
+
export const WORKSPACE_NOT_FOUND = 'WORKSPACE_NOT_FOUND';
|
|
3
|
+
/** The command needs an area but none could be resolved (same code the API uses). */
|
|
4
|
+
export const AREA_CONTEXT_REQUIRED = 'AREA_CONTEXT_REQUIRED';
|
|
5
|
+
const FLAT_ERROR_CODES = {
|
|
6
|
+
402: 'PAYMENT_REQUIRED',
|
|
7
|
+
429: 'RATE_LIMITED',
|
|
8
|
+
};
|
|
1
9
|
export class OrbitMapAPIError extends Error {
|
|
2
10
|
code;
|
|
3
11
|
status;
|
|
@@ -13,14 +21,41 @@ export class OrbitMapAPIError extends Error {
|
|
|
13
21
|
const { code, message, status, details } = body.error;
|
|
14
22
|
return new OrbitMapAPIError(message, code, status, details);
|
|
15
23
|
}
|
|
24
|
+
static fromFlatResponse(body, httpStatus) {
|
|
25
|
+
const message = body.message || body.error;
|
|
26
|
+
const code = FLAT_ERROR_CODES[httpStatus] ?? 'USAGE_LIMIT';
|
|
27
|
+
const details = {};
|
|
28
|
+
for (const [key, value] of Object.entries(body)) {
|
|
29
|
+
if (key !== 'error' && key !== 'message')
|
|
30
|
+
details[key] = value;
|
|
31
|
+
}
|
|
32
|
+
return new OrbitMapAPIError(message, code, httpStatus, Object.keys(details).length > 0 ? details : undefined);
|
|
33
|
+
}
|
|
34
|
+
static workspaceNotFound(message) {
|
|
35
|
+
return new OrbitMapAPIError(message ||
|
|
36
|
+
'No OrbitMap workspace found. Run `orbitmap init` to create one, or point at an ' +
|
|
37
|
+
'existing workspace with --workspace <path> or ORBITMAP_WORKSPACE.', WORKSPACE_NOT_FOUND, 404);
|
|
38
|
+
}
|
|
39
|
+
static areaContextRequired(message, details) {
|
|
40
|
+
return new OrbitMapAPIError(message ||
|
|
41
|
+
'Area context is required. Pass --area <slug>, set ORBITMAP_AREA, or set a default ' +
|
|
42
|
+
'area with `orbitmap init`.', AREA_CONTEXT_REQUIRED, 400, details);
|
|
43
|
+
}
|
|
16
44
|
static isApiErrorBody(body) {
|
|
17
45
|
return (typeof body === 'object' &&
|
|
18
46
|
body !== null &&
|
|
19
47
|
'error' in body &&
|
|
20
48
|
typeof body.error === 'object' &&
|
|
49
|
+
body.error !== null &&
|
|
21
50
|
typeof body.error.code === 'string' &&
|
|
22
51
|
typeof body.error.message === 'string' &&
|
|
23
52
|
typeof body.error.status === 'number');
|
|
24
53
|
}
|
|
54
|
+
static isFlatApiErrorBody(body) {
|
|
55
|
+
return (typeof body === 'object' &&
|
|
56
|
+
body !== null &&
|
|
57
|
+
'error' in body &&
|
|
58
|
+
typeof body.error === 'string');
|
|
59
|
+
}
|
|
25
60
|
}
|
|
26
61
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAmBA,iFAAiF;AACjF,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAEzD,qFAAqF;AACrF,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAE7D,MAAM,gBAAgB,GAA2B;IAC/C,GAAG,EAAE,kBAAkB;IACvB,GAAG,EAAE,cAAc;CACpB,CAAC;AAEF,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAChC,IAAI,CAAS;IACb,MAAM,CAAS;IACf,OAAO,CAA2B;IAE3C,YACE,OAAe,EACf,IAAY,EACZ,MAAc,EACd,OAAiC;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,IAAkB;QACpC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACtD,OAAO,IAAI,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,CAAC,gBAAgB,CACrB,IAAsB,EACtB,UAAkB;QAElB,MAAM,OA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AK,QAAQ;YACxD,OAAQ,IAAqB,CAAC,KAAK,CAAC,MAAM,KAAK,QAAQ,CACxD,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,IAAa;QACrC,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;YACxB,IAAI,KAAK,IAAI;YACb,OAAO,IAAI,IAAI;YACf,OAAQ,IAAyB,CAAC,KAAK,KAAK,QAAQ,CACrD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prefixed display IDs (`TS-uw9yh5`, `IS-4k2p9q`, …) are what the CLI prints and therefore
|
|
3
|
+
* what users paste back in. This module is the single place that understands them.
|
|
4
|
+
*
|
|
5
|
+
* The Agent API is asymmetric about them: `/issues/{id}`, `/ideas/{id}`, `/intents/{id}` and
|
|
6
|
+
* `/missions/{id}` resolve a prefixed ID inline, server-side, but **tasks do not** — a task
|
|
7
|
+
* reference that is not a uuid has to go through `/tasks/by-number/{number}` first, with the
|
|
8
|
+
* `TS-` prefix stripped. Before this module the CLI patched that around in four copies of the
|
|
9
|
+
* same two helpers and simply omitted it in eight commands, so the same identifier worked in
|
|
10
|
+
* `orbitmap task` and 404'd in `orbitmap status`.
|
|
11
|
+
*
|
|
12
|
+
* Resolution lives in the adapter layer (see `resolveTaskRef` below and its callers in
|
|
13
|
+
* `adapters/cloud.ts`), not in the commands: per CLAUDE.md commands never talk to the network
|
|
14
|
+
* and never reimplement rules, and putting it there means a new task command gets prefixed-ID
|
|
15
|
+
* support for free instead of having to remember. `LocalAdapter` already resolves every task
|
|
16
|
+
* reference through `requireTaskFile`, so this brings cloud mode up to the same contract.
|
|
17
|
+
*/
|
|
18
|
+
/** Two-letter prefix → object type, as the Agent API assigns them. */
|
|
19
|
+
export declare const OBJECT_PREFIXES: {
|
|
20
|
+
readonly TS: "task";
|
|
21
|
+
readonly IS: "issue";
|
|
22
|
+
readonly ID: "idea";
|
|
23
|
+
readonly VB: "vibe";
|
|
24
|
+
readonly IN: "intent";
|
|
25
|
+
readonly MS: "mission";
|
|
26
|
+
};
|
|
27
|
+
export type ObjectPrefix = keyof typeof OBJECT_PREFIXES;
|
|
28
|
+
/**
|
|
29
|
+
* A prefixed display ID or a bare object code — i.e. anything that is NOT a uuid and has to
|
|
30
|
+
* be resolved by number. Six base-36 characters, optionally behind a two-letter prefix.
|
|
31
|
+
*
|
|
32
|
+
* This is the one shared predicate for the number-vs-uuid decision; a uuid is 36 characters
|
|
33
|
+
* with dashes and can never match, and a value that matches can never be a uuid, so the two
|
|
34
|
+
* paths are mutually exclusive by construction. Kept byte-identical to the four helper copies
|
|
35
|
+
* it replaces so no existing input changes meaning.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isObjectNumber(id: string): boolean;
|
|
38
|
+
/** Canonical uuid check, for callers that need the positive form rather than {@link isObjectNumber}. */
|
|
39
|
+
export declare function isUuid(id: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Drop the two-letter prefix from a display ID, leaving the bare object code. A value with no
|
|
42
|
+
* prefix (a bare code, or a uuid) is returned unchanged, so this is safe to call on anything.
|
|
43
|
+
*/
|
|
44
|
+
export declare function stripPrefix(id: string): string;
|
|
45
|
+
/** The prefix of a display ID, or `undefined` when there is none. Never mangles the input. */
|
|
46
|
+
export declare function objectPrefix(id: string): ObjectPrefix | undefined;
|
|
47
|
+
/** The subset of the adapter surface {@link resolveTaskRef} needs. */
|
|
48
|
+
export interface TaskNumberLookup {
|
|
49
|
+
getTaskByNumber(taskNumber: string): Promise<unknown>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Turn any task reference — uuid, `TS-uw9yh5` or the bare code `uw9yh5` — into the uuid the
|
|
53
|
+
* task endpoints expect.
|
|
54
|
+
*
|
|
55
|
+
* A uuid costs **no extra request**: it is returned as-is, synchronously in effect, so the
|
|
56
|
+
* commands that already passed uuids keep their single round trip. Only a by-number reference
|
|
57
|
+
* pays for the `/tasks/by-number/{n}` lookup, which is the price of the API asymmetry this
|
|
58
|
+
* works around (see the module comment) and disappears if `/tasks/{id}` ever resolves
|
|
59
|
+
* prefixed IDs inline the way `/intents/{id}` already does.
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveTaskRef(ref: string, lookup: TaskNumberLookup): Promise<string>;
|