@crewhaus/target-crew 0.2.3 → 0.3.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 (2) hide show
  1. package/dist/index.js +72 -7
  2. package/package.json +5 -4
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@
19
19
  import { CrewhausError } from "@crewhaus/errors";
20
20
  import { escapeJsonString } from "@crewhaus/infra-utils";
21
21
  import { renderBundleReadme, } from "@crewhaus/ir";
22
+ import { memoryFragmentFromIr } from "@crewhaus/memory-service";
22
23
  export class TargetEmitError extends CrewhausError {
23
24
  name = "TargetEmitError";
24
25
  constructor(message, cause) {
@@ -233,6 +234,30 @@ function roleVar(name) {
233
234
  // ---------------------------------------------------------------------------
234
235
  // File: daemon.ts — entrypoint. Reads stdin, drives the crew, prints events.
235
236
  // ---------------------------------------------------------------------------
237
+ /**
238
+ * v0.3.0 PR 11 — the crew shape's memory-fabric wiring state. `wired` when
239
+ * the IR carries an enabled `memory` block and/or a `continuity` block
240
+ * (DEFAULT-ON in 0.3.0 — only `continuity: false` removes it). Scope is
241
+ * `spec`, shared by every role: the plan store IS the coordination surface
242
+ * (§2.7); the tools/seams thread crew-wide through the orchestrator's
243
+ * `extraTools`/`memory`/`continuity`/`skills` RunOptions.
244
+ */
245
+ function memoryFabric(ir) {
246
+ const memoryOn = ir.memory !== undefined && ir.memory.enabled !== false;
247
+ const continuityOn = ir.continuity !== undefined;
248
+ const wired = memoryOn || continuityOn;
249
+ const fragmentJson = wired
250
+ ? JSON.stringify(memoryFragmentFromIr({
251
+ name: ir.name,
252
+ ...(memoryOn ? { memory: ir.memory } : {}),
253
+ ...(continuityOn ? { continuity: ir.continuity } : {}),
254
+ // v0.3.0 Goal 2 (PR 17) — learning rides the fragment: wireMemory
255
+ // renders the learning-loop skill + gates in /study /reflect.
256
+ ...(ir.learning !== undefined ? { learning: ir.learning } : {}),
257
+ }))
258
+ : "";
259
+ return { wired, fragmentJson };
260
+ }
236
261
  function renderDaemon(ir) {
237
262
  const hasRules = ir.permissions.rules.length > 0;
238
263
  const permImport = hasRules
@@ -240,10 +265,44 @@ function renderDaemon(ir) {
240
265
  : "";
241
266
  const permField = renderPermissionsField(ir);
242
267
  const taxonomyField = renderFailureTaxonomyField(ir);
268
+ const fabric = memoryFabric(ir);
269
+ const memImport = fabric.wired
270
+ ? `import { wireMemory } from "@crewhaus/memory-service";
271
+ import { createSkillTool } from "@crewhaus/skills-registry";
272
+ import type { RegisteredTool } from "@crewhaus/tool-catalog";
273
+ `
274
+ : "";
275
+ const memBoot = fabric.wired
276
+ ? `
277
+ // v0.3.0 — the memory fabric, wired ONCE through the stable composition-
278
+ // root call (design §1 principle 1): roles share the spec-scoped stores;
279
+ // the orchestrator threads the tools + seams into every role's turn.
280
+ const __memTools: RegisteredTool[] = [];
281
+ const __memWired = await wireMemory(${fabric.fragmentJson}, {
282
+ catalog: { register: (t: RegisteredTool) => { __memTools.push(t); } },
283
+ cwd: process.cwd(),
284
+ });
285
+ const __skills = __memWired.options.skills ?? [];
286
+ if (__skills.length > 0) __memTools.push(createSkillTool(__skills));`
287
+ : "";
288
+ const memOptsFields = fabric.wired
289
+ ? `
290
+ extraTools: __memTools,
291
+ ...(__memWired.options.memory !== undefined ? { memory: __memWired.options.memory } : {}),
292
+ ...(__memWired.options.continuity !== undefined ? { continuity: __memWired.options.continuity } : {}),
293
+ ...(__skills.length > 0 ? { skills: __skills } : {}),`
294
+ : "";
295
+ // v0.3.0 Goal 3 — thredz is spec-carried on this shape but not emit-wired
296
+ // in this release (the one-knob backend flip ships on cli). Surface it,
297
+ // 0.2.3-style, so nobody wonders why their wiki stayed local.
298
+ const thredzWarning = ir.thredz !== undefined
299
+ ? "// note: thredz configured but ignored on crew in 0.3.0 — the Thredz backend flip is wired on the cli shape (design §4)\n"
300
+ : "";
243
301
  return `#!/usr/bin/env bun
244
302
  // Generated by crewhaus. DO NOT EDIT.
245
303
  // Source spec: ${escapeJsonString(ir.name)} (target: crew, ir version: ${ir.version}, file: daemon.ts)
246
- ${permImport}import { buildCrew } from "./orchestrator.js";
304
+ ${thredzWarning}import { formatRunFailure, toFailureReport } from "@crewhaus/errors";
305
+ ${permImport}${memImport}import { buildCrew } from "./orchestrator.js";
247
306
 
248
307
  async function main(): Promise<void> {
249
308
  const crew = buildCrew();
@@ -252,8 +311,8 @@ async function main(): Promise<void> {
252
311
  if (trimmed.length === 0) {
253
312
  process.stderr.write("[crew] no input on stdin\\n");
254
313
  process.exit(2);
255
- }
256
- const opts: Parameters<typeof crew.run>[1] = {${permField}${taxonomyField}
314
+ }${memBoot}
315
+ const opts: Parameters<typeof crew.run>[1] = {${permField}${taxonomyField}${memOptsFields}
257
316
  };
258
317
  let lastFinalOutput = "";
259
318
  try {
@@ -262,8 +321,12 @@ async function main(): Promise<void> {
262
321
  if (ev.kind === "crew_done") lastFinalOutput = ev.finalOutput;
263
322
  }
264
323
  } catch (err) {
265
- process.stderr.write(\`[crew] error: \${(err as Error).message}\\n\`);
266
- process.exit(1);
324
+ // v0.3.0 Goal 6 — render the one structured failure report (classified
325
+ // for a RunFailedError, generic otherwise) and exit with its coded
326
+ // status instead of the bare "[crew] error:" line + exit 1.
327
+ const __report = toFailureReport(err);
328
+ process.stderr.write(\`\${formatRunFailure(__report, { prefix: "[crew]" })}\\n\`);
329
+ process.exit(__report.exitCode);
267
330
  }
268
331
  if (lastFinalOutput.length > 0) {
269
332
  const PREVIEW_LIMIT = 200;
@@ -285,8 +348,10 @@ async function readAllStdin(): Promise<string> {
285
348
  }
286
349
 
287
350
  main().catch((err) => {
288
- process.stderr.write(\`[crew] fatal: \${(err as Error).message}\\n\`);
289
- process.exit(1);
351
+ // v0.3.0 Goal 6 — no unhandled Bun stack: same report, coded exit.
352
+ const __report = toFailureReport(err);
353
+ process.stderr.write(\`\${formatRunFailure(__report, { prefix: "[crew]" })}\\n\`);
354
+ process.exit(__report.exitCode);
290
355
  });
291
356
  `;
292
357
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crewhaus/target-crew",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "Codegen for the CRW target — emits a daemon + per-role agent files driven by crew-orchestrator (Section 22)",
6
6
  "main": "dist/index.js",
@@ -15,9 +15,10 @@
15
15
  "test": "bun test src"
16
16
  },
17
17
  "dependencies": {
18
- "@crewhaus/errors": "0.2.3",
19
- "@crewhaus/infra-utils": "0.2.3",
20
- "@crewhaus/ir": "0.2.3"
18
+ "@crewhaus/errors": "0.3.0",
19
+ "@crewhaus/infra-utils": "0.3.0",
20
+ "@crewhaus/ir": "0.3.0",
21
+ "@crewhaus/memory-service": "0.3.0"
21
22
  },
22
23
  "license": "Apache-2.0",
23
24
  "author": {