dreamteamer 0.47.0 → 0.48.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/README.md CHANGED
@@ -121,6 +121,14 @@ for (const { id, fields } of store.readAll('notes')) {
121
121
  }
122
122
  ```
123
123
 
124
+ ## Writing a module
125
+
126
+ A module is one npm package with a `dreamteamer` block, and the engine is all it needs:
127
+ `dt add modules --name acme --extension --package @acme/acme` scaffolds a publishable one inside any
128
+ workspace, its tests run on the real engine through `import … from 'dreamteamer/testing'`, and
129
+ `dt check modules/acme --alone` says whether it is publishable before you `npm publish`
130
+ ([`references/writing-a-module.md`](skills/using-dreamteamer/references/writing-a-module.md)).
131
+
124
132
  ## Extensions
125
133
 
126
134
  An extension adds verbs, source kinds or harnesses through one contract
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dreamteamer",
3
- "version": "0.47.0",
3
+ "version": "0.48.0",
4
4
  "description": "A workspace compiler for coding agents \u2014 schema-validated records as plain files over git, compiled into every harness",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Gilad Khen <giladkhen@gmail.com>",
@@ -40,6 +40,10 @@
40
40
  "types": "./src/records-api.d.ts",
41
41
  "default": "./src/records-api.js"
42
42
  },
43
+ "./testing": {
44
+ "types": "./src/testing.d.ts",
45
+ "default": "./src/testing.js"
46
+ },
43
47
  "./package.json": "./package.json"
44
48
  },
45
49
  "bin": {
@@ -154,6 +154,7 @@ Load by the map; nothing here is loaded "just in case".
154
154
  | a route, a nav entry, a board / calendar / map over records | `references/ui-views.md` |
155
155
  | a rendering or editing behaviour nothing registered has | `references/ui-components.md` |
156
156
  | an optional tool — behaviour proofs, worktrees, a REST server, an exporter, a new harness — and whether to write one | `references/extensions.md` |
157
+ | writing, testing and publishing a module of your own — `dt add modules --extension --package`, a setup unit, `dreamteamer/testing`, `dt check modules/<id> --alone` | `references/writing-a-module.md` |
157
158
  | other agent sessions are running on this machine — finding them, messaging one, coordinating several, and what may not cross between them | `references/sessions.md` |
158
159
 
159
160
  three act-two tie-breakers, because they are the ones that go wrong:
@@ -60,6 +60,39 @@ knowing the module (`setup.md`). `doctor` renders a unit's checks as rows. An in
60
60
  package's `dreamteamer.env` or `vars`. A composed package lists what it composes in `dreamteamer.provides`, so `dt install`
61
61
  refuses a duplicate in both directions.
62
62
 
63
+ Since 0.48.0:
64
+
65
+ - **an `env` action** — `{ id, title, env: { KEY: value, … }, state? }` — is performed by the engine, not by `apply`: the
66
+ `.env` write, confined to the workspace, every other line kept, the value never printed. Judged when the plan is read:
67
+ `done` when every key holds its value (whatever it holds — a value set by hand is never refused afterwards),
68
+ `needs-input` for an `undefined` value, `blocked` (nothing written, exit 0) for an undeclared key, a non-string value, a
69
+ key assigned twice, a value holding `"`, `$`, a backtick or a carriage return (or a backslash that would need quoting —
70
+ a Windows path is written unquoted), a leftover temp file, a `.env` git would commit, or a key another unit wrote in the
71
+ same run with a different value (two units may share a key, never disagree on it); a leading byte-order mark is kept; at write time a `.env` that changed after the plan is a failure (exit 1). A ready env action's `reason`
72
+ is the unit's note on what it wrote or left out, printed after the write (redacted). `.env` is the only file the engine
73
+ writes for a unit; anything else is an `apply` action with its effects.
74
+ - **`apply` is optional** — a non-env action from a unit without one fails by name. **`inspect` must be synchronous** — an
75
+ `async` one is refused at load, and a plain one that returns a Promise reads `blocked` naming the fix (`dt status`
76
+ reads it without awaiting).
77
+ - **redaction** touches failure text only — what a unit throws, a failed `apply` message, an action's `reason`; a check's
78
+ `fix`, any `title` and the next command print whole.
79
+ - **the engine is never a module's `dependencies`** — `dt check` names one that lists it (a second engine would nest);
80
+ `devDependencies` for the module's tests, an npm peer dependency optionally. `dreamteamer.engine` is the floor the engine reads.
81
+
82
+ The `ctx` each driver hands a unit:
83
+
84
+ | key | `dt setup` | `dt doctor` | `dt install` · `dt init` | `dt status` |
85
+ |---|---|---|---|---|
86
+ | `root`, `ws`, `env`, `receiptDir` | set | set | set | set |
87
+ | `tty` | the terminal | false | the terminal | false |
88
+ | `dt` | the engine's API | the engine's API | null | null |
89
+
90
+ `inspect` and `plan` must not depend on `ctx.dt`; a machine step that wants the API runs under `dt setup`.
91
+
92
+ Writing, testing and publishing a module end to end — the scaffold, `dreamteamer/testing`, `dt check modules/<id> --alone`
93
+ — is `references/writing-a-module.md`. `dreamteamer/testing` and `dreamteamer/records` are 0.x exports: a breaking change
94
+ lands in a minor, announced one release ahead in `UPDATING.md`.
95
+
63
96
  The `draft` is data only: the staged entries, the final merged descriptors, the modules, declared var
