@openparachute/vault 0.6.2 → 0.6.3-rc.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/core/src/onboarding.ts +185 -0
- package/core/src/vault-projection.ts +44 -0
- package/package.json +1 -1
- package/src/cli.ts +9 -1
- package/src/mcp-tools.ts +8 -0
- package/src/onboarding-seed.test.ts +150 -0
- package/src/onboarding-seed.ts +83 -0
- package/src/server.ts +5 -0
- package/src/vault-create.test.ts +46 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Onboarding doctrine — the in-vault guide a freshly-created vault seeds so a
|
|
3
|
+
* connected AI can self-orient and set the vault up on the operator's behalf.
|
|
4
|
+
*
|
|
5
|
+
* This module is the single source of truth for the *content* + the *paths* of
|
|
6
|
+
* the seeded notes. It lives in `core` (not `src`) so both:
|
|
7
|
+
* - the seeding path (`src/onboarding-seed.ts`, called from `createVault`), and
|
|
8
|
+
* - the projection/`vault-info` pointer (`core/src/vault-projection.ts`)
|
|
9
|
+
* can share the canonical note paths without a cross-layer import.
|
|
10
|
+
*
|
|
11
|
+
* The notes are AI-legible, practical (SKILL.md-style) guides addressed to the
|
|
12
|
+
* assistant that connects to the vault. They are a starting point, not gospel —
|
|
13
|
+
* Getting Started tells the AI it can adapt them as the vault matures. Seeding is
|
|
14
|
+
* create-time only and idempotent (never clobbers a note the operator/AI has
|
|
15
|
+
* since edited).
|
|
16
|
+
*
|
|
17
|
+
* See the demo-prep Workstream A (A1/A2/A3).
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** Canonical path of the seeded onboarding guide. Top-level, title-cased so it
|
|
21
|
+
* reads as a doc and sorts to the top of a casual file listing. */
|
|
22
|
+
export const GETTING_STARTED_PATH = "Getting Started";
|
|
23
|
+
|
|
24
|
+
/** Canonical path of the seeded surface-build starter, linked from Getting
|
|
25
|
+
* Started. */
|
|
26
|
+
export const SURFACE_STARTER_PATH = "Surface Starter";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Body of the seeded `Getting Started` note.
|
|
30
|
+
*
|
|
31
|
+
* Voice: addressed to the connected AI ("you"), practical, SKILL.md-style.
|
|
32
|
+
* Covers (a) what a Parachute vault is, (b) tags-vs-paths-vs-schemas design,
|
|
33
|
+
* (c) importing existing notes, (d) that it's an adaptable starting point.
|
|
34
|
+
*/
|
|
35
|
+
export const GETTING_STARTED_CONTENT = `# Getting Started
|
|
36
|
+
|
|
37
|
+
This is the **start-here guide** for this Parachute vault — think of it like a
|
|
38
|
+
\`SKILL.md\`: practical instructions for setting up and growing the vault. Read it
|
|
39
|
+
when you're **getting the vault started** or orienting yourself to it — you don't
|
|
40
|
+
need to re-read it every session. It's a **starting point, not a script**, and
|
|
41
|
+
it's adaptable: edit it (see "Adapt this note") as the vault takes shape.
|
|
42
|
+
|
|
43
|
+
When the operator says something like *"help me set up my parachute,"* this is
|
|
44
|
+
your brief: design their structure with them, import what they already have, and
|
|
45
|
+
shape the vault around how they actually think and work.
|
|
46
|
+
|
|
47
|
+
## What a Parachute vault is
|
|
48
|
+
|
|
49
|
+
A vault is **notes + tags + links** in one graph, reachable over MCP (you, now),
|
|
50
|
+
a REST API (scripts), and any surface (a UI). It ships *blank* — no predefined
|
|
51
|
+
tags or schema. You and the operator design the structure that fits *their*
|
|
52
|
+
life and work. The vault is the engine; the meaning is yours to bring.
|
|
53
|
+
|
|
54
|
+
Core moves you already have as MCP tools:
|
|
55
|
+
- \`create-note\` / \`update-note\` / \`delete-note\` — write notes (single or batch).
|
|
56
|
+
- \`query-notes\` — by id/path, by tag, full-text \`search\`, or graph \`near\` a note.
|
|
57
|
+
- \`list-tags\` / \`update-tag\` / \`delete-tag\` — manage the tag vocabulary + schemas.
|
|
58
|
+
- \`find-path\` — shortest link path between two notes.
|
|
59
|
+
- \`vault-info\` — refresh the live schema/stats projection any time.
|
|
60
|
+
|
|
61
|
+
\`[[wikilinks]]\` in note content auto-link to the note at that path — use them
|
|
62
|
+
freely; they resolve even if the target is created later.
|
|
63
|
+
|
|
64
|
+
## Tags vs paths vs schemas — the design vocabulary
|
|
65
|
+
|
|
66
|
+
These three axes are the heart of vault design. Use the right one for the job:
|
|
67
|
+
|
|
68
|
+
- **Tags = types / membership.** A tag answers *"what kind of thing is this?"*
|
|
69
|
+
(\`#person\`, \`#meeting\`, \`#project\`). Queries **expand over tags**: a tag can
|
|
70
|
+
declare \`parent_names\` so \`tag:X\` also returns its subtypes (e.g. tagging a
|
|
71
|
+
note \`#meeting/standup\` with \`parent_names: [meeting]\` means \`query-notes
|
|
72
|
+
{ tag: "meeting" }\` finds it). Tags are how you ask *"show me all my people."*
|
|
73
|
+
This is the primary structure — reach for a tag first.
|
|
74
|
+
|
|
75
|
+
- **Paths = organization / filing.** A path (\`Projects/Acme/Kickoff\`) is *where*
|
|
76
|
+
a note lives — a human-browsable address, unique per note. Paths are for
|
|
77
|
+
folders and named docs (like this one). They do **not** drive type queries;
|
|
78
|
+
don't encode meaning in a path that a tag should carry. A note can have a
|
|
79
|
+
path, tags, or both.
|
|
80
|
+
|
|
81
|
+
- **Schemas = typed metadata fields.** Attach a schema to a tag (via
|
|
82
|
+
\`update-tag\`) to declare typed metadata fields — e.g. \`#meeting\` with a
|
|
83
|
+
\`held_on\` date, \`#person\` with an \`email\`. Each field can **optionally** be
|
|
84
|
+
marked \`indexed: true\` to make it **queryable with operators** (\`query-notes
|
|
85
|
+
{ tag: "meeting", metadata: { held_on: { gte: "2026-01-01" } } }\`); indexing
|
|
86
|
+
is opt-in per field, not automatic. Add a schema (and index a field) when you
|
|
87
|
+
find yourself wanting to filter or sort on a value, not before.
|
|
88
|
+
|
|
89
|
+
Rule of thumb: **type with tags, file with paths, make-it-queryable with
|
|
90
|
+
schemas.** Start minimal — invent tags as real notes need them, declare a
|
|
91
|
+
schema only when a query demands it. Over-designing an empty vault is the
|
|
92
|
+
common mistake.
|
|
93
|
+
|
|
94
|
+
(Full design guide, with copy-paste examples: https://parachute.computer/scripting/)
|
|
95
|
+
|
|
96
|
+
## Importing existing notes
|
|
97
|
+
|
|
98
|
+
If the operator already keeps notes (Obsidian, Markdown, etc.), bring them in
|
|
99
|
+
rather than starting cold:
|
|
100
|
+
|
|
101
|
+
- **Obsidian / a Markdown folder:** \`parachute-vault import <path>\` — preserves
|
|
102
|
+
frontmatter, tags, \`[[wikilinks]]\`, and file paths.
|
|
103
|
+
- **A portable Parachute export** (a dir with \`.parachute/vault.yaml\`): the same
|
|
104
|
+
\`import\` command auto-detects it and does a lossless round-trip (ids, typed
|
|
105
|
+
links, tag schemas, attachments).
|
|
106
|
+
- **Ad hoc / pasted content:** just \`create-note\` it. Then help the operator tag
|
|
107
|
+
and schematize: read a sample of imported notes, propose a small tag
|
|
108
|
+
vocabulary, and apply it.
|
|
109
|
+
|
|
110
|
+
After an import, orient yourself: \`vault-info\` for the new schema picture,
|
|
111
|
+
\`list-tags\` to see what vocabulary arrived, \`query-notes { search: "..." }\` to
|
|
112
|
+
spot-check. Then propose structure — don't impose it silently.
|
|
113
|
+
|
|
114
|
+
## Later: a custom surface
|
|
115
|
+
|
|
116
|
+
Building a custom UI over the vault (a dashboard, a notes app) is usually **not**
|
|
117
|
+
the starting point — get the notes and structure right first. If and when the
|
|
118
|
+
operator wants one, see **[[Surface Starter]]** (built with
|
|
119
|
+
\`@openparachute/surface-client\` + \`@openparachute/surface-render\`).
|
|
120
|
+
|
|
121
|
+
## Adapt this note
|
|
122
|
+
|
|
123
|
+
This guide is a **default starting point, not gospel** — edit it to fit this
|
|
124
|
+
vault. As you and the operator settle on a tag vocabulary, conventions, or a
|
|
125
|
+
surface, you can record that here so a future session inherits the current shape
|
|
126
|
+
of the vault instead of this blank-slate default. Useful things to capture:
|
|
127
|
+
- the tag vocabulary you've settled on and what each tag means;
|
|
128
|
+
- naming/path conventions for this vault;
|
|
129
|
+
- which schemas exist and why;
|
|
130
|
+
- anything a fresh AI would need to be immediately useful.
|
|
131
|
+
|
|
132
|
+
Treat setup as a relationship, not a one-time install.
|
|
133
|
+
`;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Body of the seeded `Surface Starter` note. Linked from Getting Started.
|
|
137
|
+
*
|
|
138
|
+
* A concise, *living* starter prompt for building a custom surface (UI) over
|
|
139
|
+
* the vault using the published surface packages. Tells the AI to import the
|
|
140
|
+
* packages rather than hand-roll OAuth/API/rendering.
|
|
141
|
+
*/
|
|
142
|
+
export const SURFACE_STARTER_CONTENT = `# Surface Starter
|
|
143
|
+
|
|
144
|
+
A **surface** is a custom UI over this vault — a dashboard, a notes app, a
|
|
145
|
+
single-purpose tool. This note is a living starter for building one *with the
|
|
146
|
+
operator*. Update it as you settle on a stack, conventions, or a deployed
|
|
147
|
+
surface for this vault.
|
|
148
|
+
|
|
149
|
+
## Don't hand-roll the plumbing
|
|
150
|
+
|
|
151
|
+
Two published packages do the heavy lifting — import them instead of writing
|
|
152
|
+
OAuth, the vault API client, or note rendering by hand:
|
|
153
|
+
|
|
154
|
+
- **\`@openparachute/surface-client\`** — \`createVaultSurface(...)\` wires up
|
|
155
|
+
Parachute OAuth (sign-in on first connect) and a typed vault API client
|
|
156
|
+
(query/create/update notes, tags, links) so your app code just calls methods.
|
|
157
|
+
- **\`@openparachute/surface-render\`** — \`<NoteRenderer>\` and friends render note
|
|
158
|
+
content (Markdown, wikilinks, embeds) the way the rest of the ecosystem does,
|
|
159
|
+
so your surface looks native without re-implementing the renderer.
|
|
160
|
+
|
|
161
|
+
## Build order
|
|
162
|
+
|
|
163
|
+
1. **Auth + data first.** Stand up \`createVaultSurface\` pointed at this vault;
|
|
164
|
+
confirm you can sign in and \`query-notes\` round-trips before any UI polish.
|
|
165
|
+
2. **Render next.** Drop in \`<NoteRenderer>\` to display note content; wire
|
|
166
|
+
wikilink/embed resolution through the package, not by hand.
|
|
167
|
+
3. **UX last.** Layout, navigation, and the surface's actual purpose — now that
|
|
168
|
+
auth, data, and rendering are solid.
|
|
169
|
+
|
|
170
|
+
## Design it around this vault's structure
|
|
171
|
+
|
|
172
|
+
A good surface is shaped by the vault's tags + schemas (see [[Getting Started]]
|
|
173
|
+
for the tags-vs-paths-vs-schemas design vocabulary). Query by the tags that
|
|
174
|
+
matter to the operator; surface the indexed fields they filter on. If the vault
|
|
175
|
+
doesn't yet have the structure a surface wants, that's a signal to design tags +
|
|
176
|
+
schemas first.
|
|
177
|
+
|
|
178
|
+
## Adapt this note
|
|
179
|
+
|
|
180
|
+
When you build a surface for this vault, record it here: what it's for, the
|
|
181
|
+
stack, how to run it, the queries it depends on. The next session should be able
|
|
182
|
+
to pick it up from this note.
|
|
183
|
+
|
|
184
|
+
(More on the surface stack + examples: https://parachute.computer/scripting/)
|
|
185
|
+
`;
|
|
@@ -33,6 +33,23 @@ import {
|
|
|
33
33
|
import { DEFAULT_TAG_NAME } from "./tag-hierarchy.ts";
|
|
34
34
|
import * as noteOps from "./notes.ts";
|
|
35
35
|
import type { VaultStats } from "./types.ts";
|
|
36
|
+
import { GETTING_STARTED_PATH } from "./onboarding.ts";
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Does a note live at the seeded onboarding path? Used to gate the "Start here"
|
|
40
|
+
* pointer so it only fires when the guide actually exists (fresh vaults seed it;
|
|
41
|
+
* pre-existing vaults that never seeded one shouldn't dangle a dead pointer).
|
|
42
|
+
*/
|
|
43
|
+
function hasGettingStartedNote(db: Database): boolean {
|
|
44
|
+
try {
|
|
45
|
+
const row = db
|
|
46
|
+
.query("SELECT 1 FROM notes WHERE path = ? LIMIT 1")
|
|
47
|
+
.get(GETTING_STARTED_PATH);
|
|
48
|
+
return row != null;
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
36
53
|
|
|
37
54
|
// ---------------------------------------------------------------------------
|
|
38
55
|
// Types
|
|
@@ -76,6 +93,14 @@ export interface VaultProjection {
|
|
|
76
93
|
tags: ProjectionTag[];
|
|
77
94
|
indexed_fields: ProjectionIndexedField[];
|
|
78
95
|
query_hints: string[];
|
|
96
|
+
/**
|
|
97
|
+
* Path of the seeded onboarding guide, when present. A pointer (NOT the note
|
|
98
|
+
* body) so any connected AI is steered to read `Getting Started` first, every
|
|
99
|
+
* session — the AI fetches it with `query-notes { id: "<path>" }`. Omitted
|
|
100
|
+
* when no such note exists (older vaults that never seeded one). See
|
|
101
|
+
* core/src/onboarding.ts.
|
|
102
|
+
*/
|
|
103
|
+
getting_started?: string;
|
|
79
104
|
/** Included when the caller requests stats; omitted otherwise. */
|
|
80
105
|
stats?: VaultStats;
|
|
81
106
|
}
|
|
@@ -210,6 +235,12 @@ export function buildVaultProjection(
|
|
|
210
235
|
query_hints: [...QUERY_HINTS],
|
|
211
236
|
};
|
|
212
237
|
|
|
238
|
+
// A2: point any connected AI at the seeded onboarding guide (a path pointer,
|
|
239
|
+
// never the body). Only when the note actually exists.
|
|
240
|
+
if (hasGettingStartedNote(db)) {
|
|
241
|
+
projection.getting_started = GETTING_STARTED_PATH;
|
|
242
|
+
}
|
|
243
|
+
|
|
213
244
|
if (opts?.includeStats) {
|
|
214
245
|
projection.stats = noteOps.getVaultStats(db);
|
|
215
246
|
}
|
|
@@ -253,6 +284,19 @@ export function projectionToMarkdown(args: {
|
|
|
253
284
|
lines.push(description.trim());
|
|
254
285
|
}
|
|
255
286
|
|
|
287
|
+
// A2: surface the seeded onboarding guide so a connected AI can discover it
|
|
288
|
+
// when setting up or orienting. A pointer only — the AI fetches the body on
|
|
289
|
+
// demand. NOT a mandate to re-read every session; it's a start-here guide.
|
|
290
|
+
if (projection.getting_started) {
|
|
291
|
+
lines.push("");
|
|
292
|
+
lines.push(
|
|
293
|
+
`## Start here\n\nThis vault has a **${projection.getting_started}** guide — how to set it up ` +
|
|
294
|
+
`and grow it (what a Parachute vault is, designing tags vs paths vs schemas, importing ` +
|
|
295
|
+
`existing notes). Read it when setting up or getting oriented, or when the operator asks ` +
|
|
296
|
+
`for help setting up their parachute. Fetch it with \`query-notes { id: "${projection.getting_started}" }\`.`,
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
256
300
|
lines.push("");
|
|
257
301
|
lines.push("## Quick orientation (call `vault-info` for full schema)");
|
|
258
302
|
lines.push("");
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -107,6 +107,7 @@ import { VAULT_SCOPES } from "./scopes.ts";
|
|
|
107
107
|
import { validateVaultName, decideInitVaultName } from "./vault-name.ts";
|
|
108
108
|
import { decideAutostart } from "./autostart.ts";
|
|
109
109
|
import { getVaultStore } from "./vault-store.ts";
|
|
110
|
+
import { seedOnboardingNotesBestEffort } from "./onboarding-seed.ts";
|
|
110
111
|
import {
|
|
111
112
|
defaultMirrorConfig,
|
|
112
113
|
resolveMirrorPath,
|
|
@@ -3639,7 +3640,14 @@ async function createVault(
|
|
|
3639
3640
|
|
|
3640
3641
|
// Touch the store so the vault's SQLite DB + schema are created. No token
|
|
3641
3642
|
// row is written — vault is a pure hub resource-server post-0.5.0.
|
|
3642
|
-
getVaultStore(name);
|
|
3643
|
+
const seedStore = getVaultStore(name);
|
|
3644
|
+
|
|
3645
|
+
// Seed the in-vault onboarding guide (Getting Started + Surface Starter) so a
|
|
3646
|
+
// connected AI can read it and help the operator set the vault up. Idempotent
|
|
3647
|
+
// + best-effort: only writes notes that are absent, and never fails the
|
|
3648
|
+
// create. Runs BEFORE the mirror bootstrap so the seeded notes land in the
|
|
3649
|
+
// initial mirror commit. See src/onboarding-seed.ts + core/src/onboarding.ts.
|
|
3650
|
+
await seedOnboardingNotesBestEffort(seedStore);
|
|
3643
3651
|
|
|
3644
3652
|
// Default new vaults to an internal live mirror (local git backup of the
|
|
3645
3653
|
// markdown projection). Backup-on-by-default; GitHub off-site backup is an
|
package/src/mcp-tools.ts
CHANGED
|
@@ -490,6 +490,14 @@ function overrideVaultInfo(
|
|
|
490
490
|
query_hints: projection.query_hints,
|
|
491
491
|
};
|
|
492
492
|
|
|
493
|
+
// A2: surface a pointer (path, not body) to the seeded onboarding guide so
|
|
494
|
+
// any connected AI is steered to read it first. Present only when the note
|
|
495
|
+
// exists (buildVaultProjection gates on it). Older vaults without one omit
|
|
496
|
+
// the field entirely.
|
|
497
|
+
if (projection.getting_started) {
|
|
498
|
+
result.getting_started = projection.getting_started;
|
|
499
|
+
}
|
|
500
|
+
|
|
493
501
|
if (projection.stats) {
|
|
494
502
|
result.stats = projection.stats;
|
|
495
503
|
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for the onboarding-guide seeding (demo-prep Workstream A — A1/A2/A3).
|
|
3
|
+
*
|
|
4
|
+
* Store-direct (no CLI subprocess) so they're fast. Covers:
|
|
5
|
+
* - A1: seedOnboardingNotes writes Getting Started + Surface Starter.
|
|
6
|
+
* - A3: Surface Starter is linked from Getting Started (wikilink).
|
|
7
|
+
* - idempotency: a re-run never clobbers an edited note.
|
|
8
|
+
* - A2: the projection / vault-info pointer steers the AI at Getting Started.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { describe, test, expect, beforeEach, afterEach } from "bun:test";
|
|
12
|
+
import { Database } from "bun:sqlite";
|
|
13
|
+
import { mkdirSync, rmSync } from "fs";
|
|
14
|
+
import { join } from "path";
|
|
15
|
+
import { tmpdir } from "os";
|
|
16
|
+
import { BunStore } from "./vault-store.ts";
|
|
17
|
+
import { seedOnboardingNotes } from "./onboarding-seed.ts";
|
|
18
|
+
import {
|
|
19
|
+
GETTING_STARTED_PATH,
|
|
20
|
+
SURFACE_STARTER_PATH,
|
|
21
|
+
} from "../core/src/onboarding.ts";
|
|
22
|
+
import {
|
|
23
|
+
buildVaultProjection,
|
|
24
|
+
projectionToMarkdown,
|
|
25
|
+
} from "../core/src/vault-projection.ts";
|
|
26
|
+
|
|
27
|
+
let db: Database;
|
|
28
|
+
let store: BunStore;
|
|
29
|
+
let tmpDir: string;
|
|
30
|
+
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
tmpDir = join(tmpdir(), `onboarding-seed-test-${Date.now()}-${Math.random().toString(36).slice(2)}`);
|
|
33
|
+
mkdirSync(tmpDir, { recursive: true });
|
|
34
|
+
db = new Database(join(tmpDir, "test.db"));
|
|
35
|
+
store = new BunStore(db);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
afterEach(() => {
|
|
39
|
+
db.close();
|
|
40
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe("seedOnboardingNotes (A1/A3)", () => {
|
|
44
|
+
test("seeds Getting Started + Surface Starter on a blank vault", async () => {
|
|
45
|
+
const result = await seedOnboardingNotes(store);
|
|
46
|
+
expect(result.seeded.sort()).toEqual(
|
|
47
|
+
[GETTING_STARTED_PATH, SURFACE_STARTER_PATH].sort(),
|
|
48
|
+
);
|
|
49
|
+
expect(result.skipped).toEqual([]);
|
|
50
|
+
|
|
51
|
+
const gs = await store.getNoteByPath(GETTING_STARTED_PATH);
|
|
52
|
+
expect(gs).not.toBeNull();
|
|
53
|
+
expect(gs!.content).toContain("# Getting Started");
|
|
54
|
+
// A1 doctrine markers: tags-as-types, the three-axis design vocab, import,
|
|
55
|
+
// and the living-note instruction.
|
|
56
|
+
expect(gs!.content).toContain("Tags = types");
|
|
57
|
+
expect(gs!.content).toContain("Paths = organization");
|
|
58
|
+
expect(gs!.content).toContain("Schemas = typed metadata fields");
|
|
59
|
+
expect(gs!.content).toContain("parachute-vault import");
|
|
60
|
+
expect(gs!.content).toContain("Adapt this note");
|
|
61
|
+
|
|
62
|
+
const ss = await store.getNoteByPath(SURFACE_STARTER_PATH);
|
|
63
|
+
expect(ss).not.toBeNull();
|
|
64
|
+
expect(ss!.content).toContain("# Surface Starter");
|
|
65
|
+
// A3: the two surface packages by name.
|
|
66
|
+
expect(ss!.content).toContain("@openparachute/surface-client");
|
|
67
|
+
expect(ss!.content).toContain("@openparachute/surface-render");
|
|
68
|
+
expect(ss!.content).toContain("createVaultSurface");
|
|
69
|
+
expect(ss!.content).toContain("NoteRenderer");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("A3: Getting Started links to Surface Starter via a resolved wikilink", async () => {
|
|
73
|
+
await seedOnboardingNotes(store);
|
|
74
|
+
const gs = await store.getNoteByPath(GETTING_STARTED_PATH);
|
|
75
|
+
expect(gs!.content).toContain("[[Surface Starter]]");
|
|
76
|
+
|
|
77
|
+
// Wikilink auto-resolution: Getting Started → Surface Starter link row.
|
|
78
|
+
const ss = await store.getNoteByPath(SURFACE_STARTER_PATH);
|
|
79
|
+
const outbound = await store.getLinks(gs!.id, { direction: "outbound" });
|
|
80
|
+
expect(outbound.some((l) => l.targetId === ss!.id)).toBe(true);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("idempotent: a second seed run skips both (does not duplicate)", async () => {
|
|
84
|
+
await seedOnboardingNotes(store);
|
|
85
|
+
const second = await seedOnboardingNotes(store);
|
|
86
|
+
expect(second.seeded).toEqual([]);
|
|
87
|
+
expect(second.skipped.sort()).toEqual(
|
|
88
|
+
[GETTING_STARTED_PATH, SURFACE_STARTER_PATH].sort(),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
// Exactly one note per path — no duplicates.
|
|
92
|
+
const all = await store.queryNotes({});
|
|
93
|
+
expect(all.filter((n) => n.path === GETTING_STARTED_PATH)).toHaveLength(1);
|
|
94
|
+
expect(all.filter((n) => n.path === SURFACE_STARTER_PATH)).toHaveLength(1);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("idempotent: never clobbers an operator-edited Getting Started", async () => {
|
|
98
|
+
await seedOnboardingNotes(store);
|
|
99
|
+
const gs = await store.getNoteByPath(GETTING_STARTED_PATH);
|
|
100
|
+
|
|
101
|
+
// Operator/AI rewrites the note — the living-note case.
|
|
102
|
+
const edited = "# Getting Started\n\nThis vault is for my book research.";
|
|
103
|
+
await store.updateNote(gs!.id, { content: edited });
|
|
104
|
+
|
|
105
|
+
// Re-seed (simulates a re-init / restart): the edit must survive untouched.
|
|
106
|
+
const rerun = await seedOnboardingNotes(store);
|
|
107
|
+
expect(rerun.seeded).toEqual([]);
|
|
108
|
+
const after = await store.getNoteByPath(GETTING_STARTED_PATH);
|
|
109
|
+
expect(after!.content).toBe(edited);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe("vault-info / projection pointer (A2)", () => {
|
|
114
|
+
test("projection carries getting_started when the note exists", async () => {
|
|
115
|
+
// Absent before seeding → no pointer.
|
|
116
|
+
const before = buildVaultProjection(db);
|
|
117
|
+
expect(before.getting_started).toBeUndefined();
|
|
118
|
+
|
|
119
|
+
await seedOnboardingNotes(store);
|
|
120
|
+
const after = buildVaultProjection(db);
|
|
121
|
+
expect(after.getting_started).toBe(GETTING_STARTED_PATH);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("connect-time markdown brief steers the AI to read Getting Started first", async () => {
|
|
125
|
+
await seedOnboardingNotes(store);
|
|
126
|
+
const projection = buildVaultProjection(db, { includeStats: true });
|
|
127
|
+
const md = projectionToMarkdown({
|
|
128
|
+
vaultName: "fresh",
|
|
129
|
+
description: null,
|
|
130
|
+
projection,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
expect(md).toContain("## Start here");
|
|
134
|
+
expect(md).toContain(GETTING_STARTED_PATH);
|
|
135
|
+
// It's a POINTER, not the embedded body — the fetch command appears, the
|
|
136
|
+
// note's distinctive body copy does not.
|
|
137
|
+
expect(md).toContain(`query-notes { id: "${GETTING_STARTED_PATH}" }`);
|
|
138
|
+
expect(md).not.toContain("Adapt this note");
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("no Start-here block on a vault without the guide (back-compat)", async () => {
|
|
142
|
+
const projection = buildVaultProjection(db, { includeStats: true });
|
|
143
|
+
const md = projectionToMarkdown({
|
|
144
|
+
vaultName: "legacy",
|
|
145
|
+
description: null,
|
|
146
|
+
projection,
|
|
147
|
+
});
|
|
148
|
+
expect(md).not.toContain("## Start here");
|
|
149
|
+
});
|
|
150
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seed the in-vault onboarding guide on vault creation.
|
|
3
|
+
*
|
|
4
|
+
* A freshly-created vault gets a `Getting Started` note (AI-legible doctrine)
|
|
5
|
+
* and a linked `Surface Starter` note, so a connected AI can read the guide and
|
|
6
|
+
* help the operator set the vault up — and keep growing it over time.
|
|
7
|
+
*
|
|
8
|
+
* IDEMPOTENT + create-time only: each note is written ONLY when absent. A
|
|
9
|
+
* re-init, restart, or re-run never clobbers a note the operator/AI has since
|
|
10
|
+
* edited. Existing vaults are unaffected — this runs on the create path, not as
|
|
11
|
+
* a sweep over existing vaults.
|
|
12
|
+
*
|
|
13
|
+
* Best-effort + non-fatal: seeding must NEVER fail a vault create. Any error is
|
|
14
|
+
* caught and logged; the vault is still usable without the guide.
|
|
15
|
+
*
|
|
16
|
+
* See the demo-prep Workstream A (A1/A2/A3).
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
GETTING_STARTED_PATH,
|
|
21
|
+
GETTING_STARTED_CONTENT,
|
|
22
|
+
SURFACE_STARTER_PATH,
|
|
23
|
+
SURFACE_STARTER_CONTENT,
|
|
24
|
+
} from "../core/src/onboarding.ts";
|
|
25
|
+
import type { Store } from "../core/src/types.ts";
|
|
26
|
+
|
|
27
|
+
interface SeedResult {
|
|
28
|
+
/** Paths actually written this run (absent ones). Empty when both pre-existed. */
|
|
29
|
+
seeded: string[];
|
|
30
|
+
/** Paths skipped because the note already existed (idempotency). */
|
|
31
|
+
skipped: string[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Write a single onboarding note only if no note already lives at `path`.
|
|
36
|
+
* Returns true when it wrote (was absent), false when it skipped (present).
|
|
37
|
+
*/
|
|
38
|
+
async function seedNoteIfAbsent(
|
|
39
|
+
store: Store,
|
|
40
|
+
path: string,
|
|
41
|
+
content: string,
|
|
42
|
+
): Promise<boolean> {
|
|
43
|
+
const existing = await store.getNoteByPath(path);
|
|
44
|
+
if (existing) return false;
|
|
45
|
+
await store.createNote(content, { path });
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Seed the onboarding notes into `store`, idempotently. Surface Starter is
|
|
51
|
+
* created first so the `[[Surface Starter]]` wikilink in Getting Started
|
|
52
|
+
* resolves immediately (the create path also auto-resolves later, but this
|
|
53
|
+
* keeps the link live from the first write).
|
|
54
|
+
*/
|
|
55
|
+
export async function seedOnboardingNotes(store: Store): Promise<SeedResult> {
|
|
56
|
+
const seeded: string[] = [];
|
|
57
|
+
const skipped: string[] = [];
|
|
58
|
+
|
|
59
|
+
for (const [path, content] of [
|
|
60
|
+
[SURFACE_STARTER_PATH, SURFACE_STARTER_CONTENT],
|
|
61
|
+
[GETTING_STARTED_PATH, GETTING_STARTED_CONTENT],
|
|
62
|
+
] as const) {
|
|
63
|
+
const wrote = await seedNoteIfAbsent(store, path, content);
|
|
64
|
+
(wrote ? seeded : skipped).push(path);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return { seeded, skipped };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Best-effort wrapper for the create path: seed the onboarding notes, swallow
|
|
72
|
+
* and log any error so a seeding failure never fails the vault create.
|
|
73
|
+
*/
|
|
74
|
+
export async function seedOnboardingNotesBestEffort(store: Store): Promise<void> {
|
|
75
|
+
try {
|
|
76
|
+
await seedOnboardingNotes(store);
|
|
77
|
+
} catch (err) {
|
|
78
|
+
console.error(
|
|
79
|
+
`Note: onboarding guide not seeded (${(err as Error)?.message ?? err}). ` +
|
|
80
|
+
`The vault was still created; you can connect an AI and ask it to set things up.`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
package/src/server.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { existsSync, rmSync } from "fs";
|
|
|
20
20
|
import { migrateVaultKeys } from "./token-store.ts";
|
|
21
21
|
import { resolveFirstBootVaultName, reservedNameSquatWarnings } from "./vault-name.ts";
|
|
22
22
|
import { getVaultStore, getVaultNameForStore } from "./vault-store.ts";
|
|
23
|
+
import { seedOnboardingNotesBestEffort } from "./onboarding-seed.ts";
|
|
23
24
|
import { defaultHookRegistry } from "../core/src/hooks.ts";
|
|
24
25
|
import { registerTriggers } from "./triggers.ts";
|
|
25
26
|
import { loadVaultTriggers } from "./triggers-api.ts";
|
|
@@ -205,6 +206,10 @@ if (listVaults().length === 0) {
|
|
|
205
206
|
}
|
|
206
207
|
writeGlobalConfig(globalConfig);
|
|
207
208
|
console.log(`Auto-created vault "${vaultName}" (API key: ${fullKey})`);
|
|
209
|
+
// Seed the in-vault onboarding guide so a connected AI can self-orient and
|
|
210
|
+
// help set the vault up — same as the `create`/`init` CLI path. Idempotent
|
|
211
|
+
// + best-effort (never fails first boot). Mirrors createVault() in cli.ts.
|
|
212
|
+
await seedOnboardingNotesBestEffort(getVaultStore(vaultName));
|
|
208
213
|
}
|
|
209
214
|
}
|
|
210
215
|
|
package/src/vault-create.test.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { describe, test, expect, beforeEach, afterEach } from "bun:test";
|
|
12
|
+
import { Database } from "bun:sqlite";
|
|
12
13
|
import { resolve } from "path";
|
|
13
14
|
import {
|
|
14
15
|
mkdtempSync,
|
|
@@ -353,6 +354,51 @@ describe("vault create — services.json registration (#208)", () => {
|
|
|
353
354
|
});
|
|
354
355
|
});
|
|
355
356
|
|
|
357
|
+
/**
|
|
358
|
+
* Onboarding-guide seeding on create (demo-prep Workstream A — A1/A3).
|
|
359
|
+
*
|
|
360
|
+
* A freshly-created vault must contain the `Getting Started` + `Surface Starter`
|
|
361
|
+
* notes so a connected AI can read them and help set the vault up. Idempotent +
|
|
362
|
+
* best-effort: the seed never fails a create and never clobbers an edited note.
|
|
363
|
+
*/
|
|
364
|
+
describe("vault create — onboarding guide seeding (A1/A3)", () => {
|
|
365
|
+
/** Read all (path, content) rows from a created vault's SQLite DB. */
|
|
366
|
+
function readNotes(name: string): { path: string | null; content: string }[] {
|
|
367
|
+
const dbPath = join(home, "vault", "data", name, "vault.db");
|
|
368
|
+
const db = new Database(dbPath, { readonly: true });
|
|
369
|
+
try {
|
|
370
|
+
return db
|
|
371
|
+
.query("SELECT path, content FROM notes")
|
|
372
|
+
.all() as { path: string | null; content: string }[];
|
|
373
|
+
} finally {
|
|
374
|
+
db.close();
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
test("create seeds Getting Started + Surface Starter notes", () => {
|
|
379
|
+
const { exitCode } = runCli(["create", "guided", "--json"], {
|
|
380
|
+
PARACHUTE_HOME: home,
|
|
381
|
+
});
|
|
382
|
+
expect(exitCode).toBe(0);
|
|
383
|
+
|
|
384
|
+
const notes = readNotes("guided");
|
|
385
|
+
const gs = notes.find((n) => n.path === "Getting Started");
|
|
386
|
+
const ss = notes.find((n) => n.path === "Surface Starter");
|
|
387
|
+
expect(gs).toBeDefined();
|
|
388
|
+
expect(ss).toBeDefined();
|
|
389
|
+
expect(gs!.content).toContain("# Getting Started");
|
|
390
|
+
expect(gs!.content).toContain("[[Surface Starter]]");
|
|
391
|
+
expect(ss!.content).toContain("@openparachute/surface-client");
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
test("seeding doesn't break --json stdout (notes seeded silently)", () => {
|
|
395
|
+
const { stdout } = runCli(["create", "jsonclean", "--json"], {
|
|
396
|
+
PARACHUTE_HOME: home,
|
|
397
|
+
});
|
|
398
|
+
expect(() => JSON.parse(stdout.trim())).not.toThrow();
|
|
399
|
+
});
|
|
400
|
+
});
|
|
401
|
+
|
|
356
402
|
describe("vault create (human mode)", () => {
|
|
357
403
|
test("prints multi-line human output without --json", () => {
|
|
358
404
|
const { exitCode, stdout } = runCli(
|