@aigile/engine 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action-item-features.d.ts +33 -0
- package/dist/action-item-features.d.ts.map +1 -0
- package/dist/action-item-features.js +113 -0
- package/dist/action-item-features.js.map +1 -0
- package/dist/action-items.d.ts +234 -0
- package/dist/action-items.d.ts.map +1 -0
- package/dist/action-items.js +722 -0
- package/dist/action-items.js.map +1 -0
- package/dist/action-sources.d.ts +44 -0
- package/dist/action-sources.d.ts.map +1 -0
- package/dist/action-sources.js +141 -0
- package/dist/action-sources.js.map +1 -0
- package/dist/agent-roles.d.ts +9 -0
- package/dist/agent-roles.d.ts.map +1 -0
- package/dist/agent-roles.js +18 -0
- package/dist/agent-roles.js.map +1 -0
- package/dist/agent-tasks.d.ts +36 -0
- package/dist/agent-tasks.d.ts.map +1 -0
- package/dist/agent-tasks.js +151 -0
- package/dist/agent-tasks.js.map +1 -0
- package/dist/agents/orchestrator.d.ts +26 -6
- package/dist/agents/orchestrator.d.ts.map +1 -1
- package/dist/agents/orchestrator.js +95 -45
- package/dist/agents/orchestrator.js.map +1 -1
- package/dist/agents/spec-analyst.d.ts +81 -13
- package/dist/agents/spec-analyst.d.ts.map +1 -1
- package/dist/agents/spec-analyst.js +350 -89
- package/dist/agents/spec-analyst.js.map +1 -1
- package/dist/ai-service.d.ts +40 -0
- package/dist/ai-service.d.ts.map +1 -1
- package/dist/ai-service.js +94 -9
- package/dist/ai-service.js.map +1 -1
- package/dist/api-tokens.d.ts +67 -0
- package/dist/api-tokens.d.ts.map +1 -0
- package/dist/api-tokens.js +89 -0
- package/dist/api-tokens.js.map +1 -0
- package/dist/attachments/extract.d.ts +26 -0
- package/dist/attachments/extract.d.ts.map +1 -0
- package/dist/attachments/extract.js +160 -0
- package/dist/attachments/extract.js.map +1 -0
- package/dist/attachments/fixtures.d.ts +9 -0
- package/dist/attachments/fixtures.d.ts.map +1 -0
- package/dist/attachments/fixtures.js +58 -0
- package/dist/attachments/fixtures.js.map +1 -0
- package/dist/attachments/service.d.ts +71 -0
- package/dist/attachments/service.d.ts.map +1 -0
- package/dist/attachments/service.js +220 -0
- package/dist/attachments/service.js.map +1 -0
- package/dist/build-service.d.ts +1 -1
- package/dist/build-service.d.ts.map +1 -1
- package/dist/build-service.js +9 -4
- package/dist/build-service.js.map +1 -1
- package/dist/change-events.d.ts +110 -0
- package/dist/change-events.d.ts.map +1 -0
- package/dist/change-events.js +238 -0
- package/dist/change-events.js.map +1 -0
- package/dist/change-sets.d.ts +110 -0
- package/dist/change-sets.d.ts.map +1 -0
- package/dist/change-sets.js +188 -0
- package/dist/change-sets.js.map +1 -0
- package/dist/command-runner.d.ts.map +1 -1
- package/dist/command-runner.js +2 -1
- package/dist/command-runner.js.map +1 -1
- package/dist/conversations.d.ts +2 -1
- package/dist/conversations.d.ts.map +1 -1
- package/dist/conversations.js +1 -1
- package/dist/conversations.js.map +1 -1
- package/dist/data-access.d.ts +9 -2
- package/dist/data-access.d.ts.map +1 -1
- package/dist/data-access.js +38 -6
- package/dist/data-access.js.map +1 -1
- package/dist/decisions.d.ts +56 -0
- package/dist/decisions.d.ts.map +1 -0
- package/dist/decisions.js +76 -0
- package/dist/decisions.js.map +1 -0
- package/dist/deliverables.d.ts +96 -0
- package/dist/deliverables.d.ts.map +1 -0
- package/dist/deliverables.js +344 -0
- package/dist/deliverables.js.map +1 -0
- package/dist/designs.d.ts +30 -0
- package/dist/designs.d.ts.map +1 -0
- package/dist/designs.js +154 -0
- package/dist/designs.js.map +1 -0
- package/dist/git-host.d.ts +10 -0
- package/dist/git-host.d.ts.map +1 -1
- package/dist/git-host.js +30 -2
- package/dist/git-host.js.map +1 -1
- package/dist/grounding.d.ts +9 -0
- package/dist/grounding.d.ts.map +1 -0
- package/dist/grounding.js +12 -0
- package/dist/grounding.js.map +1 -0
- package/dist/index.d.ts +35 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -10
- package/dist/index.js.map +1 -1
- package/dist/jira-features.d.ts +142 -0
- package/dist/jira-features.d.ts.map +1 -0
- package/dist/jira-features.js +366 -0
- package/dist/jira-features.js.map +1 -0
- package/dist/milestones.js +1 -1
- package/dist/milestones.js.map +1 -1
- package/dist/pull-request-sync.d.ts.map +1 -1
- package/dist/pull-request-sync.js +10 -6
- package/dist/pull-request-sync.js.map +1 -1
- package/dist/questions.d.ts +100 -10
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +211 -22
- package/dist/questions.js.map +1 -1
- package/dist/related.d.ts +26 -0
- package/dist/related.d.ts.map +1 -0
- package/dist/related.js +64 -0
- package/dist/related.js.map +1 -0
- package/dist/release-gates.d.ts +16 -0
- package/dist/release-gates.d.ts.map +1 -0
- package/dist/release-gates.js +47 -0
- package/dist/release-gates.js.map +1 -0
- package/dist/reviews.d.ts.map +1 -1
- package/dist/reviews.js +4 -3
- package/dist/reviews.js.map +1 -1
- package/dist/router.d.ts +2 -2
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js.map +1 -1
- package/dist/scheduler.d.ts +41 -5
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +109 -7
- package/dist/scheduler.js.map +1 -1
- package/dist/services.d.ts +760 -15
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js +402 -20
- package/dist/services.js.map +1 -1
- package/dist/source-sync.d.ts +136 -0
- package/dist/source-sync.d.ts.map +1 -0
- package/dist/source-sync.js +370 -0
- package/dist/source-sync.js.map +1 -0
- package/dist/sources/front-matter.d.ts +20 -0
- package/dist/sources/front-matter.d.ts.map +1 -0
- package/dist/sources/front-matter.js +57 -0
- package/dist/sources/front-matter.js.map +1 -0
- package/dist/sources/git.d.ts +80 -0
- package/dist/sources/git.d.ts.map +1 -0
- package/dist/sources/git.js +338 -0
- package/dist/sources/git.js.map +1 -0
- package/dist/sources/http.d.ts +54 -0
- package/dist/sources/http.d.ts.map +1 -0
- package/dist/sources/http.js +79 -0
- package/dist/sources/http.js.map +1 -0
- package/dist/spec-cache.d.ts +54 -0
- package/dist/spec-cache.d.ts.map +1 -0
- package/dist/spec-cache.js +133 -0
- package/dist/spec-cache.js.map +1 -0
- package/dist/spec-links.d.ts +68 -0
- package/dist/spec-links.d.ts.map +1 -0
- package/dist/spec-links.js +144 -0
- package/dist/spec-links.js.map +1 -0
- package/dist/spec-reader.d.ts +44 -0
- package/dist/spec-reader.d.ts.map +1 -0
- package/dist/spec-reader.js +81 -0
- package/dist/spec-reader.js.map +1 -0
- package/dist/spec-resolver.d.ts +13 -1
- package/dist/spec-resolver.d.ts.map +1 -1
- package/dist/spec-resolver.js +45 -8
- package/dist/spec-resolver.js.map +1 -1
- package/dist/spec-tools.d.ts +10 -0
- package/dist/spec-tools.d.ts.map +1 -0
- package/dist/spec-tools.js +103 -0
- package/dist/spec-tools.js.map +1 -0
- package/dist/task-scope.d.ts +11 -0
- package/dist/task-scope.d.ts.map +1 -0
- package/dist/task-scope.js +11 -0
- package/dist/task-scope.js.map +1 -0
- package/dist/telemetry.d.ts +34 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +72 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/template.d.ts +341 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/template.js +142 -0
- package/dist/template.js.map +1 -0
- package/dist/tool-sandbox.d.ts.map +1 -1
- package/dist/tool-sandbox.js +2 -2
- package/dist/tool-sandbox.js.map +1 -1
- package/dist/tracks.d.ts +3 -3
- package/dist/tracks.js +1 -1
- package/dist/tracks.js.map +1 -1
- package/dist/verifier.d.ts.map +1 -1
- package/dist/verifier.js +8 -7
- package/dist/verifier.js.map +1 -1
- package/dist/vscode-connect.d.ts +48 -0
- package/dist/vscode-connect.d.ts.map +1 -0
- package/dist/vscode-connect.js +105 -0
- package/dist/vscode-connect.js.map +1 -0
- package/package.json +14 -3
- package/prompts/agent-task.contract.md +9 -0
- package/prompts/orchestrator.brief.md +17 -0
- package/prompts/orchestrator.contract.md +7 -0
- package/prompts/spec-analyst.brief.md +19 -0
- package/prompts/spec-analyst.contract.md +5 -0
- package/prompts/spec-analyst.sweep.md +2 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { telemetry } from './telemetry.js';
|
|
2
|
+
import { COLLECTIONS, newId, nowIso, specReferencesSchema, specSchema, userSchema } from '@aigile/core';
|
|
3
|
+
import { AttachmentService } from './attachments/service.js';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { SERVICE_AUTHOR_ID } from './agents/spec-analyst.js';
|
|
6
|
+
import { DataAccess } from './data-access.js';
|
|
7
|
+
import { specReaderFor } from './spec-reader.js';
|
|
8
|
+
import { ServiceError } from './services.js';
|
|
9
|
+
/** Where a source's sync left off: one record per source in `source-cursors`. */
|
|
10
|
+
export const sourceCursorSchema = z.object({
|
|
11
|
+
id: z.string().min(1),
|
|
12
|
+
cursor: z.string().nullable().default(null),
|
|
13
|
+
syncedAt: z.string().datetime(),
|
|
14
|
+
/** The last sync's counts, for the status page. */
|
|
15
|
+
last: z.object({ added: z.number().int(), updated: z.number().int(), removed: z.number().int() }).nullable().default(null),
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* Mirrors spec sources into the datastore (documentation/sources.md). Each
|
|
19
|
+
* run asks every source what changed since its cursor and writes the result
|
|
20
|
+
* as spec revisions: a new document becomes a spec (author = the user whose
|
|
21
|
+
* email matches, else the service), a changed one a revision, a removed one a
|
|
22
|
+
* deletion (its history stays in the datastore). A spec that already exists
|
|
23
|
+
* keeps the mappings people set in aigile unless the document asks for its
|
|
24
|
+
* own; a new top document (no parent within the source) gets the source's
|
|
25
|
+
* defaults, and the documents under it inherit (documentation/sources.md
|
|
26
|
+
* "Outlines"). A document's parent comes from the source. Nothing is rewritten while the document's version is unchanged, so a
|
|
27
|
+
* sync of a quiet source makes no commit.
|
|
28
|
+
*/
|
|
29
|
+
export class SourceSync {
|
|
30
|
+
store;
|
|
31
|
+
sources;
|
|
32
|
+
log;
|
|
33
|
+
data;
|
|
34
|
+
running = null;
|
|
35
|
+
/** The last error logged per source, so a source that stays broken (no token yet) is logged once, not every tick. */
|
|
36
|
+
lastError = new Map();
|
|
37
|
+
/** The last run per source, for the status page and the API. */
|
|
38
|
+
reports = new Map();
|
|
39
|
+
attachments;
|
|
40
|
+
constructor(store, sources, log = (line) => console.warn(line), options = {}) {
|
|
41
|
+
this.store = store;
|
|
42
|
+
this.sources = sources;
|
|
43
|
+
this.log = log;
|
|
44
|
+
this.data = new DataAccess(store);
|
|
45
|
+
this.attachments = new AttachmentService(store, options.attachments, options.blobs ?? null);
|
|
46
|
+
}
|
|
47
|
+
/** The configured sources, for listing. */
|
|
48
|
+
list() {
|
|
49
|
+
return this.sources;
|
|
50
|
+
}
|
|
51
|
+
/** Sync every source (or the one named); one at a time, and never two runs at once. */
|
|
52
|
+
syncAll(onlyId) {
|
|
53
|
+
if (this.running)
|
|
54
|
+
return this.running;
|
|
55
|
+
this.running = (async () => {
|
|
56
|
+
const reports = [];
|
|
57
|
+
for (const source of this.sources) {
|
|
58
|
+
if (onlyId && source.id !== onlyId)
|
|
59
|
+
continue;
|
|
60
|
+
reports.push(await this.sync(source));
|
|
61
|
+
}
|
|
62
|
+
return reports;
|
|
63
|
+
})().finally(() => {
|
|
64
|
+
this.running = null;
|
|
65
|
+
});
|
|
66
|
+
return this.running;
|
|
67
|
+
}
|
|
68
|
+
/** Sync one source; an adapter failure is reported, never thrown, so one broken source does not stop the others. */
|
|
69
|
+
async sync(source) {
|
|
70
|
+
const report = { sourceId: source.id, kind: source.kind, added: 0, updated: 0, removed: 0, unknownMappings: [], cursor: null, error: null };
|
|
71
|
+
const started = Date.now();
|
|
72
|
+
try {
|
|
73
|
+
const state = await this.cursor(source.id);
|
|
74
|
+
report.cursor = state?.cursor ?? null;
|
|
75
|
+
await source.init();
|
|
76
|
+
const changes = await source.changes(state?.cursor ?? null);
|
|
77
|
+
const all = (await this.store.list(COLLECTIONS.specs)).flatMap((raw) => {
|
|
78
|
+
const parsed = specSchema.safeParse(raw);
|
|
79
|
+
return parsed.success ? [parsed.data] : [];
|
|
80
|
+
});
|
|
81
|
+
// One record per document: a second one (left by a write whose commit failed) is marked removed, keeping the live, placed, oldest one.
|
|
82
|
+
const mirrored = new Map();
|
|
83
|
+
const rank = (s) => [s.source.removedAt ? 1 : 0, s.parentId ? 0 : 1, s.createdAt];
|
|
84
|
+
const better = (a, b) => {
|
|
85
|
+
const [ra, rb] = [rank(a), rank(b)];
|
|
86
|
+
return ra[0] - rb[0] || ra[1] - rb[1] || ra[2].localeCompare(rb[2]);
|
|
87
|
+
};
|
|
88
|
+
for (const s of all.filter((x) => x.source?.sourceId === source.id).sort(better)) {
|
|
89
|
+
const keep = mirrored.get(s.source.externalId);
|
|
90
|
+
if (!keep) {
|
|
91
|
+
mirrored.set(s.source.externalId, s);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (!s.source.removedAt)
|
|
95
|
+
await this.store.put(COLLECTIONS.specs, s.id, { ...s, updatedAt: nowIso(), source: { ...s.source, removedAt: nowIso() } }, { message: `Spec ${s.title} is a second record of ${source.id} ${s.source.externalId}; ${keep.id} is kept` });
|
|
96
|
+
}
|
|
97
|
+
const reader = specReaderFor(this.store);
|
|
98
|
+
const [users, known] = await Promise.all([this.users(), this.knownIds()]);
|
|
99
|
+
const byEmail = new Map(users.filter((u) => u.email).map((u) => [u.email.toLowerCase(), u.id]));
|
|
100
|
+
// The spec the source's top documents sit under (config `under`), when it is mirrored.
|
|
101
|
+
const anchor = source.anchor;
|
|
102
|
+
const anchorId = !anchor ? null : 'specId' in anchor ? (all.some((s) => s.id === anchor.specId) ? anchor.specId : null) : (all.find((s) => s.source?.sourceId === anchor.sourceId && s.source.externalId === anchor.externalId && !s.source.removedAt)?.id ?? null);
|
|
103
|
+
// Ids first, so a document can name a parent that arrives in the same batch.
|
|
104
|
+
const fresh = new Map();
|
|
105
|
+
for (const item of changes.items)
|
|
106
|
+
if (!mirrored.has(item.externalId))
|
|
107
|
+
fresh.set(item.externalId, newId('spec'));
|
|
108
|
+
const idOf = (externalId) => mirrored.get(externalId)?.id ?? fresh.get(externalId) ?? null;
|
|
109
|
+
const seen = new Set();
|
|
110
|
+
// A source's first sync is an import: what it brings in is the baseline, not news, so the Spec Analyst does not review it page by page (a sweep reads it).
|
|
111
|
+
const firstSync = state === null;
|
|
112
|
+
const imported = [];
|
|
113
|
+
for (const item of changes.items) {
|
|
114
|
+
seen.add(item.externalId);
|
|
115
|
+
const existing = mirrored.get(item.externalId);
|
|
116
|
+
if (reader)
|
|
117
|
+
await reader.warm(source.id, item);
|
|
118
|
+
// A parent outside what this source mirrors (the page above an imported subtree) makes a top document, under the source's anchor when it has one; a spec a person anchored elsewhere stays there.
|
|
119
|
+
let parentId = item.parentExternalId === undefined ? (existing?.parentId ?? null) : item.parentExternalId === null ? null : idOf(item.parentExternalId);
|
|
120
|
+
if (parentId === null && anchorId)
|
|
121
|
+
parentId = anchorId;
|
|
122
|
+
if (existing?.anchored)
|
|
123
|
+
parentId = existing.parentId;
|
|
124
|
+
const order = existing?.anchored ? existing.order : item.order === undefined ? (existing?.order ?? null) : item.order;
|
|
125
|
+
const meta = item.meta ?? existing?.source?.meta ?? {};
|
|
126
|
+
if (existing && existing.source.version === item.version && !existing.source.removedAt && existing.parentId === parentId && existing.order === order && JSON.stringify(existing.source.meta ?? {}) === JSON.stringify(meta)) {
|
|
127
|
+
// The text is unchanged, but a full read (a reset) brings the references and files of pages mirrored before they were collected.
|
|
128
|
+
await this.links(source, existing, item, report);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const authorId = (item.author?.email && byEmail.get(item.author.email.toLowerCase())) || existing?.authorUserId || SERVICE_AUTHOR_ID;
|
|
132
|
+
const asked = item.mappings ?? (!existing && parentId === null && source.defaults ? source.defaults : null);
|
|
133
|
+
const mappings = asked ? this.resolveMappings({ ...item, mappings: asked }, known, report) : null;
|
|
134
|
+
const ts = nowIso();
|
|
135
|
+
const next = specSchema.parse({
|
|
136
|
+
...(existing ?? { id: fresh.get(item.externalId), createdAt: ts, organizationIds: [], projectIds: [], roleIds: [], userIds: [], seed: null }),
|
|
137
|
+
...(mappings ?? {}),
|
|
138
|
+
parentId,
|
|
139
|
+
order,
|
|
140
|
+
title: item.title,
|
|
141
|
+
content: item.content,
|
|
142
|
+
authorUserId: existing?.authorUserId ?? authorId,
|
|
143
|
+
updatedAt: ts,
|
|
144
|
+
source: { sourceId: source.id, kind: source.kind, externalId: item.externalId, version: item.version, url: item.url, syncedAt: ts, removedAt: null, meta },
|
|
145
|
+
});
|
|
146
|
+
await this.store.put(COLLECTIONS.specs, next.id, next, this.write(`${existing ? (existing.source.removedAt ? 'Restore' : 'Mirror') : 'Mirror new'} spec ${next.title} from ${source.id} @ ${item.version.slice(0, 12)}`, item));
|
|
147
|
+
await this.links(source, next, item, report);
|
|
148
|
+
if (existing)
|
|
149
|
+
report.updated++;
|
|
150
|
+
else {
|
|
151
|
+
report.added++;
|
|
152
|
+
if (firstSync)
|
|
153
|
+
imported.push(next.id);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// Gone from the source: the record stays (its relations, the builds that pinned it) but is marked removed and hidden; the source keeps the history.
|
|
157
|
+
const gone = changes.full ? [...mirrored.keys()].filter((id) => !seen.has(id)) : changes.removed.filter((id) => mirrored.has(id));
|
|
158
|
+
for (const externalId of gone) {
|
|
159
|
+
const spec = mirrored.get(externalId);
|
|
160
|
+
if (spec.source.removedAt)
|
|
161
|
+
continue;
|
|
162
|
+
await this.store.put(COLLECTIONS.specs, spec.id, { ...spec, updatedAt: nowIso(), source: { ...spec.source, removedAt: nowIso() } }, { message: `Spec ${spec.title} is gone from ${source.id}` });
|
|
163
|
+
report.removed++;
|
|
164
|
+
}
|
|
165
|
+
// A document that sits under another now but got the source's defaults as a top one (an import before its parent was known) inherits instead; the same placement, one tree.
|
|
166
|
+
if (source.defaults) {
|
|
167
|
+
const same = (a, b) => [...(a ?? [])].sort().join() === [...b].sort().join();
|
|
168
|
+
for (const raw of await this.store.list(COLLECTIONS.specs)) {
|
|
169
|
+
const parsed = specSchema.safeParse(raw);
|
|
170
|
+
if (!parsed.success)
|
|
171
|
+
continue;
|
|
172
|
+
const s = parsed.data;
|
|
173
|
+
if (s.source?.sourceId !== source.id || s.source.removedAt || !s.parentId)
|
|
174
|
+
continue;
|
|
175
|
+
if (s.organizationIds.length + s.projectIds.length === 0)
|
|
176
|
+
continue;
|
|
177
|
+
if (!same(source.defaults.organizationIds, s.organizationIds) || !same(source.defaults.projectIds, s.projectIds))
|
|
178
|
+
continue;
|
|
179
|
+
await this.store.put(COLLECTIONS.specs, s.id, { ...s, organizationIds: [], projectIds: [], updatedAt: nowIso() }, { message: `Spec ${s.title} now applies through its parent in ${source.id}` });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
for (const specId of imported) {
|
|
183
|
+
const revision = await this.data.specCurrentRevision(specId);
|
|
184
|
+
if (revision)
|
|
185
|
+
await this.store.put(COLLECTIONS.specReviews, specId, { specId, revision, status: 'baseline', at: nowIso() }, { message: `Baseline spec ${specId} @ ${revision.slice(0, 12)}: imported with ${source.id}'s first sync` });
|
|
186
|
+
}
|
|
187
|
+
report.cursor = changes.cursor;
|
|
188
|
+
const record = { id: source.id, cursor: changes.cursor, syncedAt: nowIso(), last: { added: report.added, updated: report.updated, removed: report.removed } };
|
|
189
|
+
if (!state || state.cursor !== record.cursor || report.added + report.updated + report.removed > 0) {
|
|
190
|
+
await this.store.put(COLLECTIONS.sourceCursors, source.id, record, { message: `Sync source ${source.id}` });
|
|
191
|
+
}
|
|
192
|
+
if (this.lastError.delete(source.id))
|
|
193
|
+
this.log(`[aigile] source ${source.id}: synced again`);
|
|
194
|
+
}
|
|
195
|
+
catch (err) {
|
|
196
|
+
report.error = err instanceof Error ? err.message : String(err);
|
|
197
|
+
if (this.lastError.get(source.id) !== report.error) {
|
|
198
|
+
this.lastError.set(source.id, report.error);
|
|
199
|
+
this.log(`[aigile] source ${source.id}: ${report.error}`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
this.reports.set(source.id, { ...report, at: nowIso() });
|
|
203
|
+
telemetry.sync(source.kind, Date.now() - started, { created: report.added, updated: report.updated, removed: report.removed }, !report.error);
|
|
204
|
+
return report;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Move a mirrored spec at its source (documentation/sources.md "Outlines"):
|
|
208
|
+
* before or after a sibling, or as the last child of another spec, both
|
|
209
|
+
* mirrored from the same source; then read the moved document back so the
|
|
210
|
+
* spec has its new parent and place at once. Before or after a top spec is
|
|
211
|
+
* refused: its siblings sit outside what the source mirrors.
|
|
212
|
+
*/
|
|
213
|
+
async move(spec, position, target) {
|
|
214
|
+
const source = this.sources.find((s) => s.id === spec.source?.sourceId);
|
|
215
|
+
if (!source || !spec.source)
|
|
216
|
+
throw new ServiceError(409, `spec ${spec.id} is not mirrored from a configured source`);
|
|
217
|
+
if (!source.move || !source.capabilities.move)
|
|
218
|
+
throw new ServiceError(409, `source ${source.id} (${source.kind}) does not move documents; move it there`);
|
|
219
|
+
if (target.source?.sourceId !== source.id)
|
|
220
|
+
throw new ServiceError(409, `a ${source.kind} page moves only among the pages of ${source.id}`);
|
|
221
|
+
if (target.id === spec.id)
|
|
222
|
+
throw new ServiceError(400, 'a spec cannot move relative to itself');
|
|
223
|
+
if (position !== 'append' && !target.parentId)
|
|
224
|
+
throw new ServiceError(409, `${target.title} is the top of ${source.id}: a page beside it would leave what the source mirrors`);
|
|
225
|
+
await source.move(spec.source.externalId, position, target.source.externalId);
|
|
226
|
+
return (await this.refreshOne(source, spec.source.externalId)) ?? spec;
|
|
227
|
+
}
|
|
228
|
+
/** Read one document again and bring its spec up to date (parent, place, title, text, version); null when the source no longer has it. */
|
|
229
|
+
async refreshOne(source, externalId) {
|
|
230
|
+
if (!source.read)
|
|
231
|
+
return null;
|
|
232
|
+
const item = await source.read(externalId);
|
|
233
|
+
if (!item)
|
|
234
|
+
return null;
|
|
235
|
+
const mirrored = new Map();
|
|
236
|
+
for (const raw of await this.store.list(COLLECTIONS.specs)) {
|
|
237
|
+
const parsed = specSchema.safeParse(raw);
|
|
238
|
+
if (parsed.success && parsed.data.source?.sourceId === source.id && !parsed.data.source.removedAt)
|
|
239
|
+
mirrored.set(parsed.data.source.externalId, parsed.data);
|
|
240
|
+
}
|
|
241
|
+
const existing = mirrored.get(externalId);
|
|
242
|
+
if (!existing)
|
|
243
|
+
return null;
|
|
244
|
+
const parentId = item.parentExternalId === undefined ? existing.parentId : item.parentExternalId === null ? null : (mirrored.get(item.parentExternalId)?.id ?? null);
|
|
245
|
+
const ts = nowIso();
|
|
246
|
+
const next = specSchema.parse({
|
|
247
|
+
...existing,
|
|
248
|
+
parentId,
|
|
249
|
+
order: item.order === undefined ? existing.order : item.order,
|
|
250
|
+
title: item.title,
|
|
251
|
+
content: item.content,
|
|
252
|
+
updatedAt: ts,
|
|
253
|
+
source: { ...existing.source, version: item.version, url: item.url, syncedAt: ts },
|
|
254
|
+
});
|
|
255
|
+
const reader = specReaderFor(this.store);
|
|
256
|
+
if (reader)
|
|
257
|
+
await reader.warm(source.id, item);
|
|
258
|
+
await this.store.put(COLLECTIONS.specs, next.id, next, this.write(`Moved spec ${next.title} in ${source.id}`, item));
|
|
259
|
+
return next;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Keep what the document points at (its references, beside the spec in
|
|
263
|
+
* `spec-references`) and its files (downloaded and read into
|
|
264
|
+
* `attachments`), when the source reported them; a source that did not
|
|
265
|
+
* leaves what the spec has. A file that fails is recorded, never thrown.
|
|
266
|
+
*/
|
|
267
|
+
async links(source, spec, item, report) {
|
|
268
|
+
if (item.references === undefined && item.attachments === undefined && item.self === undefined)
|
|
269
|
+
return;
|
|
270
|
+
const prior = specReferencesSchema.safeParse(await this.store.get(COLLECTIONS.specReferences, spec.id));
|
|
271
|
+
const before = prior.success ? prior.data : null;
|
|
272
|
+
const record = specReferencesSchema.parse({
|
|
273
|
+
id: spec.id,
|
|
274
|
+
specId: spec.id,
|
|
275
|
+
sourceId: source.id,
|
|
276
|
+
self: item.self ?? before?.self ?? { sourceKind: source.kind, id: item.externalId, title: item.title, ...(item.url ? { url: item.url } : {}) },
|
|
277
|
+
references: item.references ?? before?.references ?? [],
|
|
278
|
+
attachments: item.attachments ?? before?.attachments ?? [],
|
|
279
|
+
syncedAt: nowIso(),
|
|
280
|
+
});
|
|
281
|
+
const same = before && JSON.stringify({ ...before, syncedAt: '' }) === JSON.stringify({ ...record, syncedAt: '' });
|
|
282
|
+
if (!same)
|
|
283
|
+
await this.store.put(COLLECTIONS.specReferences, spec.id, record, { message: `References of spec ${spec.title} from ${source.id}: ${record.references.length} link(s), ${record.attachments.length} attachment(s)` });
|
|
284
|
+
if (item.attachments === undefined)
|
|
285
|
+
return;
|
|
286
|
+
try {
|
|
287
|
+
const r = await this.attachments.syncDocument(source, spec.id, item.externalId, item.attachments);
|
|
288
|
+
const sum = (report.attachments ??= { downloaded: 0, shared: 0, skipped: 0, failed: 0, removed: 0 });
|
|
289
|
+
sum.downloaded += r.downloaded;
|
|
290
|
+
sum.shared += r.shared;
|
|
291
|
+
sum.skipped += r.skipped;
|
|
292
|
+
sum.failed += r.failed;
|
|
293
|
+
sum.removed += r.removed;
|
|
294
|
+
}
|
|
295
|
+
catch (err) {
|
|
296
|
+
this.log(`[aigile] source ${source.id}: attachments of ${item.externalId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/** The last run of a source in this process, or null when it has not run here yet. */
|
|
300
|
+
lastReport(sourceId) {
|
|
301
|
+
return this.reports.get(sourceId) ?? null;
|
|
302
|
+
}
|
|
303
|
+
/** True while a run is in flight. */
|
|
304
|
+
get busy() {
|
|
305
|
+
return this.running !== null;
|
|
306
|
+
}
|
|
307
|
+
/** The sync's position for a source, or null before its first run. */
|
|
308
|
+
async cursor(sourceId) {
|
|
309
|
+
const raw = await this.store.get(COLLECTIONS.sourceCursors, sourceId);
|
|
310
|
+
return raw === null ? null : sourceCursorSchema.parse(raw);
|
|
311
|
+
}
|
|
312
|
+
/** Forget the position: the next sync takes everything again (a rewritten history, a moved source). */
|
|
313
|
+
async reset(sourceId) {
|
|
314
|
+
if ((await this.store.get(COLLECTIONS.sourceCursors, sourceId)) !== null) {
|
|
315
|
+
await this.store.delete(COLLECTIONS.sourceCursors, sourceId, { message: `Reset source ${sourceId}` });
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Make the specs mirrored from a source ordinary specs again (their
|
|
320
|
+
* provenance cleared, editable in aigile) and forget its cursor: for a
|
|
321
|
+
* source taken out of the config. Returns how many specs were released.
|
|
322
|
+
*/
|
|
323
|
+
async detach(sourceId) {
|
|
324
|
+
let n = 0;
|
|
325
|
+
for (const spec of await this.data.specs()) {
|
|
326
|
+
if (spec.source?.sourceId !== sourceId)
|
|
327
|
+
continue;
|
|
328
|
+
await this.store.put(COLLECTIONS.specs, spec.id, { ...spec, source: null, updatedAt: nowIso() }, { message: `Detach spec ${spec.title} from ${sourceId}` });
|
|
329
|
+
n++;
|
|
330
|
+
}
|
|
331
|
+
await this.reset(sourceId);
|
|
332
|
+
return n;
|
|
333
|
+
}
|
|
334
|
+
async users() {
|
|
335
|
+
return (await this.store.list(COLLECTIONS.users)).flatMap((raw) => {
|
|
336
|
+
const parsed = userSchema.safeParse(raw);
|
|
337
|
+
return parsed.success ? [parsed.data] : [];
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
write(message, item) {
|
|
341
|
+
return item.author?.email ? { message, author: { name: item.author.name, email: item.author.email } } : { message };
|
|
342
|
+
}
|
|
343
|
+
async knownIds() {
|
|
344
|
+
const [organizations, projects, roles] = await Promise.all([this.store.listIds(COLLECTIONS.organizations), this.store.listIds(COLLECTIONS.projects), this.store.listIds(COLLECTIONS.roles)]);
|
|
345
|
+
return { organizations: new Set(organizations), projects: new Set(projects), roles: new Set(roles) };
|
|
346
|
+
}
|
|
347
|
+
/** Keep the mappings that name something; report the rest instead of refusing the document. */
|
|
348
|
+
resolveMappings(item, known, report) {
|
|
349
|
+
const keep = (ids, set, what) => {
|
|
350
|
+
const out = [];
|
|
351
|
+
for (const id of ids ?? []) {
|
|
352
|
+
if (set.has(id))
|
|
353
|
+
out.push(id);
|
|
354
|
+
else
|
|
355
|
+
report.unknownMappings.push(`${item.title}: ${what} ${id}`);
|
|
356
|
+
}
|
|
357
|
+
return out;
|
|
358
|
+
};
|
|
359
|
+
return {
|
|
360
|
+
organizationIds: keep(item.mappings?.organizationIds, known.organizations, 'organization'),
|
|
361
|
+
projectIds: keep(item.mappings?.projectIds, known.projects, 'project'),
|
|
362
|
+
roleIds: keep(item.mappings?.roleIds, known.roles, 'role'),
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
/** True when a spec is mirrored from a source and so edited there, not in aigile. */
|
|
367
|
+
export function isMirrored(spec) {
|
|
368
|
+
return spec.source !== null && spec.source !== undefined;
|
|
369
|
+
}
|
|
370
|
+
//# sourceMappingURL=source-sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-sync.js","sourceRoot":"","sources":["../src/source-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,oBAAoB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACxG,OAAO,EAAE,iBAAiB,EAA0B,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CA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,GAAa,EAAE,CAAC;YACzB,KAAK,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,EAAE,CAAC;gBAC3B,IAAI,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;;oBACzB,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,KAAK,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC;YACnE,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC,CAAC;QACF,OAAO;YACL,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,EAAE,KAAK,CAAC,aAAa,EAAE,cAAc,CAAC;YAC1F,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC;YACtE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC;SAC3D,CAAC;IACJ,CAAC;CACF;AAED,qFAAqF;AACrF,MAAM,UAAU,UAAU,CAAC,IAA0B;IACnD,OAAO,IAAI,CAAC,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The front matter a spec document may carry: a `---` block of `key: value`
|
|
3
|
+
* lines at the top, with lists as `[a, b]` or as `- item` lines below the key.
|
|
4
|
+
* A deliberate subset of YAML (no nesting, no multi-line scalars), so no
|
|
5
|
+
* dependency: the keys aigile reads are `title`, `organizations`, `projects`
|
|
6
|
+
* and `roles`; anything else is kept for the caller and ignored by the sync.
|
|
7
|
+
*/
|
|
8
|
+
export interface FrontMatter {
|
|
9
|
+
data: Record<string, string | string[]>;
|
|
10
|
+
/** The document without its front matter block. */
|
|
11
|
+
body: string;
|
|
12
|
+
/** True when the document opened with a front matter block (even an empty one). */
|
|
13
|
+
present: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function parseFrontMatter(text: string): FrontMatter;
|
|
16
|
+
/** A list value, however it was written: one string becomes a one-item list. */
|
|
17
|
+
export declare function listOf(value: string | string[] | undefined): string[] | undefined;
|
|
18
|
+
/** A document's title: its front matter `title`, else its first heading, else its file name. */
|
|
19
|
+
export declare function titleOf(fm: FrontMatter, fallback: string): string;
|
|
20
|
+
//# sourceMappingURL=front-matter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"front-matter.d.ts","sourceRoot":"","sources":["../../src/sources/front-matter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IACxC,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,mFAAmF;IACnF,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAgC1D;AAOD,gFAAgF;AAChF,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,EAAE,GAAG,SAAS,CAGjF;AAED,gGAAgG;AAChG,wBAAgB,OAAO,CAAC,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKjE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export function parseFrontMatter(text) {
|
|
2
|
+
const m = text.match(/^(?:\uFEFF)?---[ \t]*\r?\n([\s\S]*?)\r?\n?---[ \t]*(?:\r?\n|$)/);
|
|
3
|
+
if (!m)
|
|
4
|
+
return { data: {}, body: text, present: false };
|
|
5
|
+
const data = {};
|
|
6
|
+
let listKey = null;
|
|
7
|
+
for (const raw of m[1].split(/\r?\n/)) {
|
|
8
|
+
const line = raw.replace(/\s+$/, '');
|
|
9
|
+
if (!line.trim() || line.trim().startsWith('#'))
|
|
10
|
+
continue;
|
|
11
|
+
const item = line.match(/^\s+-\s*(.*)$/);
|
|
12
|
+
if (item && listKey) {
|
|
13
|
+
data[listKey].push(unquote(item[1]));
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const kv = line.match(/^([A-Za-z_][\w.-]*)\s*:\s*(.*)$/);
|
|
17
|
+
if (!kv)
|
|
18
|
+
continue;
|
|
19
|
+
const [, key, value] = kv;
|
|
20
|
+
if (value === '') {
|
|
21
|
+
data[key] = [];
|
|
22
|
+
listKey = key;
|
|
23
|
+
}
|
|
24
|
+
else if (value.startsWith('[') && value.endsWith(']')) {
|
|
25
|
+
data[key] = value
|
|
26
|
+
.slice(1, -1)
|
|
27
|
+
.split(',')
|
|
28
|
+
.map((v) => unquote(v.trim()))
|
|
29
|
+
.filter(Boolean);
|
|
30
|
+
listKey = null;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
data[key] = unquote(value);
|
|
34
|
+
listKey = null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return { data, body: text.slice(m[0].length), present: true };
|
|
38
|
+
}
|
|
39
|
+
function unquote(v) {
|
|
40
|
+
const t = v.trim();
|
|
41
|
+
return (t.startsWith('"') && t.endsWith('"')) || (t.startsWith("'") && t.endsWith("'")) ? t.slice(1, -1) : t;
|
|
42
|
+
}
|
|
43
|
+
/** A list value, however it was written: one string becomes a one-item list. */
|
|
44
|
+
export function listOf(value) {
|
|
45
|
+
if (value === undefined)
|
|
46
|
+
return undefined;
|
|
47
|
+
return Array.isArray(value) ? value : value.split(',').map((v) => v.trim()).filter(Boolean);
|
|
48
|
+
}
|
|
49
|
+
/** A document's title: its front matter `title`, else its first heading, else its file name. */
|
|
50
|
+
export function titleOf(fm, fallback) {
|
|
51
|
+
const fromMatter = fm.data.title;
|
|
52
|
+
if (typeof fromMatter === 'string' && fromMatter.trim())
|
|
53
|
+
return fromMatter.trim();
|
|
54
|
+
const heading = fm.body.match(/^\s*#\s+(.+?)\s*#*\s*$/m);
|
|
55
|
+
return heading?.[1]?.trim() || fallback;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=front-matter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"front-matter.js","sourceRoot":"","sources":["../../src/sources/front-matter.ts"],"names":[],"mappings":"AAeA,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,gEAAgE,CAAC,CAAC;IACvF,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACxD,MAAM,IAAI,GAAsC,EAAE,CAAC;IACnD,IAAI,OAAO,GAAkB,IAAI,CAAC;IAClC,KAAK,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAS;QAC1D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QACzC,IAAI,IAAI,IAAI,OAAO,EAAE,CAAC;YACnB,IAAI,CAAC,OAAO,CAAc,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC;YACpD,SAAS;QACX,CAAC;QACD,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACzD,IAAI,CAAC,EAAE;YAAE,SAAS;QAClB,MAAM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AC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/G,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,MAAM,CAAC,KAAoC;IACzD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC9F,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,OAAO,CAAC,EAAe,EAAE,QAAgB;IACvD,MAAM,UAAU,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;IACjC,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC,IAAI,EAAE;QAAE,OAAO,UAAU,CAAC,IAAI,EAAE,CAAC;IAClF,MAAM,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACzD,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,QAAQ,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { SourceAuthor, SourceChanges, SourceItem, SourceVersion, SourceWrite, SourceWriteResult, SpecSource, SourceCapabilities } from '@aigile/core';
|
|
2
|
+
export interface GitSpecSourceOptions {
|
|
3
|
+
id: string;
|
|
4
|
+
/** The remote (any URL git accepts, or a local path for tests). */
|
|
5
|
+
url: string;
|
|
6
|
+
branch: string;
|
|
7
|
+
/** The folder whose `*.md` files are specs; '' for the whole repository. */
|
|
8
|
+
path: string;
|
|
9
|
+
/** Where the mirror's clone lives (no working tree: files are read from the ref). */
|
|
10
|
+
dir: string;
|
|
11
|
+
/** The mappings a document gets unless its front matter names its own. */
|
|
12
|
+
defaults: {
|
|
13
|
+
organizationIds: string[];
|
|
14
|
+
projectIds: string[];
|
|
15
|
+
};
|
|
16
|
+
/** Extra environment for git (the datastore's credential helper, for a private remote). */
|
|
17
|
+
env?: Record<string, string>;
|
|
18
|
+
/** Never push from the workspace (saves are refused; edits stay drafts). */
|
|
19
|
+
readOnly?: boolean;
|
|
20
|
+
/** The committer for saves (the installation's identity); the person is the author. */
|
|
21
|
+
committer?: {
|
|
22
|
+
name: string;
|
|
23
|
+
email: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A Git repository of Markdown as a spec source. Every `*.md` under `path`
|
|
28
|
+
* on `branch` is a document: its external id is the path, its version the
|
|
29
|
+
* last commit that touched it, its author that commit's author, its title the
|
|
30
|
+
* front matter `title` or its first heading. Front matter `organizations`,
|
|
31
|
+
* `projects` and `roles` (ids) replace the defaults for that document. The
|
|
32
|
+
* clone keeps no working tree; a sync is one fetch and reads from the ref,
|
|
33
|
+
* with the same hardening as the Engineer's checkouts.
|
|
34
|
+
*/
|
|
35
|
+
export declare class GitSpecSource implements SpecSource {
|
|
36
|
+
private readonly opts;
|
|
37
|
+
readonly kind = "git";
|
|
38
|
+
readonly id: string;
|
|
39
|
+
readonly capabilities: SourceCapabilities;
|
|
40
|
+
private readonly ref;
|
|
41
|
+
constructor(opts: GitSpecSourceOptions);
|
|
42
|
+
/** One file at a commit (the branch's tip when none); null when the commit or the file is not there. */
|
|
43
|
+
read(externalId: string, version?: string): Promise<SourceItem | null>;
|
|
44
|
+
/** The commits that touched a file, newest first. */
|
|
45
|
+
versions(externalId: string): Promise<SourceVersion[]>;
|
|
46
|
+
/** Save one document: one commit (see `writeMany`). */
|
|
47
|
+
write(doc: SourceWrite): Promise<SourceWriteResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Save several documents as one commit on the branch and push it, without
|
|
50
|
+
* a working tree: each blob is written, the tree built from the branch's
|
|
51
|
+
* tip with a temporary index, the commit made with the person as author
|
|
52
|
+
* and the installation as committer, the ref pushed. A document whose
|
|
53
|
+
* file moved past its `baseVersion` is a conflict; a push that loses the
|
|
54
|
+
* race is retried once from the new tip when none of the files moved.
|
|
55
|
+
*/
|
|
56
|
+
writeMany(docs: SourceWrite[], message: string, author: SourceAuthor | null): Promise<SourceWriteResult[]>;
|
|
57
|
+
private show;
|
|
58
|
+
/** A new file's path under the source's path, from the title; a suffix when it is taken (or already in this batch). */
|
|
59
|
+
private freshPath;
|
|
60
|
+
init(): Promise<void>;
|
|
61
|
+
changes(cursor: string | null): Promise<SourceChanges>;
|
|
62
|
+
private item;
|
|
63
|
+
/** The document's page on its host, for the "edit at the source" link; null for a host aigile does not know. */
|
|
64
|
+
urlFor(file: string): string | null;
|
|
65
|
+
private prefix;
|
|
66
|
+
private cloned;
|
|
67
|
+
private git;
|
|
68
|
+
private gitStdin;
|
|
69
|
+
private env;
|
|
70
|
+
}
|
|
71
|
+
/** The document's text for a save: the existing front matter kept with its title updated, or none when the file had none and the title is the first heading. */
|
|
72
|
+
export declare function withFrontMatter(current: string | null, title: string, content: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* Where a document sits in the outline (documentation/sources.md "Outlines"):
|
|
75
|
+
* a file sits under its folder's index file, an index file under the index of
|
|
76
|
+
* the nearest folder above that has one; a folder without one passes its
|
|
77
|
+
* documents up. Null at the top.
|
|
78
|
+
*/
|
|
79
|
+
export declare function outlineParent(file: string, files: ReadonlySet<string>): string | null;
|
|
80
|
+
//# sourceMappingURL=git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/sources/git.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAQ3J,MAAM,WAAW,oBAAoB;IACnC,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