64
97
  and env key NAMES, and the previous manifest. No writer, no Store, no environment values — an analysis
65
98
  that needs one is a command, not an analysis.
@@ -113,8 +113,10 @@ holds — nothing else was committed).
113
113
 
114
114
  ## writing a unit (module authors)
115
115
 
116
- A module declares `setup: [{ id, version: 1, inputs, inspect, plan, apply }]` in its extension
117
- contribution — `references/extensions.md` has the shape. `inspect` is local and side-effect-free;
118
- `plan` names each action with its effects and a preview; `apply` performs one previewed action and
119
- refuses a stale preview. A verify action writes a dated receipt the next inspect reads. The engine
116
+ A module declares `setup: [{ id, version: 1, inputs, inspect, plan, apply? }]` in its extension
117
+ contribution — `references/extensions.md` has the shape, `references/writing-a-module.md` the whole
118
+ path. `inspect` is local, side-effect-free and synchronous; `plan` names each action with its effects
119
+ and a preview. An action carrying `env: { KEY: value }` is the engine's to perform — `.env` is the only
120
+ file the engine writes for a unit; `apply` performs every other previewed action and refuses a stale
121
+ preview. A verify action writes a dated receipt the next inspect reads. The engine
120
122
  never learns the module's name; `dt status` and `dt doctor` render whatever the unit reports.
