@pleri/olam-cli 0.1.182 → 0.1.185

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 (117) hide show
  1. package/dist/agent-stream/agent-sdk-to-chunks.js +44 -30
  2. package/dist/ask/checkout.d.ts +19 -0
  3. package/dist/ask/checkout.d.ts.map +1 -0
  4. package/dist/ask/checkout.js +40 -0
  5. package/dist/ask/checkout.js.map +1 -0
  6. package/dist/ask/knowledge-pack-builder.d.ts +72 -0
  7. package/dist/ask/knowledge-pack-builder.d.ts.map +1 -0
  8. package/dist/ask/knowledge-pack-builder.js +91 -0
  9. package/dist/ask/knowledge-pack-builder.js.map +1 -0
  10. package/dist/ask/knowledge-pack.generated.d.ts +8 -0
  11. package/dist/ask/knowledge-pack.generated.d.ts.map +1 -0
  12. package/dist/ask/knowledge-pack.generated.js +1947 -0
  13. package/dist/ask/knowledge-pack.generated.js.map +1 -0
  14. package/dist/ask/one-shot.d.ts +21 -0
  15. package/dist/ask/one-shot.d.ts.map +1 -0
  16. package/dist/ask/one-shot.js +50 -0
  17. package/dist/ask/one-shot.js.map +1 -0
  18. package/dist/ask/repl.d.ts +30 -0
  19. package/dist/ask/repl.d.ts.map +1 -0
  20. package/dist/ask/repl.js +109 -0
  21. package/dist/ask/repl.js.map +1 -0
  22. package/dist/ask/sdk-client.d.ts +87 -0
  23. package/dist/ask/sdk-client.d.ts.map +1 -0
  24. package/dist/ask/sdk-client.js +118 -0
  25. package/dist/ask/sdk-client.js.map +1 -0
  26. package/dist/ask/system-prompt.d.ts +30 -0
  27. package/dist/ask/system-prompt.d.ts.map +1 -0
  28. package/dist/ask/system-prompt.js +31 -0
  29. package/dist/ask/system-prompt.js.map +1 -0
  30. package/dist/commands/ask.d.ts +27 -0
  31. package/dist/commands/ask.d.ts.map +1 -0
  32. package/dist/commands/ask.js +63 -0
  33. package/dist/commands/ask.js.map +1 -0
  34. package/dist/commands/auth-list-json.d.ts +53 -0
  35. package/dist/commands/auth-list-json.d.ts.map +1 -0
  36. package/dist/commands/auth-list-json.js +47 -0
  37. package/dist/commands/auth-list-json.js.map +1 -0
  38. package/dist/commands/auth.d.ts.map +1 -1
  39. package/dist/commands/auth.js +13 -0
  40. package/dist/commands/auth.js.map +1 -1
  41. package/dist/commands/doctor.js +11 -11
  42. package/dist/commands/doctor.js.map +1 -1
  43. package/dist/commands/keys-list-json.d.ts +55 -0
  44. package/dist/commands/keys-list-json.d.ts.map +1 -0
  45. package/dist/commands/keys-list-json.js +54 -0
  46. package/dist/commands/keys-list-json.js.map +1 -0
  47. package/dist/commands/keys.d.ts.map +1 -1
  48. package/dist/commands/keys.js +6 -0
  49. package/dist/commands/keys.js.map +1 -1
  50. package/dist/commands/lanes-list-json.d.ts +69 -0
  51. package/dist/commands/lanes-list-json.d.ts.map +1 -0
  52. package/dist/commands/lanes-list-json.js +42 -0
  53. package/dist/commands/lanes-list-json.js.map +1 -0
  54. package/dist/commands/lanes.d.ts.map +1 -1
  55. package/dist/commands/lanes.js +18 -7
  56. package/dist/commands/lanes.js.map +1 -1
  57. package/dist/commands/plans-list-json.d.ts +77 -0
  58. package/dist/commands/plans-list-json.d.ts.map +1 -0
  59. package/dist/commands/plans-list-json.js +61 -0
  60. package/dist/commands/plans-list-json.js.map +1 -0
  61. package/dist/commands/plans.d.ts.map +1 -1
  62. package/dist/commands/plans.js +10 -0
  63. package/dist/commands/plans.js.map +1 -1
  64. package/dist/commands/repos-list-json.d.ts +58 -0
  65. package/dist/commands/repos-list-json.d.ts.map +1 -0
  66. package/dist/commands/repos-list-json.js +45 -0
  67. package/dist/commands/repos-list-json.js.map +1 -0
  68. package/dist/commands/repos.d.ts +1 -1
  69. package/dist/commands/repos.d.ts.map +1 -1
  70. package/dist/commands/repos.js +12 -2
  71. package/dist/commands/repos.js.map +1 -1
  72. package/dist/commands/services.d.ts +47 -1
  73. package/dist/commands/services.d.ts.map +1 -1
  74. package/dist/commands/services.js +59 -33
  75. package/dist/commands/services.js.map +1 -1
  76. package/dist/commands/skills.d.ts +27 -0
  77. package/dist/commands/skills.d.ts.map +1 -1
  78. package/dist/commands/skills.js +17 -2
  79. package/dist/commands/skills.js.map +1 -1
  80. package/dist/commands/workspace-list-json.d.ts +73 -0
  81. package/dist/commands/workspace-list-json.d.ts.map +1 -0
  82. package/dist/commands/workspace-list-json.js +59 -0
  83. package/dist/commands/workspace-list-json.js.map +1 -0
  84. package/dist/commands/workspace.d.ts.map +1 -1
  85. package/dist/commands/workspace.js +7 -1
  86. package/dist/commands/workspace.js.map +1 -1
  87. package/dist/image-digests.json +8 -8
  88. package/dist/index.js +3170 -580
  89. package/dist/index.js.map +1 -1
  90. package/dist/lib/k8s-bootstrap.d.ts.map +1 -1
  91. package/dist/lib/k8s-bootstrap.js +13 -1
  92. package/dist/lib/k8s-bootstrap.js.map +1 -1
  93. package/dist/lib/k8s-secret-render.d.ts +2 -0
  94. package/dist/lib/k8s-secret-render.d.ts.map +1 -1
  95. package/dist/lib/k8s-secret-render.js +27 -0
  96. package/dist/lib/k8s-secret-render.js.map +1 -1
  97. package/dist/lib/peripheral-registry.d.ts +1 -1
  98. package/dist/lib/peripheral-registry.d.ts.map +1 -1
  99. package/dist/lib/peripheral-registry.js +13 -0
  100. package/dist/lib/peripheral-registry.js.map +1 -1
  101. package/dist/lib/upgrade-kubernetes.d.ts +6 -0
  102. package/dist/lib/upgrade-kubernetes.d.ts.map +1 -1
  103. package/dist/lib/upgrade-kubernetes.js +7 -1
  104. package/dist/lib/upgrade-kubernetes.js.map +1 -1
  105. package/dist/mcp-server.js +1167 -37
  106. package/hermes-bundle/version.json +1 -1
  107. package/host-cp/k8s/manifests/30-configmap.yaml +11 -6
  108. package/host-cp/k8s/manifests/50-deployment.yaml +15 -1
  109. package/host-cp/k8s/manifests/auth-service/50-deployment.yaml +1 -1
  110. package/host-cp/k8s/manifests/kg-service/50-deployment.yaml +1 -1
  111. package/host-cp/k8s/manifests/mcp-auth-service/50-deployment.yaml +1 -1
  112. package/host-cp/k8s/manifests/memory-service/50-deployment.yaml +1 -1
  113. package/host-cp/k8s/templates/chunks-postgres-secret-template.yaml +24 -0
  114. package/host-cp/k8s/templates/plan-chat-service-secret-template.yaml +35 -0
  115. package/host-cp/src/plan-chat-service.mjs +99 -74
  116. package/host-cp/src/server.mjs +141 -5
  117. package/package.json +4 -2
