isorite 0.3.0 → 0.5.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.
Files changed (62) hide show
  1. package/README.md +3 -3
  2. package/dist/core.js +4 -2
  3. package/dist/embed-worker.js +9 -4
  4. package/dist/main.js +7707 -7203
  5. package/docs/setup-for-agents.md +27 -2
  6. package/docs/setup.md +28 -2
  7. package/docs/terminal.md +16 -4
  8. package/package.json +1 -1
  9. package/plugin/tui.tsx +3 -77
  10. package/web/_app/immutable/assets/{0.IOi79DXH.css → 0.DNvf5eFW.css} +1 -1
  11. package/web/_app/immutable/chunks/-7PsQOY4.js +3 -0
  12. package/web/_app/immutable/chunks/B9vLu37F.js +1 -0
  13. package/web/_app/immutable/chunks/BAVeNK5c.js +20 -0
  14. package/web/_app/immutable/chunks/C1xA2mdF.js +1 -0
  15. package/web/_app/immutable/chunks/CQqNkDRK.js +1 -0
  16. package/web/_app/immutable/chunks/Cs9sQ8Oa.js +1 -0
  17. package/web/_app/immutable/chunks/{BNCmWi9e.js → D4Jg9Smi.js} +1 -1
  18. package/web/_app/immutable/chunks/{BN1DRYj2.js → DG2llOXe.js} +21 -21
  19. package/web/_app/immutable/chunks/DqVFJWdL.js +1 -0
  20. package/web/_app/immutable/chunks/{BZeALCyJ.js → HCrXwzvD.js} +1 -1
  21. package/web/_app/immutable/chunks/MjV3DsQW.js +1 -0
  22. package/web/_app/immutable/chunks/uID4v_1K.js +1 -0
  23. package/web/_app/immutable/entry/app.CR9ubCCo.js +2 -0
  24. package/web/_app/immutable/entry/start.D4DOZCP6.js +1 -0
  25. package/web/_app/immutable/nodes/0.BYXv43VP.js +26 -0
  26. package/web/_app/immutable/nodes/1.DGP71l35.js +1 -0
  27. package/web/_app/immutable/nodes/2.CxspTYRG.js +1 -0
  28. package/web/_app/immutable/nodes/3.ZTzs6oEI.js +1 -0
  29. package/web/_app/immutable/nodes/4.CeIGu2c2.js +2 -0
  30. package/web/_app/immutable/nodes/5.k1DmYkGm.js +5 -0
  31. package/web/_app/immutable/nodes/6.Q0yGno8p.js +1 -0
  32. package/web/_app/immutable/nodes/7.BJRu312o.js +1 -0
  33. package/web/_app/version.json +1 -1
  34. package/web/index.html +17 -20
  35. package/dist/tutorial/barnes_hut.py +0 -46
  36. package/dist/tutorial/sim.py +0 -29
  37. package/plugin/tour.ts +0 -74
  38. package/web/_app/immutable/assets/8.CFA9_nYZ.css +0 -1
  39. package/web/_app/immutable/assets/Tutorial.DOfsM49T.css +0 -1
  40. package/web/_app/immutable/chunks/-XH9wLvF.js +0 -1
  41. package/web/_app/immutable/chunks/B_AYGp9o.js +0 -1
  42. package/web/_app/immutable/chunks/BavLcJN1.js +0 -1
  43. package/web/_app/immutable/chunks/BcrJkegU.js +0 -1
  44. package/web/_app/immutable/chunks/BqrPWk6N.js +0 -20
  45. package/web/_app/immutable/chunks/Bze-M_kr.js +0 -3
  46. package/web/_app/immutable/chunks/CRzLMJPS.js +0 -1
  47. package/web/_app/immutable/chunks/Cr4-_2Vw.js +0 -1
  48. package/web/_app/immutable/chunks/D25FgEb3.js +0 -43
  49. package/web/_app/immutable/chunks/D8jeeZa0.js +0 -1
  50. package/web/_app/immutable/chunks/DHMLhlug.js +0 -1
  51. package/web/_app/immutable/chunks/DsnHcTIO.js +0 -1
  52. package/web/_app/immutable/entry/app.B9MdwZzs.js +0 -2
  53. package/web/_app/immutable/entry/start.gtQcHKDR.js +0 -1
  54. package/web/_app/immutable/nodes/0.DSajjyn5.js +0 -15
  55. package/web/_app/immutable/nodes/1.hmQ_l8t-.js +0 -1
  56. package/web/_app/immutable/nodes/2.Bu6Zvx8F.js +0 -1
  57. package/web/_app/immutable/nodes/3.DcSG1nNk.js +0 -1
  58. package/web/_app/immutable/nodes/4.QUhLgH4i.js +0 -2
  59. package/web/_app/immutable/nodes/5.D3JSWVyR.js +0 -5
  60. package/web/_app/immutable/nodes/6.CWfUNDww.js +0 -1
  61. package/web/_app/immutable/nodes/7.DmPPLDvb.js +0 -1
  62. package/web/_app/immutable/nodes/8.CwMTBog4.js +0 -486