@@ -0,0 +1,132 @@
1
+ # writing a module — scaffold, setup, test, gate, publish
2
+
3
+ A module is one npm package whose `package.json` carries a `dreamteamer` block. Writing one needs the
4
+ engine and nothing else: no helper package, no file copied from anyone's repository. You develop it
5
+ inside a workspace (the inline `modules/<id>` channel is dev mode), test it on the real engine, prove
6
+ it publishable with one command, and `npm publish`. A consumer then runs `dt install <name>`.
7
+
8
+ ## 1. scaffold
9
+
10
+ ```bash
11
+ dt add modules --name acme --extension --package @acme/acme --description "Acme records."
12
+ ```
13
+
14
+ That writes, and commits in one scoped commit:
15
+
16
+ - `modules/acme/package.json` — `name` `@acme/acme`, `version` `0.1.0`, `type` `module`, a `files`
17
+ list covering every kind folder plus `src` and `README.md`, `devDependencies.dreamteamer` pinned to
18
+ the engine you ran, and `dreamteamer.engine: ">=<that version>"` — the floor the module is written
19
+ against.
20
+ - `modules/acme/src/extension.js` — `activate(dt)` returning one setup unit (below).
21
+ - `modules/acme/README.md` — the install line and the develop/test/gate loop.
22
+ - `modules/acme/test/module.test.mjs` — one test on `dreamteamer/testing`, run by `npm test`.
23
+ - every kind folder (`collections/`, `skills/`, …) for the content you add.
24
+
25
+ Without `--package` the module stays private (folder = package name = id); without `--extension` there
26
+ is no `src/`. `dt compile && dt status` makes it live in this workspace.
27
+
28
+ ## 2. the manifest rules
29
+
30
+ - **`dreamteamer.engine`** is the one floor the engine reads (`dt install`, compile, `--alone`). Raise
31
+ it when you use something a newer engine added.
32
+ - **`devDependencies.dreamteamer`** is where your own tests get an engine.
33
+ - **an npm peer dependency on `dreamteamer`** is optional and conventional; a miss prints `dt update --engine`.
34
+ - **never `dependencies.dreamteamer`** — npm would nest a second engine beside the workspace's, and
35
+ your code would disagree with the engine the operator ran. `dt check` names it.
36
+ - No new keys: `dreamteamer` is a closed set, and an unknown key fails compile on every engine.
37
+
38
+ A module never imports the engine and never imports another module. The engine reaches your code as
39
+ `activate(dt)`, with `dt` the running engine's API.
40
+
41
+ ## 3. setup — the unit
42
+
43
+ A module that needs something per machine (a token, a folder, a download) declares a setup unit. The
44
+ scaffold's, with its comments removed:
45
+
46
+ ```js
47
+ const KEY = 'ACME_TOKEN';
48
+ function inspect(ctx) {
49
+ return { checks: [{ id: 'acme.token', status: ctx.env[KEY] ? 'configured' : 'missing', title: KEY, fix: 'dt setup acme --input token=<token>' }] };
50
+ }
51
+ function plan(ctx, inputs) {
52
+ const token = inputs.token ?? ctx.env[KEY];
53
+ return {
54
+ checks: inspect({ ...ctx, env: { ...ctx.env, ...(token ? { [KEY]: token } : {}) } }).checks,
55
+ actions: [{ id: 'set-token', title: `write ${KEY} into .env`, env: { [KEY]: token }, state: token ? 'ready' : 'needs-input' }],
56
+ needs: token ? [] : ['token'],
57
+ };
58
+ }
59
+ export default function activate(dt) {
60
+ return { setup: [{ id: 'acme', version: 1, inputs: [{ id: 'token', kind: 'string', env: KEY, required: true }], inspect, plan }] };
61
+ }
62
+ ```
63
+
64
+ - **`inspect` is synchronous and read-only** — `dt status` calls it without awaiting; an `async`
65
+ inspect is refused at load, one that returns a Promise reads `blocked`.
66
+ - **An `env` action is the engine's to perform.** Name the keys and values; the engine writes `.env`:
67
+ inside the workspace only, every other line kept, refused (`blocked`, nothing written) when git would
68
+ commit `.env`, when a key is assigned twice, or a value holds `"`, `$`, a backtick or a carriage return
69
+ (a shell sourcing `.env` would read it differently), and refused (`failed`, exit 1) when `.env`
70
+ changed after the plan. A value already in the file is `done`, however it got there. The value is never printed. A value not yet known
71
+ (`undefined`) makes the action `needs-input`; a key already holding its value makes it `done`.
72
+ Every key must be in `dreamteamer.env` or `vars`.
73
+ - **`.env` is the only file the engine writes for a unit** (0.48.0). Anything else your unit makes —
74
+ a download, a venv, a receipt under `ctx.receiptDir` — is an `apply` action with its `effects`
75
+ (`download`, `network`, `machine`, `account`), and the engine asks consent for each.
76
+ - **`apply` is optional.** A unit whose actions all carry `env` needs none; a non-env action from a
77
+ unit without `apply` fails by name.
78
+ - A check's `fix` is printed whole; a thrown error, a failed `apply` message and an action's `reason`
79
+ are redacted (values after `key=`, e-mails, home folders, long tokens).
80
+
81
+ `references/extensions.md` has the full contract and the `ctx` each verb hands over;
82
+ `references/setup.md` how a person drives it.
83
+
84
+ ## 4. test — `dreamteamer/testing`
85
+
86
+ ```js
87
+ import { test } from 'node:test';
88
+ import assert from 'node:assert/strict';
89
+ import { fileURLToPath } from 'node:url';
90
+ import { createWorkspace, install, run } from 'dreamteamer/testing';
91
+
92
+ test('installs, and asks for its token', () => {
93
+ const ws = createWorkspace(); // dt init on the engine running this test
94
+ const r = install(ws, fileURLToPath(new URL('..', import.meta.url))); // packed with npm pack, then dt install
95
+ assert.equal(r.status, 3); // 3: a required input is still missing
96
+ assert.match(run(ws, ['status']).stdout, /acme\s+configured\s+ACME_TOKEN missing/);
97
+ });
98
+ ```
99
+
100
+ Run it with `node --test`. Every helper spawns the engine as a consumer does; `ENGINE` is the
101
+ `dreamteamer` your `devDependencies` installed, never one on `PATH`. `DT_ENGINE_DIR=<checkout>`
102
+ points `createWorkspace` at another engine (CI against an unreleased one). `run(ws, args, { env,
103
+ input, timeoutMs })` — `status` is `null` when a run hit its timeout.
104
+
105
+ ## 5. gate — `--alone`
106
+
107
+ ```bash
108
+ dt check modules/acme --alone
109
+ ```
110
+
111
+ Packs the module, installs it into a fresh workspace on this engine with only its declared
112
+ `dreamteamer.dependencies` (packed from this workspace, never fetched), compiles, checks, and prints
113
+ its setup line. **Exit 0 is publishable** — including a unit still waiting for an input a stranger
114
+ will give. Exit 1 names what is wrong (a dependency not held here, a floor above this engine, a
115
+ `files` list missing the entry, a compile or check error); 2 is usage. `--keep` leaves the temp
116
+ workspace. It does not run your `npm test` — run both. It packs with `--ignore-scripts` (it runs none of
117
+ your code); `pack()` in your own tests runs your `prepack`. A module that builds in `prepack` ships its
118
+ built files in `files`, or the gate judges the unbuilt package.
119
+
120
+ ## 6. publish
121
+
122
+ ```bash
123
+ cd modules/acme && npm publish --access public
124
+ ```
125
+
126
+ A consumer: `dt install @acme/acme`, then `dt setup acme --input token=<token>`.
127
+
128
+ ## what a pin buys
129
+
130
+ `dreamteamer/testing` and `dreamteamer/records` are 0.x exports: a breaking change lands in a minor
131
+ and is announced one release ahead in `UPDATING.md`; a removed name keeps working one release with a
132
+ deprecation line on stderr.
package/src/api.js CHANGED
@@ -12,8 +12,9 @@ import path from 'node:path';
12
12
  import { fileURLToPath } from 'node:url';