@@ -77,14 +77,20 @@ export async function streamSdkToChunks(input) {
77
77
  // do NOT carry usage (one usage block per assistant API response).
78
78
  const turnUsage = assistant.message?.usage;
79
79
  let usageAttached = false;
80
+ // PERF: stamp `created_at` ONCE per assistant message rather than per
81
+ // content block. The blocks of a single assistant message are drained
82
+ // in this synchronous inner loop, so a wall-clock `now()` already
83
+ // returns the same millisecond for every block — the per-block call was
84
+ // re-allocating a `Date` + re-formatting an ISO string (~0.33µs each)
85
+ // that resolved to the identical value. It's also dead work for the
86
+ // persisted substrate: host-cp's `INSERT INTO chunks` omits `created_at`
87
+ // and lets the column default to `clock_timestamp()`, so the adapter's
88
+ // stamp is never stored. Hoisting collapses N Date allocations to 1 per
89
+ // message while keeping per-message timestamp distinction and the
90
+ // injected-clock contract (fixed `now` → byte-identical output).
91
+ const createdAt = now().toISOString();
80
92
  for (const block of content) {
81
- const draft = blockToChunkDraft(block, {
82
- worldId,
83
- sessionId,
84
- messageId,
85
- seq,
86
- createdAt: now().toISOString(),
87
- });
93
+ const draft = blockToChunkDraft(block, worldId, sessionId, messageId, seq, createdAt);
88
94
  if (draft === null)
89
95
  continue;
90
96
  const draftWithUsage = !usageAttached && turnUsage !== undefined
@@ -169,14 +175,13 @@ export async function streamMultiTurnSdkToChunks(input) {
169
175
  // first non-null chunk per turn; subsequent chunks carry no usage.
170
176
  const turnUsage = assistant.message?.usage;
171
177
  let usageAttached = false;
178
+ // PERF: stamp `created_at` once per assistant message (see the matching
179
+ // note in `streamSdkToChunks` — blocks of one message land in the same
180
+ // wall-clock millisecond and the persisted column ignores this value
181
+ // anyway). One Date allocation per message instead of one per block.
182
+ const createdAt = now().toISOString();
172
183
  for (const block of content) {
173
- const draft = blockToChunkDraft(block, {
174
- worldId,
175
- sessionId,
176
- messageId,
177
- seq,
178
- createdAt: now().toISOString(),
179
- });
184
+ const draft = blockToChunkDraft(block, worldId, sessionId, messageId, seq, createdAt);
180
185
  if (draft === null)
181
186
  continue;
182
187
  const draftWithUsage = !usageAttached && turnUsage !== undefined
@@ -219,30 +224,39 @@ export async function streamMultiTurnSdkToChunks(input) {
219
224
  }
220
225
  return { turnsObserved, chunksEmitted, lastError };
221
226
  }
222
- function blockToChunkDraft(block, ctx) {
227
+ /**
228
+ * Map a single SDK content block to a chunk draft, or `null` to skip (empty
229
+ * text). Takes the stream-constant scope fields (`worldId`/`sessionId`/
230
+ * `messageId`) plus the per-block `seq`/`createdAt` as flat parameters rather
231
+ * than a context object — this is a per-chunk hot path (every agent
232
+ * token-burst flows through it), and a freshly-allocated `BlockContext`
233
+ * literal per block was pure parameter-passing garbage. Output is identical;
234
+ * only the intermediate allocation is removed.
235
+ */
236
+ function blockToChunkDraft(block, worldId, sessionId, messageId, seq, createdAt) {
223
237
  if (block.type === 'text') {
224
238
  const text = block.text;
225
239
  if (!text)
226
240
  return null;
227
241
  return {
228
- world_id: ctx.worldId,
229
- session_id: ctx.sessionId,
230
- message_id: ctx.messageId,
231
- seq: ctx.seq,
242
+ world_id: worldId,
243
+ session_id: sessionId,
244
+ message_id: messageId,
245
+ seq,
232
246
  role: 'assistant',
233
247
  kind: 'text',
234
248
  chunk_type: 'text',
235
249
  chunk: text,
236
- created_at: ctx.createdAt,
250
+ created_at: createdAt,
237
251
  };
238
252
  }
239
253
  if (block.type === 'tool_use') {
240
254
  const tool = block;
241
255
  return {
242
- world_id: ctx.worldId,
243
- session_id: ctx.sessionId,
244
- message_id: ctx.messageId,
245
- seq: ctx.seq,
256
+ world_id: worldId,
257
+ session_id: sessionId,
258
+ message_id: messageId,
259
+ seq,
246
260
  role: 'tool',
247
261
  kind: 'tool-call',
248
262
  chunk_type: 'tool_use',
@@ -251,22 +265,22 @@ function blockToChunkDraft(block, ctx) {
251
265
  name: tool.name,
252
266
  input: tool.input,
253
267
  }),
254
- created_at: ctx.createdAt,
268
+ created_at: createdAt,
255
269
  };
256
270
  }
257
271
  // Unknown block types: preserve via JSON repr so nothing is silently
258
272
  // dropped (operator-visible kind='text' fallback keeps the stream
259
273
  // intact for forward-compat with future SDK content-block additions).
260
274
  return {
261
- world_id: ctx.worldId,
262
- session_id: ctx.sessionId,
263
- message_id: ctx.messageId,
264
- seq: ctx.seq,
275
+ world_id: worldId,
276
+ session_id: sessionId,
277
+ message_id: messageId,
278
+ seq,
265
279
  role: 'assistant',
266
280
  kind: 'text',
267
281
  chunk_type: 'text',
268
282
  chunk: JSON.stringify(block),
269
- created_at: ctx.createdAt,
283
+ created_at: createdAt,
270
284
  };
271
285
  }
272
286
  /**
@@ -0,0 +1,19 @@
1
+ /**
2
+ * checkout.ts — detect whether `olam ask` is running inside an olam checkout.
3
+ *
4
+ * When inside a checkout, the SDK is granted read-only filesystem tools (cwd =
5
+ * repo root) so it can pull live repo files for fresher answers. Outside a
6
+ * checkout (npx install), the bundled knowledge pack is the only grounding.
7
+ *
8
+ * Detection walks up from the start dir looking for an olam-shaped repo root:
9
+ * a directory containing BOTH `packages/host-cp` and `docs/architecture`.
10
+ * Both markers together avoid false positives on unrelated monorepos that
11
+ * merely have a `packages/` dir.
12
+ */
13
+ /**
14
+ * Walk up from `startDir` (default cwd) to the filesystem root, returning the
15
+ * first olam repo root found, or `null` when none. Pure relative to the
16
+ * injected `startDir`; uses real `existsSync` for the marker checks.
17
+ */
18
+ export declare function findOlamCheckoutRoot(startDir?: string): string | null;
19
+ //# sourceMappingURL=checkout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/ask/checkout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAaH;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,GAAE,MAAsB,GAAG,MAAM,GAAG,IAAI,CAWpF"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * checkout.ts — detect whether `olam ask` is running inside an olam checkout.
3
+ *
4
+ * When inside a checkout, the SDK is granted read-only filesystem tools (cwd =
5
+ * repo root) so it can pull live repo files for fresher answers. Outside a
6
+ * checkout (npx install), the bundled knowledge pack is the only grounding.
7
+ *
8
+ * Detection walks up from the start dir looking for an olam-shaped repo root:
9
+ * a directory containing BOTH `packages/host-cp` and `docs/architecture`.
10
+ * Both markers together avoid false positives on unrelated monorepos that
11
+ * merely have a `packages/` dir.
12
+ */
13
+ import { existsSync } from 'node:fs';
14
+ import { dirname, join, parse } from 'node:path';
15
+ /** Returns true when `dir` looks like an olam repo root. */
16
+ function isOlamRoot(dir) {
17
+ return (existsSync(join(dir, 'packages', 'host-cp')) &&
18
+ existsSync(join(dir, 'docs', 'architecture')));
19
+ }
20
+ /**
21
+ * Walk up from `startDir` (default cwd) to the filesystem root, returning the
22
+ * first olam repo root found, or `null` when none. Pure relative to the
23
+ * injected `startDir`; uses real `existsSync` for the marker checks.
24
+ */
25
+ export function findOlamCheckoutRoot(startDir = process.cwd()) {
26
+ let dir = startDir;
27
+ const { root } = parse(dir);
28
+ // Bound the walk by the filesystem root to avoid an infinite loop.
29
+ for (;;) {
30
+ if (isOlamRoot(dir))
31
+ return dir;
32
+ if (dir === root)
33
+ return null;
34
+ const parent = dirname(dir);
35
+ if (parent === dir)
36
+ return null;
37
+ dir = parent;
38
+ }
39
+ }
40
+ //# sourceMappingURL=checkout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../src/ask/checkout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEjD,4DAA4D;AAC5D,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,CACL,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;QAC5C,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAC9C,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAAmB,OAAO,CAAC,GAAG,EAAE;IACnE,IAAI,GAAG,GAAG,QAAQ,CAAC;IACnB,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5B,mEAAmE;IACnE,SAAS,CAAC;QACR,IAAI,UAAU,CAAC,GAAG,CAAC;YAAE,OAAO,GAAG,CAAC;QAChC,IAAI,GAAG,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAC9B,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;QAChC,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * knowledge-pack-builder.ts — assembles the bundled olam knowledge pack.
3
+ *
4
+ * The knowledge pack is a single Markdown string concatenating a curated set
5
+ * of repo docs (README, onboarding, top-level architecture overviews) plus a
6
+ * generated CLI command reference. It is produced at BUILD time by
7
+ * `scripts/gen-knowledge-pack.mjs` (which calls {@link buildKnowledgePack})
8
+ * and emitted into `src/ask/knowledge-pack.generated.ts` so the published
9
+ * `@pleri/olam-cli` tarball ships the pack inline — no repo checkout needed
10
+ * at runtime (the `npx` install case).
11
+ *
12
+ * Why a build-time pack and not runtime file reads alone: outside an olam
13
+ * checkout (installed via `npx`) there is no repo to read, yet operators still
14
+ * ask setup questions. The bundled pack guarantees a useful baseline answer.
15
+ * Inside a checkout, `olam ask` ADDITIONALLY lets the SDK read live repo files
16
+ * (via the Claude Code preset's Read/Grep tools) for fresher, precise answers.
17
+ *
18
+ * This module is pure: callers inject the repo root + a file reader so the
19
+ * generator script and its unit tests share one code path (Rule 9 — the test
20
+ * asserts the assembled shape without touching the real filesystem).
21
+ */
22
+ /** A doc to fold into the pack, identified by its repo-relative path. */
23
+ export interface PackSource {
24
+ /** Repo-relative path, e.g. `README.md` or `docs/architecture/03-system.md`. */
25
+ readonly path: string;
26
+ /** Human label rendered as the section heading inside the pack. */
27
+ readonly label: string;
28
+ /**
29
+ * When true, a missing file is tolerated (skipped with a note) rather than
30
+ * failing the build. Used for optional overview docs that may be renamed.
31
+ */
32
+ readonly optional?: boolean;
33
+ }
34
+ /**
35
+ * Curated source list. Ordered most-foundational first so truncation (if a
36
+ * future cap is added) drops the least-essential docs last. Kept small and
37
+ * overview-grade on purpose: the pack is the SDK system prompt, not a full
38
+ * doc dump — bloating it wastes the operator's local-subscription tokens and
39
+ * dilutes answer precision.
40
+ */
41
+ export declare const DEFAULT_PACK_SOURCES: readonly PackSource[];
42
+ /** Signature of the file reader the builder depends on (test seam). */
43
+ export type FileReader = (absPath: string) => string;
44
+ /** Signature of the existence check the builder depends on (test seam). */
45
+ export type FileExists = (absPath: string) => boolean;
46
+ export interface BuildKnowledgePackInput {
47
+ /** Absolute path to the repo root the doc paths resolve against. */
48
+ readonly repoRoot: string;
49
+ /** Reads a file as UTF-8; throws if unreadable. */
50
+ readonly readFile: FileReader;
51
+ /** Returns true when the file exists + is readable. */
52
+ readonly fileExists: FileExists;
53
+ /** Override the source list (tests). Defaults to {@link DEFAULT_PACK_SOURCES}. */
54
+ readonly sources?: readonly PackSource[];
55
+ /**
56
+ * The CLI command reference Markdown (a `command — description` list).
57
+ * Injected so the generator can derive it from the live commander program
58
+ * while tests pass a fixed string. Optional — omitted in pure-doc tests.
59
+ */
60
+ readonly commandReference?: string;
61
+ /** Path joiner (test seam); defaults to POSIX join via the generator. */
62
+ readonly join: (root: string, rel: string) => string;
63
+ }
64
+ /**
65
+ * Assemble the knowledge pack string from the curated sources + command
66
+ * reference. Pure: no I/O of its own — all filesystem access flows through the
67
+ * injected `readFile`/`fileExists`. Missing REQUIRED docs throw (the build
68
+ * must fail loudly per Rule 12); missing OPTIONAL docs are skipped with an
69
+ * inline note so the pack stays coherent.
70
+ */
71
+ export declare function buildKnowledgePack(input: BuildKnowledgePackInput): string;
72
+ //# sourceMappingURL=knowledge-pack-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knowledge-pack-builder.d.ts","sourceRoot":"","sources":["../../src/ask/knowledge-pack-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,yEAAyE;AACzE,MAAM,WAAW,UAAU;IACzB,gFAAgF;IAChF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,UAAU,EA2BrD,CAAC;AAEF,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;AAErD,2EAA2E;AAC3E,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;AAEtD,MAAM,WAAW,uBAAuB;IACtC,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,uDAAuD;IACvD,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,kFAAkF;IAClF,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CACtD;AAUD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,MAAM,CAwBzE"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * knowledge-pack-builder.ts — assembles the bundled olam knowledge pack.
3
+ *
4
+ * The knowledge pack is a single Markdown string concatenating a curated set
5
+ * of repo docs (README, onboarding, top-level architecture overviews) plus a
6
+ * generated CLI command reference. It is produced at BUILD time by
7
+ * `scripts/gen-knowledge-pack.mjs` (which calls {@link buildKnowledgePack})
8
+ * and emitted into `src/ask/knowledge-pack.generated.ts` so the published
9
+ * `@pleri/olam-cli` tarball ships the pack inline — no repo checkout needed
10
+ * at runtime (the `npx` install case).
11
+ *
12
+ * Why a build-time pack and not runtime file reads alone: outside an olam
13
+ * checkout (installed via `npx`) there is no repo to read, yet operators still
14
+ * ask setup questions. The bundled pack guarantees a useful baseline answer.
15
+ * Inside a checkout, `olam ask` ADDITIONALLY lets the SDK read live repo files
16
+ * (via the Claude Code preset's Read/Grep tools) for fresher, precise answers.
17
+ *
18
+ * This module is pure: callers inject the repo root + a file reader so the
19
+ * generator script and its unit tests share one code path (Rule 9 — the test
20
+ * asserts the assembled shape without touching the real filesystem).
21
+ */
22
+ /**
23
+ * Curated source list. Ordered most-foundational first so truncation (if a
24
+ * future cap is added) drops the least-essential docs last. Kept small and
25
+ * overview-grade on purpose: the pack is the SDK system prompt, not a full
26
+ * doc dump — bloating it wastes the operator's local-subscription tokens and
27
+ * dilutes answer precision.
28
+ */
29
+ export const DEFAULT_PACK_SOURCES = [
30
+ { path: 'README.md', label: 'Olam — README (overview, substrates, scope)' },
31
+ {
32
+ path: 'docs/ONBOARDING.md',
33
+ label: 'Onboarding (first-run, install, getting started)',
34
+ optional: true,
35
+ },
36
+ {
37
+ path: 'docs/onboarding/fresh-machine-setup.md',
38
+ label: 'Setup — fresh machine',
39
+ optional: true,
40
+ },
41
+ {
42
+ path: 'docs/architecture/01-problem.md',
43
+ label: 'Architecture — the problem olam solves',
44
+ optional: true,
45
+ },
46
+ {
47
+ path: 'docs/architecture/03-system.md',
48
+ label: 'Architecture — system overview',
49
+ optional: true,
50
+ },
51
+ {
52
+ path: 'docs/architecture/04-lifecycle.md',
53
+ label: 'Architecture — world lifecycle',
54
+ optional: true,
55
+ },
56
+ ];
57
+ /** A simple, self-describing header so the model knows what it's reading. */
58
+ const PACK_HEADER = `# Olam knowledge pack
59
+
60
+ The sections below are curated excerpts from the olam repository's own
61
+ documentation, bundled into the CLI at build time. Treat them as the
62
+ authoritative source for olam usage, setup, and CLI behaviour. When a section
63
+ conflicts with your prior knowledge, the section wins.`;
64
+ /**
65
+ * Assemble the knowledge pack string from the curated sources + command
66
+ * reference. Pure: no I/O of its own — all filesystem access flows through the
67
+ * injected `readFile`/`fileExists`. Missing REQUIRED docs throw (the build
68
+ * must fail loudly per Rule 12); missing OPTIONAL docs are skipped with an
69
+ * inline note so the pack stays coherent.
70
+ */
71
+ export function buildKnowledgePack(input) {
72
+ const sources = input.sources ?? DEFAULT_PACK_SOURCES;
73
+ const parts = [PACK_HEADER];
74
+ for (const src of sources) {
75
+ const abs = input.join(input.repoRoot, src.path);
76
+ if (!input.fileExists(abs)) {
77
+ if (src.optional) {
78
+ parts.push(`## ${src.label}\n\n_(source \`${src.path}\` not present in this build — skipped)_`);
79
+ continue;
80
+ }
81
+ throw new Error(`buildKnowledgePack: required source missing: ${src.path} (resolved ${abs})`);
82
+ }
83
+ const body = input.readFile(abs).trim();
84
+ parts.push(`## ${src.label}\n\nSource: \`${src.path}\`\n\n${body}`);
85
+ }
86
+ if (input.commandReference && input.commandReference.trim().length > 0) {
87
+ parts.push(`## CLI command reference\n\n${input.commandReference.trim()}`);
88
+ }
89
+ return parts.join('\n\n---\n\n') + '\n';
90
+ }
91
+ //# sourceMappingURL=knowledge-pack-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knowledge-pack-builder.js","sourceRoot":"","sources":["../../src/ask/knowledge-pack-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAeH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA0B;IACzD,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,6CAA6C,EAAE;IAC3E;QACE,IAAI,EAAE,oBAAoB;QAC1B,KAAK,EAAE,kDAAkD;QACzD,QAAQ,EAAE,IAAI;KACf;IACD;QACE,IAAI,EAAE,wCAAwC;QAC9C,KAAK,EAAE,uBAAuB;QAC9B,QAAQ,EAAE,IAAI;KACf;IACD;QACE,IAAI,EAAE,iCAAiC;QACvC,KAAK,EAAE,wCAAwC;QAC/C,QAAQ,EAAE,IAAI;KACf;IACD;QACE,IAAI,EAAE,gCAAgC;QACtC,KAAK,EAAE,gCAAgC;QACvC,QAAQ,EAAE,IAAI;KACf;IACD;QACE,IAAI,EAAE,mCAAmC;QACzC,KAAK,EAAE,gCAAgC;QACvC,QAAQ,EAAE,IAAI;KACf;CACF,CAAC;AA2BF,6EAA6E;AAC7E,MAAM,WAAW,GAAG;;;;;uDAKmC,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAA8B;IAC/D,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,oBAAoB,CAAC;IACtD,MAAM,KAAK,GAAa,CAAC,WAAW,CAAC,CAAC;IAEtC,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;gBACjB,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,KAAK,kBAAkB,GAAG,CAAC,IAAI,0CAA0C,CAAC,CAAC;gBAChG,SAAS;YACX,CAAC;YACD,MAAM,IAAI,KAAK,CACb,gDAAgD,GAAG,CAAC,IAAI,cAAc,GAAG,GAAG,CAC7E,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QACxC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,KAAK,iBAAiB,GAAG,CAAC,IAAI,SAAS,IAAI,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,IAAI,KAAK,CAAC,gBAAgB,IAAI,KAAK,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvE,KAAK,CAAC,IAAI,CAAC,+BAA+B,KAAK,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * AUTO-GENERATED by scripts/gen-knowledge-pack.mjs — DO NOT EDIT BY HAND.
3
+ *
4
+ * The bundled olam knowledge pack used as the `olam ask` SDK system prompt.
5
+ * Regenerate with: npm run gen:knowledge-pack --workspace=@pleri/olam-cli
6
+ */
7
+ export declare const KNOWLEDGE_PACK: string;
8
+ //# sourceMappingURL=knowledge-pack.generated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knowledge-pack.generated.d.ts","sourceRoot":"","sources":["../../src/ask/knowledge-pack.generated.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,eAAO,MAAM,cAAc,EAAE,MAk5D5B,CAAC"}