package/README.md CHANGED
@@ -6,10 +6,10 @@ Needs Node 24 or later. For the terminal, OpenCode 2: `npm i -g @opencode/cli`.
6
6
 
7
7
  ```sh
8
8
  npm install -g isorite
9
- isorite --tutorial # the tutorial: the terminal's tour, and the browser's beside it, on an example base
9
+ isorite guide # the guide: a knowledge base about isorite, with things to do, in ~/isorite-guide
10
10
  ```
11
11
 
12
- On your own notes, a folder of Markdown files (empty is fine):
12
+ On your own notes, a folder of Markdown files (`isorite new <notes>` starts one):
13
13
 
14
14
  ```sh
15
15
  isorite serve <notes> # the browser, at http://localhost:4767/; set Iso's provider key behind the logo
@@ -21,6 +21,6 @@ Setting it up, at work too (a company's gateway, a client certificate, a proxy):
21
21
  When something fails, `isorite doctor` says what to change; `isorite doctor --report` gives it as one block, its
22
22
  secrets hidden, to paste to someone helping. For an AI helping you: `isorite help setup`.
23
23
 
24
- The tutorial in a browser alone: https://lachlanjs.github.io/isorite/
24
+ The guide in a browser alone: https://lachlanjs.github.io/isorite/
25
25
 
26
26
  Source, and what is on disk: https://github.com/lachlanjs/isorite
package/dist/core.js CHANGED
@@ -511,6 +511,8 @@ function outwardLinks(body) {
511
511
  }
512
512
  //#endregion
513
513
  //#region packages/core/src/bundle.ts
514
+ /** The base's own instructions, for Iso and any other agent, at the top of the notes (M15). Not a note. */
515
+ const AGENTS_FILE = "AGENTS.md";
514
516
  const OKF_VERSION = "0.2";
515
517
  const ARTIFACT = /\.html?$/i;
516
518
  const IMAGE = /\.(png|jpe?g|gif|svg|webp|avif)$/i;
@@ -668,7 +670,7 @@ var Bundle = class Bundle {
668
670
  this.ensureDir(rel);
669
671
  continue;
670
672
  }
671
- if (!rel.endsWith(".md")) {
673
+ if (!rel.endsWith(".md") || rel === "AGENTS.md") {
672
674
  this.files.add(rel);
673
675
  continue;
674
676
  }
@@ -2214,4 +2216,4 @@ function ago(at, now = Date.now()) {
2214
2216
  /** A moment is named by its last entry: the one the note is shown at. */
2215
2217
  const momentKey = (m) => m.ids.at(-1);
2216
2218
  //#endregion
2217
- export { ABOUT, Bundle, CONFIG_FILE, Concept, DEVICE_RE, DONE, DiffError, Directory, FrontmatterError, GITATTRIBUTES, ID_RE, KINDS, LearnerError, MAX_EVENT_BYTES, OKF_VERSION, OWN_DIR, OWN_FORMAT, RATINGS, SESSION_GAP_MS, SETTINGS_FILE, SNAPSHOT_EVERY, STRENGTH, STUDY_DIR, STUDY_FORMAT, SearchIndex, StudyError, agentName, ago, anchorOf, applyHunks, authors, blocks, change, citeKind, cleanEvent, cmp, cmpTuple, codeTarget, contentHash, describe, diffLines, doneOf, dumpFrontmatter, editFrontmatter, embedFor, embedRefs, findAnchor, findPassage, floatRepr, frontmatterText, hashText, headings, idsOf, impliedLinks, insertAt, iso, journalLine, journalPath, kindOf, legacyId, linkRefs, linkTexts, locate, mapModel, mergeRecords, momentKey, moments, newId, noteIds, outwardLinks, pagerank, parseSettings, parseStudyConfig, parseYaml, passageOf, pending, pyRepr, rating, reach, readJournal, readRecord, reconcile, recordPath, replay, round3, section, sessionMoments, settingsText, sha256, slugify, snippet, spliceText, splitFrontmatter, splitSource, stamp, strengthEdges, strip, stronglyConnected, text, textAt, toTime, tokenize, touched, wordAuthors, written };
2219
+ export { ABOUT, AGENTS_FILE, Bundle, CONFIG_FILE, Concept, DEVICE_RE, DONE, DiffError, Directory, FrontmatterError, GITATTRIBUTES, ID_RE, KINDS, LearnerError, MAX_EVENT_BYTES, OKF_VERSION, OWN_DIR, OWN_FORMAT, RATINGS, SESSION_GAP_MS, SETTINGS_FILE, SNAPSHOT_EVERY, STRENGTH, STUDY_DIR, STUDY_FORMAT, SearchIndex, StudyError, agentName, ago, anchorOf, applyHunks, authors, blocks, change, citeKind, cleanEvent, cmp, cmpTuple, codeTarget, contentHash, describe, diffLines, doneOf, dumpFrontmatter, editFrontmatter, embedFor, embedRefs, findAnchor, findPassage, floatRepr, frontmatterText, hashText, headings, idsOf, impliedLinks, insertAt, iso, journalLine, journalPath, kindOf, legacyId, linkRefs, linkTexts, locate, mapModel, mergeRecords, momentKey, moments, newId, noteIds, outwardLinks, pagerank, parseSettings, parseStudyConfig, parseYaml, passageOf, pending, pyRepr, rating, reach, readJournal, readRecord, reconcile, recordPath, replay, round3, section, sessionMoments, settingsText, sha256, slugify, snippet, spliceText, splitFrontmatter, splitSource, stamp, strengthEdges, strip, stronglyConnected, text, textAt, toTime, tokenize, touched, wordAuthors, written };
@@ -3212,14 +3212,15 @@ var init_ort_wasm_bundle_min = __esmMin((() => {
3212
3212
  //#endregion
3213
3213
  //#region packages/server/src/embed-worker.ts
3214
3214
  const MAX_TOKENS = 512;
3215
- const { dir, dim } = workerData;
3215
+ const { dir, dim, pooling } = workerData;
3216
3216
  const ort = await Promise.resolve().then(() => (init_ort_wasm_bundle_min(), ort_wasm_bundle_min_exports));
3217
3217
  const { Tokenizer } = await import("@huggingface/tokenizers");
3218
3218
  ort.env.wasm.numThreads = 1;
3219
3219
  const WASM = "ort-wasm-simd-threaded.wasm";
3220
3220
  const beside = join(dirname(fileURLToPath(import.meta.url)), WASM);
3221
3221
  ort.env.wasm.wasmBinary = readFileSync(existsSync(beside) ? beside : join(dirname(createRequire(import.meta.url).resolve("onnxruntime-web")), WASM));
3222
- const tok = new Tokenizer(JSON.parse(readFileSync(join(dir, "tokenizer.json"), "utf8")), JSON.parse(readFileSync(join(dir, "tokenizer_config.json"), "utf8")));
3222
+ const config = join(dir, "tokenizer_config.json");
3223
+ const tok = new Tokenizer(JSON.parse(readFileSync(join(dir, "tokenizer.json"), "utf8")), existsSync(config) ? JSON.parse(readFileSync(config, "utf8")) : {});
3223
3224
  const externalData = readdirSync(dir).filter((f) => f.endsWith(".onnx_data")).map((path) => ({
3224
3225
  path,
3225
3226
  data: readFileSync(join(dir, path))
@@ -3238,8 +3239,12 @@ async function embed(text) {
3238
3239
  attention_mask: big(ids.map(() => 1)),
3239
3240
  ...typed ? { token_type_ids: big(ids.map(() => 0)) } : {}
3240
3241
  });
3241
- const state = out.last_hidden_state ?? Object.values(out)[0];
3242
- return Float32Array.from(state.data.subarray(0, dim));
3242
+ const state = out.last_hidden_state ?? Object.values(out)[0], width = state.dims.at(-1), data = state.data;
3243
+ if (width !== dim) throw new Error(`its vectors have ${width} numbers, not ${dim}`);
3244
+ if (pooling === "cls" || state.dims.length < 3) return Float32Array.from(data.subarray(0, dim));
3245
+ const n = data.length / dim, mean = new Float32Array(dim);
3246
+ for (let t = 0; t < n; t++) for (let k = 0; k < dim; k++) mean[k] += data[t * dim + k] / n;
3247
+ return mean;
3243
3248
  }
3244
3249
  parentPort.on("message", (m) => {
3245
3250
  embed(m.text).then((vector) => parentPort.postMessage({