13
13
  import * as self from './api.js';
14
14
  import { findWorkspace } from './workspace.js';
15
- import { loadExtensions } from './extensions.js';
16
- import { KINDS } from './compile.js';
15
+ import { loadExtensions, manifestViolations } from './extensions.js';
16
+ import fs from 'node:fs';
17
+ import { KINDS, discoverModules } from './compile.js';
17
18
  import { DERIVED_KINDS } from './runtime.js';
18
19
  import { KNOWN_HARNESSES } from './harnesses.js';
19
20
  import { CORE_VERBS } from './cli.js';
@@ -46,6 +47,17 @@ export const CHECK_WARNINGS = true;
46
47
  * item the extension marked `warning: true` keeps the mark: `check` prints it and does not count it. */
47
48
  export async function contributedViolations(ws) {
48
49
  const out = [];
50
+ // every discovered module's manifest, held to the dependency rule — the workspace's own root and the
51
+ // engine are not modules anybody installs
52
+ try {
53
+ for (const m of discoverModules(ws.root, ws.pkg).modules) {
54
+ if (path.resolve(m.root) === path.resolve(ws.root)) continue;
55
+ let pkg;
56
+ try { pkg = JSON.parse(fs.readFileSync(path.join(m.root, 'package.json'), 'utf8')); } catch { continue; }
57
+ if (pkg.name === 'dreamteamer') continue;
58
+ for (const v of manifestViolations(pkg, path.relative(ws.root, path.join(m.root, 'package.json')))) out.push({ file: v.file, msg: v.message });
59
+ }
60
+ } catch { /* discovery failing is compile's to report */ }
49
61
  for (const e of (ws.extensions ?? []).filter((x) => x.check)) {
50
62
  try {
51
63
  for (const v of (await e.check({ root: ws.root, ws, dt: self })) ?? []) out.push({ file: v.file ?? e.name, msg: `${v.message} (${e.name})`, ...(v.warning === true ? { warning: true } : {}) });
@@ -0,0 +1,121 @@
1
+ // `dt check modules/<id> --alone` — is this inline module publishable? (cr-dt-007, G3, D63, D65)
2
+ //
3
+ // The gate does to a module what a stranger's workspace will: packs it with `npm pack` (so its `files`
4
+ // list is what is judged), `init`s a fresh workspace on THIS engine, `dt install`s the tarball with only
5
+ // the module's declared `dreamteamer.dependencies` (each packed from this workspace — `modules/` or
6
+ // `node_modules` — never fetched, so the gate is offline), then compiles and checks it and prints the
7
+ // module's setup line. It learns nothing about the module beyond its manifest, and it runs no package
8
+ // script of the author's (D63: the author's `npm test` is the author's).
9
+ //
10
+ // exit 0 publishable — including a unit that still needs an input a stranger supplies later (install 3)
11
+ // exit 1 refused, the first reason named: a dependency not held here, a floor above this engine, a
12
+ // refused install, a compile error, a check violation
13
+ // exit 2 usage
14
+ //
15
+ // Dispatched from src/cli.js before the host workspace is opened: a module whose dependency is
16
+ // missing would fail the HOST's compile, and the gate's whole point is to say so by name.
17
+ import fs from 'node:fs';
18
+ import os from 'node:os';
19
+ import path from 'node:path';
20
+ import { spawnSync } from 'node:child_process';
21
+ import { fileURLToPath } from 'node:url';
22
+ import { resolveNpm, childEnv } from './checkout.js';
23
+
24
+ const ENGINE = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
25
+ const IDENTITY = { GIT_AUTHOR_NAME: 'dreamteamer check', GIT_AUTHOR_EMAIL: 'check@example.invalid', GIT_COMMITTER_NAME: 'dreamteamer check', GIT_COMMITTER_EMAIL: 'check@example.invalid' };
26
+
27
+ /** Run `engine`'s CLI in `cwd`, output captured, no stdin. */
28
+ export function engineRun(engine, cwd, args, { env = {}, timeoutMs = 300_000, input } = {}) {
29
+ const r = spawnSync(process.execPath, [path.join(engine, 'bin', 'dreamteamer.js'), ...args], {
30
+ cwd, encoding: 'utf8', timeout: timeoutMs, killSignal: 'SIGKILL',
31
+ env: { ...process.env, ...IDENTITY, NO_COLOR: '1', ...env },
32
+ ...(input !== undefined ? { input } : { stdio: ['ignore', 'pipe', 'pipe'] }),
33
+ });
34
+ return { status: r.status, stdout: r.stdout ?? '', stderr: r.stderr ?? '' };
35
+ }
36
+
37
+ /** A fresh workspace in `root` on `engine`: the engine declared as a `file:` dependency and linked
38
+ * before `init`, so init finds it present and asks no registry. Throws with init's words on failure. */
39
+ export function freshWorkspace(root, engine = ENGINE) {
40
+ fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify({ name: path.basename(root).toLowerCase().replace(/[^a-z0-9-]/g, '-'), private: true, dependencies: { dreamteamer: `file:${engine}` } }, null, '\t') + '\n');
41
+ fs.mkdirSync(path.join(root, 'node_modules'), { recursive: true });
42
+ fs.symlinkSync(engine, path.join(root, 'node_modules', 'dreamteamer'), 'dir');
43
+ const r = engineRun(engine, root, ['init', '--no-input'], { timeoutMs: 180_000 });
44
+ if (r.status !== 0) throw new Error(`dt init failed (exit ${r.status}): ${(r.stderr || r.stdout).trim().split('\n')[0]}`);
45
+ return root;
46
+ }
47
+
48
+ const readPkg = (dir) => JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'));
49
+
50
+ /** Where this workspace holds a package by name: an inline module whose package.json names it, or node_modules/<name>. */
51
+ function locate(root, name) {
52
+ const inline = path.join(root, 'modules');
53
+ if (fs.existsSync(inline)) for (const d of fs.readdirSync(inline)) {
54
+ try { if (readPkg(path.join(inline, d)).name === name) return path.join(inline, d); } catch { /* not a module folder */ }
55
+ }
56
+ const npm = path.join(root, 'node_modules', name);
57
+ return fs.existsSync(path.join(npm, 'package.json')) ? fs.realpathSync(npm) : null;
58
+ }
59
+
60
+ function npmPack(npm, dir, dest) {
61
+ const before = new Set(fs.readdirSync(dest));
62
+ const r = spawnSync(npm, ['pack', '--silent', '--ignore-scripts', '--pack-destination', dest], { cwd: dir, encoding: 'utf8', timeout: 120_000, env: childEnv() });
63
+ if (r.status !== 0) throw new Error(`npm pack failed in ${dir}: ${(r.stderr || r.stdout).trim().split('\n')[0]}`);
64
+ return fs.readdirSync(dest).find((f) => f.endsWith('.tgz') && !before.has(f));
65
+ }
66
+
67
+ /** The gate. `target` is the positional (`modules/<id>`); returns the exit code. */
68
+ export function checkAlone(ws, { target, keep = false, log = console.log, error = console.error } = {}) {
69
+ const usage = (m) => { error(`✖ ${m}`); return 2; };
70
+ if (!target) return usage('check --alone takes modules/<id> — the inline module to judge');
71
+ const m = /^modules\/([^/]+)\/?$/.exec(target);
72
+ const dir = m && path.join(ws.root, 'modules', m[1]);
73
+ if (!dir || !fs.existsSync(path.join(dir, 'package.json'))) return usage(`${target} is not an inline module of this workspace — check --alone takes modules/<id>`);
74
+ const label = `modules/${m[1]}`;
75
+ let pkg;
76
+ try { pkg = readPkg(dir); } catch (e) { error(`✖ ${label}: package.json does not parse — ${e.message}`); return 1; }
77
+ if (!pkg.dreamteamer) { error(`✖ ${label}: package.json has no "dreamteamer" block — the engine would not see it as a module`); return 1; }
78
+ const npm = resolveNpm();
79
+ if (!npm) { error(`✖ ${label}: no npm beside this node or on PATH — the gate packs the module with it`); return 1; }
80
+
81
+ const tmp = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'dt-check-alone-')));
82
+ const refuse = (why) => { error(`✖ ${label}: ${why}`); if (keep) log(` kept: ${path.join(tmp, 'ws')}`); else fs.rmSync(tmp, { recursive: true, force: true }); return 1; };
83
+ try {
84
+ // the module and its declared dependency closure, packed into one folder `dt install --from` reads
85
+ const from = path.join(tmp, 'from');
86
+ fs.mkdirSync(from);
87
+ npmPack(npm, dir, from);
88
+ const deps = [];
89
+ const seen = new Set([pkg.name]);
90
+ const queue = [...(pkg.dreamteamer.dependencies ?? [])];
91
+ while (queue.length) {
92
+ const name = queue.shift();
93
+ if (seen.has(name)) continue;
94
+ seen.add(name);
95
+ const at = locate(ws.root, name);
96
+ if (!at) return refuse(`dependency ${name} is not installed here — install it, or drop it from dreamteamer.dependencies`);
97
+ npmPack(npm, at, from);
98
+ deps.push(name);
99
+ queue.push(...(readPkg(at).dreamteamer?.dependencies ?? []));
100
+ }
101
+ // a fresh workspace on this engine, the module installed the way a stranger installs it
102
+ const root = path.join(tmp, 'ws');
103
+ fs.mkdirSync(root);
104
+ freshWorkspace(root);
105
+ const inst = engineRun(ENGINE, root, ['install', pkg.name, '--from', from, '--no-input']);
106
+ if (inst.status !== 0 && inst.status !== 3) return refuse((inst.stderr || inst.stdout).trim().split('\n').find((l) => l.trim()) ?? `dt install exited ${inst.status}`);
107
+ const comp = engineRun(ENGINE, root, ['compile']);
108
+ if (comp.status !== 0) return refuse(`compile: ${(comp.stderr || comp.stdout).trim().split('\n')[0]}`);
109
+ const chk = engineRun(ENGINE, root, ['check']);
110
+ if (chk.status !== 0) return refuse(`check: ${(chk.stdout + chk.stderr).trim().split('\n').find((l) => l.startsWith('✖')) ?? `exited ${chk.status}`}`);
111
+ // the module's setup line(s), as a stranger's `dt status` will draw them
112
+ const status = engineRun(ENGINE, root, ['status']);
113
+ const setup = (status.stdout.split('setup:\n')[1] ?? '').split('\n').filter((l) => l.startsWith(' ') && !/^\s+dreamteamer\b/.test(l));
114
+ log(`✔ ${label} is publishable — packed, installed alone${deps.length ? ` (with ${deps.join(', ')})` : ''}, compiled, checked`);
115
+ for (const l of setup) log(l);
116
+ if (keep) log(` kept: ${root}`); else fs.rmSync(tmp, { recursive: true, force: true });
117
+ return 0;
118
+ } catch (e) {
119
+ return refuse(e.message);
120
+ }
121
+ }
package/src/checkout.js CHANGED
@@ -656,8 +656,9 @@ export async function initCommand(flags, { root = process.cwd(), open, verify, n
656
656
  const filled = await fillInputs(all, { flags: parseInputFlags(argv), env: unitEnv(ws, processEnv), tty, noInput, prompt: term?.prompt ?? null, lenient: true });
657
657
  for (const text of filled.ignored) log(`⚠ ${text} — ignored`);
658
658
  const allow = parseAllow(argv);
659
+ const written = new Map(); // one run never lets two units disagree on a key (he3)
659
660
  for (const u of all) {
660
- const r = await runUnit(ws, u, { inputs: filled.inputs.get(u.id) ?? {}, allow, tty, ask: term?.ask ?? null, processEnv, drop: droppedKeys(filled.problems, u.id) });
661
+ const r = await runUnit(ws, u, { inputs: filled.inputs.get(u.id) ?? {}, allow, tty, ask: term?.ask ?? null, processEnv, drop: droppedKeys(filled.problems, u.id), written });
661
662
  const problems = filled.problems.filter((m) => m.unit === u.id);
662
663
  const miss = [...filled.missing.filter((m) => m.unit === u.id).map((m) => m.id), ...problems.filter((m) => m.required).map((m) => m.id)];
663
664
  const f = fold(r.checks, {});
package/src/cli.js CHANGED
@@ -14,7 +14,8 @@ import fs from 'node:fs';
14
14
  import path from 'node:path';
15
15
  import { execFileSync } from 'node:child_process';
16
16
  import * as api from './api.js';
17
- import { openWorkspace } from './api.js';
17
+ import { openWorkspace, findWorkspace } from './api.js';
18
+ import { checkAlone } from './check-alone.js';
18
19
  import { compile, staleness, warnIfStale, discoverModules, CHANNEL_LABEL, locationOf, kindsOf, moduleIdOf, layerEntries } from './compile.js';
19
20
  import { check } from './check.js';
20
21
  import { collectionCommand, emit, relationsCommand, reportCommits } from './collections-cli.js';
@@ -128,11 +129,13 @@ commits there.
128
129
  health/doctors; a module declaring exactly ONE
129
130
  namespace infers it, and the resolved name is echoed.
130
131
  --namespace '' means no namespace)
131
- add modules --name <id> [--description "…"] [--namespace <ns>]
132
- (modules/<id>/ + every kind folder + package.json.
133
- --namespace DECLARES it in the module (§8), so every
134
- later \`add collections --module <id>\` infers it.
135
- folder = package name = id, so a module never forks.
132
+ add modules --name <id> [--description "…"] [--namespace <ns>] [--extension] [--package <npm name>]
133
+ (modules/<id>/ + every kind folder + package.json + README.md,
134
+ floored on this engine. --namespace DECLARES it in the module
135
+ (§8), so every later \`add collections --module <id>\` infers it.
136
+ --extension adds src/extension.js with a one-token setup unit;
137
+ --package names it for npm and makes it publishable — the
138
+ folder stays the id. Without it, folder = package name = id.
136
139
  the git shape is \`install --clone <url> [name]\`)
137
140
  add skills --name <id> --description "…" (skills/<id>/SKILL.md — --description is required,
138
141
  because an undescribed skill is undiscoverable)
@@ -263,6 +266,9 @@ workspace verbs:
263
266
  through a record layer is a ⚠ line until its exports manifest lists it; a reference no root
264
267
  answers is external when the referring repo's manifest vouches for it
265
268
  [--strict-export] makes each unlisted one, and a stale manifest, a violation
269
+ modules/<id> --alone: is that inline module publishable — packed, installed into a fresh
270
+ workspace on this engine with only its declared dependencies, compiled, checked; exit 0
271
+ publishable, 1 refused naming why, 2 usage [--keep] leaves the temp workspace
266
272
  exports write this workspace's dreamteamer-exports.json — each id its records name that no file
267
273
  here holds, with its label and the workspace holding it — and commit that one file
268
274
  [--layer <name>] that layer's, from this workspace's view [--dry-run] [--json]
@@ -333,7 +339,7 @@ export const GLOBAL_FLAGS = ['workspace', 'vault'];
333
339
  export const WORKSPACE_FLAGS = {
334
340
  init: ['name', 'data_path', 'harnesses', 'workspace_module', 'no-git', 'git', 'no-compile', 'from', 'input', 'allow', 'no-input'], update: ['engine', 'allow', 'from', 'no-commit'],
335
341
  install: ['clone', 'dry-run', 'json', 'link-env', 'all', 'hook', 'print-adapters', 'from', 'input', 'allow', 'no-input', 'no-commit'],
336
- compile: ['watch'], check: ['strict-export'], exports: ['layer', 'dry-run', 'json'], status: ['json'], doctor: ['strict', 'json'],
342
+ compile: ['watch'], check: ['strict-export', 'alone', 'keep'], exports: ['layer', 'dry-run', 'json'], status: ['json'], doctor: ['strict', 'json'],
337
343
  setup: ['input', 'allow', 'authorize', 'verify', 'skip', 'no-input', 'json'],
338
344
  changes: ['since', 'json'], commit: ['dry-run', 'json'], fmt: ['dry-run'], relocate: ['dry-run', 'json', 'to-root'],
339
345
  };
@@ -401,6 +407,14 @@ export async function run(argv) {
401
407
  emit(USAGE + extensionUsage(ws));
402
408
  process.exit(0);
403
409
  }
410
+ // `dt check modules/<id> --alone` judges one inline module in a fresh workspace (src/check-alone.js) —
411
+ // dispatched before the host is opened, because the module's own problem (a missing dependency, a
412
+ // floor above this engine) would otherwise surface as the host's refusal instead of the gate's verdict
413
+ if (cmd === 'check') {
414
+ const target = rest.find((a) => !a.startsWith('--'));
415
+ if (rest.includes('--alone')) process.exit(checkAlone(findWorkspace(), { target, keep: rest.includes('--keep') }));
416
+ if (target) { console.error(`✖ check takes no target — did you mean --alone? (dt check ${target} --alone judges one inline module)`); process.exit(2); }
417
+ }
404
418
  let ws;
405
419
  try { ws = await openWorkspace(); } catch (e) {
406
420
  // `status` is read-only and always answers: a runtime whose extensions refuse to load (two
@@ -358,9 +358,11 @@ function metaModulesAdd(ws, store, flags) {
358
358
  name: oneValue(flags, 'name'),
359
359
  description: oneValue(flags, 'description'),
360
360
  namespace: oneValue(flags, 'namespace'),
361
+ extension: flags.extension === true || flags.extension === 'true',
362
+ pkg: flags.package === undefined ? null : flags.package === true ? true : oneValue(flags, 'package'),
361
363
  });
362
364
  if (flags.json) { emit(JSON.stringify(out)); return 0; }
363
- console.log(`✔ ${out.root}/ — package.json + ${KIND_COUNT} kind folder(s)`);
365
+ console.log(`✔ ${out.root}/ — ${out.files.join(' · ')} + ${KIND_COUNT} kind folder(s)`);
364
366
  // §6.2 promises the namespace is DECLARED IN THE MODULE, and §8 makes every later
365
367
  // `add collections --module <id>` infer it — so the declaration is echoed, because an inferred
366
368
  // identity the operator did not type is one they must be able to read back.
@@ -1322,7 +1324,7 @@ export const VERB_FLAGS = {
1322
1324
  'collections:add': ['json', 'module', 'name', 'namespace', 'mixins', 'id-from', 'description', 'suffix'],
1323
1325
  'collections:get': ['json', 'module'], 'collections:set': ['json', 'module', 'dry-run'],
1324
1326
  'collections:rm': FORCE_RM, 'collections:rename': ['json', 'namespace', 'dry-run'], 'collections:reorder': NAV_MOVE,
1325
- 'modules:add': ['json', 'name', 'description', 'namespace'], 'modules:rename': JSON_ONLY, 'modules:rm': FORCE_RM,
1327
+ 'modules:add': ['json', 'name', 'description', 'namespace', 'extension', 'package'], 'modules:rename': JSON_ONLY, 'modules:rm': FORCE_RM,
1326
1328
  'modules:set': ['json', 'description', 'namespaces', 'dependencies', 'peer_collections'],
1327
1329
  // the identity kinds: `add` scaffolds, `rm`/`rename` fall through to the generic rows, and `set`
1328
1330
  // is deliberately UNCHECKED — a skill's frontmatter is an open document (`allowed-tools`, `model`,
package/src/compile.js CHANGED
@@ -616,7 +616,7 @@ export function compile(ws) {
616
616
  if (!sib || dep === mod) continue;
617
617
  const ok = satisfies(have, range);
618
618
  if (ok === null) console.warn(`⚠ module ${mod}: peerDependencies range "${range}" for "${dep}" (${have ?? 'no version'}) not understood by the built-in checker (see src/semver.js) — not verified`);
619
- else if (!ok) misses.push(`module "${mod}" ${moduleVersions.get(mod)} needs "${dep}" ${range} (its peerDependencies) — this workspace has ${have}, from ${CHANNEL_LABEL[sib.channel]}.\n fix: ${sib.channel === 'npm' ? `npm install "${dep}@${range}"` : `bring ${rel(sib.root)} to a version in ${range}`}`);
619
+ else if (!ok) misses.push(`module "${mod}" ${moduleVersions.get(mod)} needs "${dep}" ${range} (its peerDependencies) — this workspace has ${have}, from ${CHANNEL_LABEL[sib.channel]}.\n fix: ${dep === 'dreamteamer' ? `dt update --engine (the engine is the workspace's pin; init and install never change it)` : sib.channel === 'npm' ? `npm install "${dep}@${range}"` : `bring ${rel(sib.root)} to a version in ${range}`}`);
620
620
  }
621
621
  if (misses.length) fail(misses.join('\n'));
622
622
  }
package/src/doctor.js CHANGED
@@ -7,7 +7,7 @@ import path from 'node:path';
7
7
  import { engineId, readManifest } from './runtime.js';
8
8
  import { satisfies } from './semver.js';
9
9
  import { MANAGED_BLOCKS } from './harnesses.js';
10
- import { units, unitEnv, receiptDir, redact } from './setup.js';
10
+ import { units, unitEnv, receiptDir, redact, safeInspect } from './setup.js';
11
11
 
12
12
  const STATES = new Set(['ok', 'warn', 'bad']);
13
13
  const UNIT_STATE = { ready: 'ok', configured: 'ok', unverified: 'warn', missing: 'warn', blocked: 'bad' };
@@ -49,7 +49,7 @@ export async function doctorBoard(ws, dt) {
49
49
  const env = unitEnv(ws);
50
50
  for (const u of units(ws)) {
51
51
  let checks;
52
- try { checks = (u.inspect({ root: ws.root, ws, dt, env, tty: false, receiptDir: receiptDir(ws, u.id) })?.checks ?? []); } catch (err) { checks = [{ id: 'inspect', title: 'inspect', status: 'blocked', detail: redact(err.message), fix: `report it to ${u.module}` }]; }
52
+ checks = safeInspect(u, { root: ws.root, ws, dt, env, tty: false, receiptDir: receiptDir(ws, u.id) }).map((c) => (c.id === `${u.id}.inspect` ? { ...c, id: 'inspect', fix: `report it to ${u.module}` } : c));
53
53
  caps.push({ name: u.id, checks: checks.map((c) => ({ label: c.title ?? c.id, state: UNIT_STATE[c.status] ?? 'bad', detail: c.detail ?? (UNIT_STATE[c.status] ? '' : `unknown status ${JSON.stringify(c.status)}`), fix: c.fix })) });
54
54
  }
55
55
  for (const e of (ws.extensions ?? []).filter((x) => x.doctor)) {