orbitmap 0.4.2 → 0.4.3
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 +60 -13
- package/dist/adapters/cloud.d.ts +53 -21
- package/dist/adapters/cloud.js +95 -29
- package/dist/adapters/cloud.js.map +1 -1
- package/dist/adapters/factory.d.ts +3 -0
- package/dist/adapters/factory.js +8 -1
- package/dist/adapters/factory.js.map +1 -1
- package/dist/adapters/local/adapter.d.ts +0 -20
- package/dist/adapters/local/adapter.js +0 -18
- package/dist/adapters/local/adapter.js.map +1 -1
- package/dist/adapters/local/context.d.ts +1 -1
- package/dist/adapters/local/context.js +10 -2
- package/dist/adapters/local/context.js.map +1 -1
- package/dist/adapters/local/entities/tasks.d.ts +9 -1
- package/dist/adapters/local/entities/tasks.js +47 -5
- package/dist/adapters/local/entities/tasks.js.map +1 -1
- package/dist/adapters/local/entities/work-items.d.ts +14 -30
- package/dist/adapters/local/entities/work-items.js +63 -47
- package/dist/adapters/local/entities/work-items.js.map +1 -1
- package/dist/adapters/local/rules.d.ts +4 -4
- package/dist/adapters/local/rules.js +4 -19
- package/dist/adapters/local/rules.js.map +1 -1
- package/dist/adapters/local/shapes.d.ts +27 -7
- package/dist/adapters/local/shapes.js +41 -5
- package/dist/adapters/local/shapes.js.map +1 -1
- package/dist/adapters/local/store.d.ts +55 -6
- package/dist/adapters/local/store.js +122 -8
- package/dist/adapters/local/store.js.map +1 -1
- package/dist/adapters/local/types.d.ts +9 -2
- package/dist/adapters/local/types.js +9 -2
- package/dist/adapters/local/types.js.map +1 -1
- package/dist/adapters/types.d.ts +7 -20
- package/dist/agent-instructions.d.ts +21 -8
- package/dist/agent-instructions.js +91 -35
- package/dist/agent-instructions.js.map +1 -1
- package/dist/area-directories.d.ts +75 -0
- package/dist/area-directories.js +162 -0
- package/dist/area-directories.js.map +1 -0
- package/dist/area-grouping.d.ts +55 -0
- package/dist/area-grouping.js +72 -0
- package/dist/area-grouping.js.map +1 -0
- package/dist/commands/areas.js +30 -2
- package/dist/commands/areas.js.map +1 -1
- package/dist/commands/assign.d.ts +1 -0
- package/dist/commands/assign.js +2 -0
- package/dist/commands/assign.js.map +1 -1
- package/dist/commands/context.d.ts +95 -0
- package/dist/commands/context.js +104 -2
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/create.d.ts +1 -0
- package/dist/commands/create.js +19 -14
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/dep.js +5 -8
- package/dist/commands/dep.js.map +1 -1
- package/dist/commands/doc-import.d.ts +1 -0
- package/dist/commands/doc-import.js +8 -26
- package/dist/commands/doc-import.js.map +1 -1
- package/dist/commands/doc-patch.js +16 -52
- package/dist/commands/doc-patch.js.map +1 -1
- package/dist/commands/doc-share.js +4 -0
- package/dist/commands/doc-share.js.map +1 -1
- package/dist/commands/doc-update.js +4 -8
- package/dist/commands/doc-update.js.map +1 -1
- package/dist/commands/doc.js +7 -12
- package/dist/commands/doc.js.map +1 -1
- package/dist/commands/docs-cache.js +23 -10
- package/dist/commands/docs-cache.js.map +1 -1
- package/dist/commands/docs.js +29 -10
- package/dist/commands/docs.js.map +1 -1
- package/dist/commands/get.js +4 -10
- package/dist/commands/get.js.map +1 -1
- package/dist/commands/ideas.d.ts +3 -1
- package/dist/commands/ideas.js +26 -49
- package/dist/commands/ideas.js.map +1 -1
- package/dist/commands/init.d.ts +24 -1
- package/dist/commands/init.js +0 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/intent.js +10 -14
- package/dist/commands/intent.js.map +1 -1
- package/dist/commands/issues.d.ts +3 -1
- package/dist/commands/issues.js +47 -72
- package/dist/commands/issues.js.map +1 -1
- package/dist/commands/log.d.ts +1 -0
- package/dist/commands/log.js +18 -17
- package/dist/commands/log.js.map +1 -1
- package/dist/commands/mission.js +3 -12
- package/dist/commands/mission.js.map +1 -1
- package/dist/commands/orbit.d.ts +7 -1
- package/dist/commands/orbit.js +13 -24
- package/dist/commands/orbit.js.map +1 -1
- package/dist/commands/setup-agent.d.ts +97 -4
- package/dist/commands/setup-agent.js +265 -38
- package/dist/commands/setup-agent.js.map +1 -1
- package/dist/commands/setup-mcp.d.ts +2 -0
- package/dist/commands/setup-mcp.js +17 -40
- package/dist/commands/setup-mcp.js.map +1 -1
- package/dist/commands/start.d.ts +43 -0
- package/dist/commands/start.js +158 -3
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +5 -15
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/subtask.d.ts +1 -0
- package/dist/commands/subtask.js +9 -2
- package/dist/commands/subtask.js.map +1 -1
- package/dist/commands/task-edit-content.js +4 -8
- package/dist/commands/task-edit-content.js.map +1 -1
- package/dist/commands/task.d.ts +7 -0
- package/dist/commands/task.js +5 -2
- package/dist/commands/task.js.map +1 -1
- package/dist/commands/tasks.d.ts +35 -0
- package/dist/commands/tasks.js +45 -9
- package/dist/commands/tasks.js.map +1 -1
- package/dist/commands/vibes.d.ts +3 -1
- package/dist/commands/vibes.js +41 -31
- package/dist/commands/vibes.js.map +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/config.js +14 -1
- package/dist/config.js.map +1 -1
- package/dist/doc-cache.d.ts +74 -5
- package/dist/doc-cache.js +106 -22
- package/dist/doc-cache.js.map +1 -1
- package/dist/enums.d.ts +26 -0
- package/dist/enums.js +53 -0
- package/dist/enums.js.map +1 -0
- package/dist/errors.d.ts +67 -0
- package/dist/errors.js +82 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.js +134 -56
- package/dist/index.js.map +1 -1
- package/dist/mcp-config.d.ts +42 -1
- package/dist/mcp-config.js +82 -2
- package/dist/mcp-config.js.map +1 -1
- package/dist/oauth.js +10 -10
- package/dist/output.d.ts +12 -0
- package/dist/output.js +39 -1
- package/dist/output.js.map +1 -1
- package/dist/paths.d.ts +40 -0
- package/dist/paths.js +174 -9
- package/dist/paths.js.map +1 -1
- package/dist/project-config.d.ts +42 -1
- package/dist/project-config.js +51 -0
- package/dist/project-config.js.map +1 -1
- package/dist/workspace-resolve.d.ts +179 -9
- package/dist/workspace-resolve.js +288 -20
- package/dist/workspace-resolve.js.map +1 -1
- package/dist/write-target.d.ts +56 -0
- package/dist/write-target.js +170 -0
- package/dist/write-target.js.map +1 -0
- package/package.json +1 -1
- package/dist/commands/create-project.d.ts +0 -6
- package/dist/commands/create-project.js +0 -28
- package/dist/commands/create-project.js.map +0 -1
- package/dist/commands/projects.d.ts +0 -3
- package/dist/commands/projects.js +0 -28
- package/dist/commands/projects.js.map +0 -1
package/dist/commands/tasks.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createAdapter } from '../adapters/factory.js';
|
|
2
2
|
import { formatOutput, printError, formatTable } from '../output.js';
|
|
3
|
+
import { groupByArea } from '../area-grouping.js';
|
|
3
4
|
export async function tasksCommand(options) {
|
|
4
5
|
try {
|
|
5
6
|
const client = await createAdapter(options.area);
|
|
@@ -8,6 +9,8 @@ export async function tasksCommand(options) {
|
|
|
8
9
|
priority: options.priority,
|
|
9
10
|
orbit: options.orbit,
|
|
10
11
|
}));
|
|
12
|
+
// Passed through verbatim, so the per-task `area` of the workspace-scoped listing
|
|
13
|
+
// survives into `--json` — agents group on it.
|
|
11
14
|
if (options.json) {
|
|
12
15
|
console.log(formatOutput(response, true));
|
|
13
16
|
return;
|
|
@@ -17,19 +20,52 @@ export async function tasksCommand(options) {
|
|
|
17
20
|
console.log('No tasks found.');
|
|
18
21
|
return;
|
|
19
22
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const workspaceScope = response.meta.scope === 'workspace';
|
|
24
|
+
console.log(workspaceScope
|
|
25
|
+
? `Tasks (${response.meta.count}) — whole workspace${response.meta.workspace ? ` ${response.meta.workspace.slug}` : ''}, grouped by area:\n`
|
|
26
|
+
: `Tasks (${response.meta.count}):\n`);
|
|
27
|
+
if (!workspaceScope) {
|
|
28
|
+
console.log(renderTable(tasks));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// The server already orders by area, so grouping is a fold over the rows, not a sort —
|
|
32
|
+
// whatever ordering the API applies inside an area is preserved as-is.
|
|
33
|
+
const groups = groupTasksByArea(tasks);
|
|
34
|
+
groups.forEach((group, index) => {
|
|
35
|
+
if (index > 0)
|
|
36
|
+
console.log('');
|
|
37
|
+
console.log(`── ${group.label} (${group.tasks.length}) ──`);
|
|
38
|
+
console.log(renderTable(group.tasks));
|
|
39
|
+
});
|
|
40
|
+
console.log("\nNarrow this down with --area <slug>, or run from inside that area's directory.");
|
|
29
41
|
}
|
|
30
42
|
catch (error) {
|
|
31
43
|
printError(error, options.json);
|
|
32
44
|
process.exitCode = 1;
|
|
33
45
|
}
|
|
34
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Rows folded into one group per area, in arrival order; area-less rows land in one bucket.
|
|
49
|
+
*
|
|
50
|
+
* The fold itself now lives in `area-grouping.ts`, shared with the issue/idea/vibe/document
|
|
51
|
+
* listings that grew the same need (TS-adanc8). This keeps the task-shaped result (`tasks`,
|
|
52
|
+
* not `rows`) that callers and tests already use.
|
|
53
|
+
*/
|
|
54
|
+
export function groupTasksByArea(tasks) {
|
|
55
|
+
return groupByArea(tasks).groups.map((group) => ({
|
|
56
|
+
label: group.label,
|
|
57
|
+
slug: group.slug,
|
|
58
|
+
tasks: group.rows,
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
function renderTable(tasks) {
|
|
62
|
+
const hasDelivery = tasks.some((t) => t.delivery_status);
|
|
63
|
+
const headers = hasDelivery
|
|
64
|
+
? ['#', 'Title', 'Status', 'Delivery', 'Priority', 'Effort']
|
|
65
|
+
: ['#', 'Title', 'Status', 'Priority', 'Effort'];
|
|
66
|
+
const rows = tasks.map((t) => hasDelivery
|
|
67
|
+
? [t.display_number ?? t.task_number, t.title, t.status, t.delivery_status ?? '', t.priority, t.estimated_effort ?? '']
|
|
68
|
+
: [t.display_number ?? t.task_number, t.title, t.status, t.priority, t.estimated_effort ?? '']);
|
|
69
|
+
return formatTable(headers, rows);
|
|
70
|
+
}
|
|
35
71
|
//# sourceMappingURL=tasks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../src/commands/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../src/commands/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAuClD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAMlC;IACC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjD,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC;YACtC,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC,CAAkB,CAAC;QAErB,kFAAkF;QAClF,+CAA+C;QAC/C,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;YAC1C,OAAO;QACT,CAAC;QAED,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC;QAE5B,IAAI,KAAK,CAAC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AO,EAAE,IAAI,CAAC,CAAC;AACpC,CAAC"}
|
package/dist/commands/vibes.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export declare function vibeLogCommand(options: {
|
|
2
2
|
json: boolean;
|
|
3
3
|
area?: string;
|
|
4
|
-
|
|
4
|
+
yes?: boolean;
|
|
5
|
+
/** Positional content, or the deprecated `--content` alias — resolved in `src/index.ts`. */
|
|
6
|
+
content?: string;
|
|
5
7
|
type: string;
|
|
6
8
|
title?: string;
|
|
7
9
|
task?: string;
|
package/dist/commands/vibes.js
CHANGED
|
@@ -1,20 +1,34 @@
|
|
|
1
1
|
import { createAdapter } from '../adapters/factory.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { confirmWriteTarget } from '../write-target.js';
|
|
3
|
+
import { formatOutput, printError, printSuccess, formatTable, printValidationError } from '../output.js';
|
|
4
|
+
import { printAreaGroups } from '../area-grouping.js';
|
|
5
|
+
/**
|
|
6
|
+
* Vibe types this command will log. `Vibe::TYPES` also allows `idea`, but ideas have their
|
|
7
|
+
* own first-class command (`orbitmap idea add`) — logging one as a vibe buries it outside
|
|
8
|
+
* the idea backlog. Same narrowing as `log_work` in orbitmap-mcp. The full enum stays in
|
|
9
|
+
* the contract layer (`adapters/local/rules.ts`), which mirrors the API.
|
|
10
|
+
*/
|
|
11
|
+
const VALID_VIBE_TYPES = ['note', 'code_change', 'decision', 'discovery', 'exploration', 'fix'];
|
|
12
|
+
/** Rejection message for a vibe type, redirecting `idea` to its own command. */
|
|
13
|
+
function vibeTypeError(type) {
|
|
14
|
+
return type === 'idea'
|
|
15
|
+
? 'Ideas are not tracked as vibes. Use `orbitmap idea add "…"` instead, or pick one of: ' +
|
|
16
|
+
`${VALID_VIBE_TYPES.join(', ')}.`
|
|
17
|
+
: `Invalid vibe type "${type}". Valid: ${VALID_VIBE_TYPES.join(', ')}`;
|
|
18
|
+
}
|
|
4
19
|
// ── Commands ──
|
|
5
20
|
export async function vibeLogCommand(options) {
|
|
21
|
+
if (!options.content) {
|
|
22
|
+
printValidationError('Vibe content is required: `orbitmap vibe log "<content>" --type <type>`.', options.json);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
6
25
|
if (!VALID_VIBE_TYPES.includes(options.type)) {
|
|
7
|
-
const msg =
|
|
8
|
-
|
|
9
|
-
console.error(JSON.stringify({ error: { message: msg } }));
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
console.error(`Error: ${msg}`);
|
|
13
|
-
}
|
|
14
|
-
process.exitCode = 1;
|
|
26
|
+
const msg = vibeTypeError(options.type);
|
|
27
|
+
printValidationError(msg, options.json);
|
|
15
28
|
return;
|
|
16
29
|
}
|
|
17
30
|
try {
|
|
31
|
+
await confirmWriteTarget('log vibe', options);
|
|
18
32
|
const client = await createAdapter(options.area);
|
|
19
33
|
const response = (await client.logVibe({
|
|
20
34
|
content: options.content,
|
|
@@ -51,18 +65,25 @@ export async function vibeListCommand(options) {
|
|
|
51
65
|
return;
|
|
52
66
|
}
|
|
53
67
|
console.log(`Vibes (${response.meta.count}):\n`);
|
|
54
|
-
|
|
55
|
-
v.type,
|
|
56
|
-
v.title ?? v.content.slice(0, 60) + (v.content.length > 60 ? '...' : ''),
|
|
57
|
-
v.author ? (typeof v.author === 'object' ? v.author.name : v.author) : '',
|
|
58
|
-
v.created_at.replace('T', ' ').replace(/\+.*$/, ''),
|
|
59
|
-
])));
|
|
68
|
+
printAreaGroups(vibes, renderVibeTable);
|
|
60
69
|
}
|
|
61
70
|
catch (error) {
|
|
62
71
|
printError(error, options.json);
|
|
63
72
|
process.exitCode = 1;
|
|
64
73
|
}
|
|
65
74
|
}
|
|
75
|
+
/** `Number` leads, the way it does in `issue list` and `idea list` — it is what you act on. */
|
|
76
|
+
function renderVibeTable(vibes) {
|
|
77
|
+
return formatTable(['Number', 'Type', 'Title / Content', 'Author', 'Created'], vibes.map((v) => [
|
|
78
|
+
// Fall back through the bare code to the uuid: `vibe show` accepts all three, so the
|
|
79
|
+
// column is never empty even against an older API that omits `display_number`.
|
|
80
|
+
v.display_number ?? (v.vibe_number ? `VB-${v.vibe_number}` : v.id),
|
|
81
|
+
v.type,
|
|
82
|
+
v.title ?? v.content.slice(0, 60) + (v.content.length > 60 ? '...' : ''),
|
|
83
|
+
v.author ? (typeof v.author === 'object' ? v.author.name : v.author) : '',
|
|
84
|
+
v.created_at.replace('T', ' ').replace(/\+.*$/, ''),
|
|
85
|
+
]));
|
|
86
|
+
}
|
|
66
87
|
export async function vibeShowCommand(id, options) {
|
|
67
88
|
try {
|
|
68
89
|
const client = await createAdapter(options.area);
|
|
@@ -99,28 +120,17 @@ export async function vibeUpdateCommand(id, options) {
|
|
|
99
120
|
}
|
|
100
121
|
catch {
|
|
101
122
|
const msg = 'Invalid JSON in --metadata option';
|
|
102
|
-
|
|
103
|
-
console.error(JSON.stringify({ error: { message: msg } }));
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
console.error(`Error: ${msg}`);
|
|
107
|
-
}
|
|
108
|
-
process.exitCode = 1;
|
|
123
|
+
printValidationError(msg, options.json);
|
|
109
124
|
return;
|
|
110
125
|
}
|
|
111
126
|
}
|
|
112
127
|
if (options.type && !VALID_VIBE_TYPES.includes(options.type)) {
|
|
113
|
-
const msg =
|
|
114
|
-
|
|
115
|
-
console.error(JSON.stringify({ error: { message: msg } }));
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
console.error(`Error: ${msg}`);
|
|
119
|
-
}
|
|
120
|
-
process.exitCode = 1;
|
|
128
|
+
const msg = vibeTypeError(options.type);
|
|
129
|
+
printValidationError(msg, options.json);
|
|
121
130
|
return;
|
|
122
131
|
}
|
|
123
132
|
try {
|
|
133
|
+
await confirmWriteTarget('update vibe', options, 'existing');
|
|
124
134
|
const client = await createAdapter(options.area);
|
|
125
135
|
const response = (await client.updateVibe(id, {
|
|
126
136
|
type: options.type,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vibes.js","sourceRoot":"","sources":["../../src/commands/vibes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"vibes.js","sourceRoot":"","sources":["../../src/commands/vibes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzG,OAAO,EAAE,eAAe,EAAgB,MAAM,qBAAqB,CAAC;AA+DpE;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC;AAEhG,gFAAgF;AAChF,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,IAAI,KAAK,MAAM;QACpB,CAAC,CAAC,uFAAuF;YACrF,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QACrC,CAAC,CAAC,sBAAsB,IAAI,aAAa,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AAC3E,CAAC;AAED,iBAAiB;AAEjB,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OASC;IAED,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACrB,oBAAoB,CAClB,0EAA0E,EAC1E,OAAO,CAAC,IAAI,CACb,CAAC;QACF,OAAO;IACT,CAAC;IAED,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7C,MAAM,GAAG,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI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AAO,CAAC,IAAI,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7D,MAAM,GAAG,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACxC,oBAAoB,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACxC,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,kBAAkB,CAAC,aAAa,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjD,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE;YAC5C,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,QAAQ;SACT,CAAC,CAAuB,CAAC;QAE1B,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;YAC1C,OAAO;QACT,CAAC;QAED,YAAY,CAAC,QAAQ,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;IAC3D,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
|
@@ -21,6 +21,17 @@ export declare const CURRENT_SCHEMA_VERSION = 1;
|
|
|
21
21
|
export declare const DEFAULT_API_HOST = "https://app.orbitmap.ai";
|
|
22
22
|
/** Default Agent API base URL: {@link DEFAULT_API_HOST} + the `/api/agent` prefix. */
|
|
23
23
|
export declare const DEFAULT_API_URL = "https://app.orbitmap.ai/api/agent";
|
|
24
|
+
/**
|
|
25
|
+
* The Agent API base URL for this process: `ORBITMAP_API_URL` env → {@link DEFAULT_API_URL}.
|
|
26
|
+
*
|
|
27
|
+
* The single source of truth for "which host am I talking to", shared by {@link resolveAuth}
|
|
28
|
+
* and by `init`. They used to disagree: `init` hardcoded the default, so a non-interactive
|
|
29
|
+
* `init --key …` validated a dev key against production and failed with "Invalid API key"
|
|
30
|
+
* while every later command in the same shell happily used the dev host. There is
|
|
31
|
+
* deliberately no config-file override (ADR 0002) — a stale pinned host is worse than an
|
|
32
|
+
* env var the caller can see.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveApiUrl(): string;
|
|
24
35
|
/** Reset the once-per-process migration latch. Tests only. */
|
|
25
36
|
export declare function resetConfigMigrationForTests(): void;
|
|
26
37
|
/** Load `~/.orbitmap/config.json` (or the XDG/legacy equivalent). Runs the one-time
|
package/dist/config.js
CHANGED
|
@@ -20,6 +20,19 @@ const LEGACY_AGENT_PROFILE = 'default';
|
|
|
20
20
|
export const DEFAULT_API_HOST = 'https://app.orbitmap.ai';
|
|
21
21
|
/** Default Agent API base URL: {@link DEFAULT_API_HOST} + the `/api/agent` prefix. */
|
|
22
22
|
export const DEFAULT_API_URL = `${DEFAULT_API_HOST}/api/agent`;
|
|
23
|
+
/**
|
|
24
|
+
* The Agent API base URL for this process: `ORBITMAP_API_URL` env → {@link DEFAULT_API_URL}.
|
|
25
|
+
*
|
|
26
|
+
* The single source of truth for "which host am I talking to", shared by {@link resolveAuth}
|
|
27
|
+
* and by `init`. They used to disagree: `init` hardcoded the default, so a non-interactive
|
|
28
|
+
* `init --key …` validated a dev key against production and failed with "Invalid API key"
|
|
29
|
+
* while every later command in the same shell happily used the dev host. There is
|
|
30
|
+
* deliberately no config-file override (ADR 0002) — a stale pinned host is worse than an
|
|
31
|
+
* env var the caller can see.
|
|
32
|
+
*/
|
|
33
|
+
export function resolveApiUrl() {
|
|
34
|
+
return process.env['ORBITMAP_API_URL'] || DEFAULT_API_URL;
|
|
35
|
+
}
|
|
23
36
|
// ── Raw file I/O ────────────────────────────────────────────────────────────
|
|
24
37
|
/** The file's JSON object exactly as written, or `undefined` when it is missing,
|
|
25
38
|
* unreadable or not a JSON object. Used to preserve keys this version does not know. */
|
|
@@ -197,7 +210,7 @@ export async function saveProjectConfig(config, dir = process.cwd()) {
|
|
|
197
210
|
export async function resolveAuth(options = {}) {
|
|
198
211
|
const cwd = options.cwd ?? process.cwd();
|
|
199
212
|
const config = options.config ?? (await loadConfig());
|
|
200
|
-
const apiUrl =
|
|
213
|
+
const apiUrl = resolveApiUrl();
|
|
201
214
|
let apiKey = process.env['ORBITMAP_API_KEY'];
|
|
202
215
|
if (!apiKey) {
|
|
203
216
|
const agent = process.env['ORBITMAP_AGENT'] ||
|
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,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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C,CAAC,EAAE,OAAO,CAAC;IACpD,CAAC;IAED,qFAAqF;IACrF,IAAI,CAAC,MAAM;QAAE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC;IAErC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC"}
|
package/dist/doc-cache.d.ts
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The document cache — **one copy of a document per machine, globally** (IN-rwb5qu).
|
|
3
|
+
*
|
|
4
|
+
* Where that copy lives is resolved, not assumed:
|
|
5
|
+
*
|
|
6
|
+
* - **cloud mode** — `<project>/.orbitmap/docs/`, where `<project>` is the nearest ancestor
|
|
7
|
+
* of the current directory that owns an `.orbitmap/` ({@link findProjectOrbitMapDir}).
|
|
8
|
+
* - **local mode** — `<workspace>/docs/`, the workspace's own documents directory. Those
|
|
9
|
+
* files *are* the documents, so nothing here downloads over them, writes a manifest next
|
|
10
|
+
* to them or cleans them up; that is what {@link DocCache.managed} distinguishes.
|
|
11
|
+
*
|
|
12
|
+
* For the ordinary in-project local workspace (`<project>/.orbitmap`) the two are literally
|
|
13
|
+
* the same path, which is the point: identical location and identical format in both modes.
|
|
14
|
+
* There are **no per-area subdirectories** — the data model does not record which area a
|
|
15
|
+
* document belongs to, so the directory tree must not pretend it does.
|
|
16
|
+
*
|
|
17
|
+
* This replaces a bare `join('.orbitmap', 'docs')` resolved against `process.cwd()` with no
|
|
18
|
+
* walk-up, which gave every subdirectory a command ran from its own private copy of every
|
|
19
|
+
* document.
|
|
20
|
+
*/
|
|
1
21
|
import type { WorkspaceAdapter } from './adapters/types.js';
|
|
22
|
+
import { type ResolvedWorkspaceContext, type ResolveOptions } from './workspace-resolve.js';
|
|
2
23
|
export interface ManifestEntry {
|
|
3
24
|
doc_id: string;
|
|
4
25
|
version: number;
|
|
@@ -14,9 +35,50 @@ export interface DownloadResult {
|
|
|
14
35
|
cached: boolean;
|
|
15
36
|
slug: string;
|
|
16
37
|
}
|
|
17
|
-
|
|
18
|
-
export
|
|
19
|
-
|
|
38
|
+
/** Where the one copy of every document lives for the current invocation. */
|
|
39
|
+
export interface DocCache {
|
|
40
|
+
/** Absolute directory holding `<slug>.md`. */
|
|
41
|
+
dir: string;
|
|
42
|
+
/**
|
|
43
|
+
* True when the CLI **owns** this directory as a cache (cloud mode): downloads are written
|
|
44
|
+
* into it, `.manifest.json` tracks them, stale files may be deleted and the directory is
|
|
45
|
+
* gitignored.
|
|
46
|
+
*
|
|
47
|
+
* False in local mode, where the very same directory is the workspace's own `docs/` —
|
|
48
|
+
* domain data, meant to be committed. Every write path below is a no-op then: the document
|
|
49
|
+
* is already there, in the same format, and re-downloading it would replace a file that
|
|
50
|
+
* carries YAML frontmatter with a frontmatter-less copy of its body.
|
|
51
|
+
*/
|
|
52
|
+
managed: boolean;
|
|
53
|
+
/** Project root whose `.gitignore` covers {@link DocCache.dir}. Only set when `managed`. */
|
|
54
|
+
gitignoreRoot?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Resolve the doc cache for this invocation through the ordinary context ladder (so the
|
|
58
|
+
* mode, the workspace directory and every override behave exactly as they do everywhere
|
|
59
|
+
* else). Commands resolve it once and hand it to the functions below.
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveDocCache(options?: ResolveOptions): Promise<DocCache>;
|
|
62
|
+
/** {@link resolveDocCache} for a context that is already resolved. */
|
|
63
|
+
export declare function docCacheFor(context: Pick<ResolvedWorkspaceContext, 'mode' | 'workspacePath'>, cwd?: string): DocCache;
|
|
64
|
+
/** Cached documents this CLI is tracking; always empty for an unmanaged (local) directory. */
|
|
65
|
+
export declare function readManifest(cache: DocCache): Manifest;
|
|
66
|
+
/** Persist the manifest; a no-op for an unmanaged (local) directory, which has none. */
|
|
67
|
+
export declare function writeManifest(cache: DocCache, manifest: Manifest): void;
|
|
68
|
+
/**
|
|
69
|
+
* Keep the doc cache out of git, in the `.gitignore` that actually covers it.
|
|
70
|
+
*
|
|
71
|
+
* Two things the old unconditional `ensureGitignore()` inside `downloadDocument` got wrong
|
|
72
|
+
* now that the cache is resolved rather than assumed:
|
|
73
|
+
*
|
|
74
|
+
* - it wrote into `process.cwd()`, which since the walk-up is no longer the project the cache
|
|
75
|
+
* belongs to — the entries are relative to that project's root, so they must land in that
|
|
76
|
+
* root's `.gitignore` or they ignore nothing;
|
|
77
|
+
* - it ran in local mode too, where `<workspace>/docs/` is domain data the user is meant to
|
|
78
|
+
* commit. Ignoring it there would quietly drop the workspace's documents from the
|
|
79
|
+
* repository, which is the opposite of what local mode is for.
|
|
80
|
+
*/
|
|
81
|
+
export declare function ensureDocCacheGitignore(cache: DocCache): string[];
|
|
20
82
|
/**
|
|
21
83
|
* Append any of `entries` missing from `<cwd>/.gitignore` (creating the file if needed) and
|
|
22
84
|
* return the entries actually written.
|
|
@@ -38,7 +100,14 @@ export declare function ensureGitignore(entries?: string[], cwd?: string): strin
|
|
|
38
100
|
* shadowing would be a false alarm.
|
|
39
101
|
*/
|
|
40
102
|
export declare function gitignoreShadowsProjectConfig(cwd?: string): boolean;
|
|
41
|
-
export declare function downloadDocument(client: WorkspaceAdapter, idOrSlug: string): Promise<DownloadResult>;
|
|
42
|
-
|
|
103
|
+
export declare function downloadDocument(client: WorkspaceAdapter, idOrSlug: string, cache: DocCache): Promise<DownloadResult>;
|
|
104
|
+
/**
|
|
105
|
+
* Drop cached documents that are stale *and* no longer offered by the workspace.
|
|
106
|
+
*
|
|
107
|
+
* Never touches an unmanaged (local) directory: those files are the documents themselves,
|
|
108
|
+
* and a `.manifest.json` left behind there by a pre-v2 doc cache would otherwise name them
|
|
109
|
+
* as deletable. (The v1 → v2 migration removes that manifest; this is the second lock.)
|
|
110
|
+
*/
|
|
111
|
+
export declare function cleanupCache(availableDocSlugs: string[], cache: DocCache): {
|
|
43
112
|
removed: string[];
|
|
44
113
|
};
|
package/dist/doc-cache.js
CHANGED
|
@@ -1,13 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The document cache — **one copy of a document per machine, globally** (IN-rwb5qu).
|
|
3
|
+
*
|
|
4
|
+
* Where that copy lives is resolved, not assumed:
|
|
5
|
+
*
|
|
6
|
+
* - **cloud mode** — `<project>/.orbitmap/docs/`, where `<project>` is the nearest ancestor
|
|
7
|
+
* of the current directory that owns an `.orbitmap/` ({@link findProjectOrbitMapDir}).
|
|
8
|
+
* - **local mode** — `<workspace>/docs/`, the workspace's own documents directory. Those
|
|
9
|
+
* files *are* the documents, so nothing here downloads over them, writes a manifest next
|
|
10
|
+
* to them or cleans them up; that is what {@link DocCache.managed} distinguishes.
|
|
11
|
+
*
|
|
12
|
+
* For the ordinary in-project local workspace (`<project>/.orbitmap`) the two are literally
|
|
13
|
+
* the same path, which is the point: identical location and identical format in both modes.
|
|
14
|
+
* There are **no per-area subdirectories** — the data model does not record which area a
|
|
15
|
+
* document belongs to, so the directory tree must not pretend it does.
|
|
16
|
+
*
|
|
17
|
+
* This replaces a bare `join('.orbitmap', 'docs')` resolved against `process.cwd()` with no
|
|
18
|
+
* walk-up, which gave every subdirectory a command ran from its own private copy of every
|
|
19
|
+
* document.
|
|
20
|
+
*/
|
|
1
21
|
import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync, statSync } from 'node:fs';
|
|
2
|
-
import { join, dirname } from 'node:path';
|
|
3
|
-
|
|
4
|
-
|
|
22
|
+
import { join, dirname, resolve } from 'node:path';
|
|
23
|
+
import { DOCS_DIR, DOC_CACHE_MANIFEST, ORBITMAP_DIR, findProjectOrbitMapDir, } from './paths.js';
|
|
24
|
+
import { LINK_FILE, resolveWorkspaceContext, } from './workspace-resolve.js';
|
|
5
25
|
const STALE_DAYS = 7;
|
|
6
|
-
|
|
7
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Resolve the doc cache for this invocation through the ordinary context ladder (so the
|
|
28
|
+
* mode, the workspace directory and every override behave exactly as they do everywhere
|
|
29
|
+
* else). Commands resolve it once and hand it to the functions below.
|
|
30
|
+
*/
|
|
31
|
+
export async function resolveDocCache(options = {}) {
|
|
32
|
+
const context = await resolveWorkspaceContext(options);
|
|
33
|
+
return docCacheFor(context, options.cwd);
|
|
34
|
+
}
|
|
35
|
+
/** {@link resolveDocCache} for a context that is already resolved. */
|
|
36
|
+
export function docCacheFor(context, cwd = process.cwd()) {
|
|
37
|
+
if (context.mode === 'local' && context.workspacePath) {
|
|
38
|
+
return { dir: join(context.workspacePath, DOCS_DIR), managed: false };
|
|
39
|
+
}
|
|
40
|
+
const start = resolve(cwd);
|
|
41
|
+
const root = findProjectOrbitMapDir(start) ?? start;
|
|
42
|
+
return {
|
|
43
|
+
dir: join(root, ORBITMAP_DIR, DOCS_DIR),
|
|
44
|
+
managed: true,
|
|
45
|
+
gitignoreRoot: root,
|
|
46
|
+
};
|
|
8
47
|
}
|
|
9
|
-
|
|
10
|
-
|
|
48
|
+
/** Cached documents this CLI is tracking; always empty for an unmanaged (local) directory. */
|
|
49
|
+
export function readManifest(cache) {
|
|
50
|
+
if (!cache.managed)
|
|
51
|
+
return {};
|
|
52
|
+
const manifestPath = join(cache.dir, DOC_CACHE_MANIFEST);
|
|
11
53
|
if (!existsSync(manifestPath))
|
|
12
54
|
return {};
|
|
13
55
|
try {
|
|
@@ -17,8 +59,11 @@ export function readManifest() {
|
|
|
17
59
|
return {};
|
|
18
60
|
}
|
|
19
61
|
}
|
|
20
|
-
|
|
21
|
-
|
|
62
|
+
/** Persist the manifest; a no-op for an unmanaged (local) directory, which has none. */
|
|
63
|
+
export function writeManifest(cache, manifest) {
|
|
64
|
+
if (!cache.managed)
|
|
65
|
+
return;
|
|
66
|
+
const manifestPath = join(cache.dir, DOC_CACHE_MANIFEST);
|
|
22
67
|
mkdirSync(dirname(manifestPath), { recursive: true });
|
|
23
68
|
writeFileSync(manifestPath, JSON.stringify(manifest, null, 2), 'utf-8');
|
|
24
69
|
}
|
|
@@ -28,7 +73,28 @@ export function writeManifest(manifest) {
|
|
|
28
73
|
* — `<project>/.orbitmap/config.json` (ADR 0002) lives in the same directory and is meant
|
|
29
74
|
* to be committed, so ignoring the whole directory would silently swallow it.
|
|
30
75
|
*/
|
|
31
|
-
const DEFAULT_GITIGNORE_ENTRIES = [
|
|
76
|
+
const DEFAULT_GITIGNORE_ENTRIES = [
|
|
77
|
+
`${ORBITMAP_DIR}/${DOCS_DIR}/`,
|
|
78
|
+
`${ORBITMAP_DIR}/${LINK_FILE}`,
|
|
79
|
+
];
|
|
80
|
+
/**
|
|
81
|
+
* Keep the doc cache out of git, in the `.gitignore` that actually covers it.
|
|
82
|
+
*
|
|
83
|
+
* Two things the old unconditional `ensureGitignore()` inside `downloadDocument` got wrong
|
|
84
|
+
* now that the cache is resolved rather than assumed:
|
|
85
|
+
*
|
|
86
|
+
* - it wrote into `process.cwd()`, which since the walk-up is no longer the project the cache
|
|
87
|
+
* belongs to — the entries are relative to that project's root, so they must land in that
|
|
88
|
+
* root's `.gitignore` or they ignore nothing;
|
|
89
|
+
* - it ran in local mode too, where `<workspace>/docs/` is domain data the user is meant to
|
|
90
|
+
* commit. Ignoring it there would quietly drop the workspace's documents from the
|
|
91
|
+
* repository, which is the opposite of what local mode is for.
|
|
92
|
+
*/
|
|
93
|
+
export function ensureDocCacheGitignore(cache) {
|
|
94
|
+
if (!cache.managed || !cache.gitignoreRoot)
|
|
95
|
+
return [];
|
|
96
|
+
return ensureGitignore(DEFAULT_GITIGNORE_ENTRIES, cache.gitignoreRoot);
|
|
97
|
+
}
|
|
32
98
|
/**
|
|
33
99
|
* Append any of `entries` missing from `<cwd>/.gitignore` (creating the file if needed) and
|
|
34
100
|
* return the entries actually written.
|
|
@@ -96,26 +162,35 @@ function normalizeGitignoreLine(line) {
|
|
|
96
162
|
const withoutComment = line.replace(/(?:^|\s)#.*$/, '');
|
|
97
163
|
return withoutComment.trim();
|
|
98
164
|
}
|
|
99
|
-
export async function downloadDocument(client, idOrSlug) {
|
|
165
|
+
export async function downloadDocument(client, idOrSlug, cache) {
|
|
100
166
|
const response = (await client.getDocument(idOrSlug, 'file'));
|
|
101
167
|
const doc = response.data;
|
|
102
168
|
const slug = doc.slug;
|
|
103
|
-
|
|
169
|
+
// Local mode: the workspace file the adapter just read *is* the copy. Nothing to download,
|
|
170
|
+
// nothing to record — and nothing may be written over it (see `DocCache.managed`).
|
|
171
|
+
if (!cache.managed) {
|
|
172
|
+
const filePath = join(cache.dir, `${slug}.md`);
|
|
173
|
+
if (!existsSync(filePath)) {
|
|
174
|
+
throw new Error(`Document ${slug} is not stored in this workspace (${filePath}).`);
|
|
175
|
+
}
|
|
176
|
+
return { filePath, version: doc.version, cached: true, slug };
|
|
177
|
+
}
|
|
178
|
+
const manifest = readManifest(cache);
|
|
104
179
|
const existing = manifest[slug];
|
|
105
180
|
// Version match — skip download
|
|
106
181
|
if (existing && existing.version === doc.version) {
|
|
107
|
-
const filePath = join(
|
|
182
|
+
const filePath = join(cache.dir, existing.file);
|
|
108
183
|
if (existsSync(filePath)) {
|
|
109
184
|
existing.last_accessed = new Date().toISOString();
|
|
110
|
-
writeManifest(manifest);
|
|
185
|
+
writeManifest(cache, manifest);
|
|
111
186
|
return { filePath, version: doc.version, cached: true, slug };
|
|
112
187
|
}
|
|
113
188
|
}
|
|
114
189
|
// Need to download
|
|
115
|
-
mkdirSync(
|
|
116
|
-
|
|
190
|
+
mkdirSync(cache.dir, { recursive: true });
|
|
191
|
+
ensureDocCacheGitignore(cache);
|
|
117
192
|
const fileName = `${slug}.md`;
|
|
118
|
-
const filePath = join(
|
|
193
|
+
const filePath = join(cache.dir, fileName);
|
|
119
194
|
if (doc.download_url) {
|
|
120
195
|
const res = await fetch(doc.download_url);
|
|
121
196
|
if (!res.ok) {
|
|
@@ -141,11 +216,20 @@ export async function downloadDocument(client, idOrSlug) {
|
|
|
141
216
|
size_bytes: size,
|
|
142
217
|
file: fileName,
|
|
143
218
|
};
|
|
144
|
-
writeManifest(manifest);
|
|
219
|
+
writeManifest(cache, manifest);
|
|
145
220
|
return { filePath, version: doc.version, cached: false, slug };
|
|
146
221
|
}
|
|
147
|
-
|
|
148
|
-
|
|
222
|
+
/**
|
|
223
|
+
* Drop cached documents that are stale *and* no longer offered by the workspace.
|
|
224
|
+
*
|
|
225
|
+
* Never touches an unmanaged (local) directory: those files are the documents themselves,
|
|
226
|
+
* and a `.manifest.json` left behind there by a pre-v2 doc cache would otherwise name them
|
|
227
|
+
* as deletable. (The v1 → v2 migration removes that manifest; this is the second lock.)
|
|
228
|
+
*/
|
|
229
|
+
export function cleanupCache(availableDocSlugs, cache) {
|
|
230
|
+
if (!cache.managed)
|
|
231
|
+
return { removed: [] };
|
|
232
|
+
const manifest = readManifest(cache);
|
|
149
233
|
const slugSet = new Set(availableDocSlugs);
|
|
150
234
|
const now = Date.now();
|
|
151
235
|
const staleMs = STALE_DAYS * 24 * 60 * 60 * 1000;
|
|
@@ -157,7 +241,7 @@ export function cleanupCache(availableDocSlugs) {
|
|
|
157
241
|
if (now - lastAccessed <= staleMs)
|
|
158
242
|
continue;
|
|
159
243
|
// Stale and not in available docs — remove
|
|
160
|
-
const filePath = join(
|
|
244
|
+
const filePath = join(cache.dir, entry.file);
|
|
161
245
|
try {
|
|
162
246
|
if (existsSync(filePath))
|
|
163
247
|
unlinkSync(filePath);
|
|
@@ -169,7 +253,7 @@ export function cleanupCache(availableDocSlugs) {
|
|
|
169
253
|
removed.push(slug);
|
|
170
254
|
}
|
|
171
255
|
if (removed.length > 0) {
|
|
172
|
-
writeManifest(manifest);
|
|
256
|
+
writeManifest(cache, manifest);
|
|
173
257
|
}
|
|
174
258
|
return { removed };
|
|
175
259
|
}
|