@vimhead.dev/norn-cli 0.1.0-tip.35390859630.1 → 0.1.0-tip.35436871363.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/assets/README.md +8 -4
- package/assets/docs/README.md +4 -4
- package/assets/docs/agents.md +37 -9
- package/assets/docs/cli.md +3 -3
- package/assets/docs/composition.md +12 -12
- package/assets/docs/persistence.md +31 -17
- package/assets/docs/providers.md +2 -2
- package/assets/docs/workflows.md +15 -10
- package/assets/examples/agent-then-analysis/README.md +8 -8
- package/assets/examples/agent-then-analysis/plugin.ts +18 -16
- package/assets/examples/caller-selected-continuation/README.md +11 -10
- package/assets/examples/caller-selected-continuation/caller.ts +12 -10
- package/assets/examples/caller-selected-continuation/producer.ts +9 -6
- package/assets/examples/coordinating-multiple-agents/README.md +26 -16
- package/assets/examples/coordinating-multiple-agents/plugin.ts +58 -35
- package/assets/examples/coordinating-multiple-agents/queue-tools.ts +43 -0
- package/assets/examples/coordinating-multiple-agents/work-queue.ts +60 -65
- package/assets/examples/getting-started/README.md +2 -2
- package/assets/examples/getting-started/plugin.ts +7 -3
- package/assets/examples/minimal-workflow/README.md +5 -4
- package/assets/examples/minimal-workflow/plugin.ts +7 -4
- package/assets/examples/shared-state/README.md +5 -5
- package/assets/examples/shared-state/plugin.ts +35 -22
- package/assets/examples/shared-state/shared-state.ts +30 -49
- package/assets/examples/shared-state/state-tools.ts +68 -0
- package/assets/examples/worktree-development-loop/README.md +14 -12
- package/assets/examples/worktree-development-loop/workflows/development-loop/execute.ts +2 -2
- package/assets/examples/worktree-development-loop/workflows/development-loop/repository.ts +5 -3
- package/assets/examples/worktree-development-loop/workflows/implementation/execute.ts +8 -7
- package/assets/examples/worktree-development-loop/workflows/implementation/schema.ts +2 -3
- package/assets/examples/worktree-development-loop/workflows/planning/execute.ts +8 -4
- package/assets/examples/worktree-development-loop/workflows/review/execute.ts +10 -7
- package/assets/examples/worktree-development-loop/workflows/review/schema.ts +1 -2
- package/assets/examples/worktree-development-loop/workflows/review-router/execute.ts +15 -14
- package/assets/examples/worktree-development-loop/workflows/review-router/schema.ts +1 -2
- package/assets/package.json +1 -1
- package/assets/packages/cli/src/cli.ts +9 -3
- package/assets/packages/cli/src/generated-build-info.ts +2 -2
- package/assets/packages/cli/src/internal/agents.ts +24 -32
- package/assets/packages/cli/src/internal/commands.ts +2 -14
- package/assets/packages/cli/src/internal/engine.ts +30 -44
- package/assets/packages/cli/src/internal/logs.ts +1 -1
- package/assets/packages/cli/src/internal/run-log.ts +1 -1
- package/assets/packages/cli/src/internal/run-state.ts +7 -2
- package/assets/packages/cli/src/internal/run.ts +2 -57
- package/assets/packages/cli/src/internal/worker-directory.ts +17 -0
- package/assets/packages/cli/src/internal/workflow-registry.ts +20 -8
- package/assets/packages/cli/src/internal/working-directory.ts +6 -0
- package/assets/packages/cli/src/workflow-loader.ts +1 -2
- package/assets/packages/sdk/src/api.ts +27 -59
- package/assets/packages/sdk/src/index.ts +0 -3
- package/assets/tests/workflow-ref.test.ts +6 -7
- package/dist/cli.js +8 -3
- package/dist/generated-build-info.d.ts +2 -2
- package/dist/generated-build-info.js +2 -2
- package/dist/internal/agents.d.ts +0 -4
- package/dist/internal/agents.js +30 -46
- package/dist/internal/commands.d.ts +0 -4
- package/dist/internal/commands.js +2 -10
- package/dist/internal/engine.js +26 -40
- package/dist/internal/file-coordinator.d.ts +17 -0
- package/dist/internal/file-coordinator.js +162 -0
- package/dist/internal/logs.d.ts +1 -1
- package/dist/internal/run-log.d.ts +1 -1
- package/dist/internal/run-state.d.ts +2 -0
- package/dist/internal/run-state.js +5 -2
- package/dist/internal/run.d.ts +2 -20
- package/dist/internal/run.js +1 -45
- package/dist/internal/worker-directory.d.ts +1 -0
- package/dist/internal/worker-directory.js +26 -0
- package/dist/internal/workflow-registry.d.ts +13 -3
- package/dist/internal/workflow-registry.js +8 -6
- package/dist/internal/working-directory.d.ts +1 -0
- package/dist/internal/working-directory.js +9 -0
- package/dist/workflow-loader.js +1 -2
- package/package.json +2 -2
- package/assets/docs/resources.md +0 -46
- package/assets/examples/coordinating-multiple-agents/queue-adapter.ts +0 -51
- package/assets/examples/shared-state/state-adapter.ts +0 -76
- package/assets/packages/cli/src/internal/artifacts.ts +0 -26
- package/assets/packages/cli/src/internal/resource-bindings.ts +0 -35
- package/assets/packages/cli/src/resources.ts +0 -69
- package/assets/packages/sdk/src/agent-resource-adapter.ts +0 -11
- package/assets/packages/sdk/src/resources.ts +0 -20
- package/dist/internal/artifacts.d.ts +0 -10
- package/dist/internal/artifacts.js +0 -29
- package/dist/internal/resource-bindings.d.ts +0 -13
- package/dist/internal/resource-bindings.js +0 -34
- package/dist/resources.d.ts +0 -11
- package/dist/resources.js +0 -100
- /package/assets/packages/{sdk/src/files.ts → cli/src/internal/file-coordinator.ts} +0 -0
package/dist/resources.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// ../core/src/atomic-files.ts
|
|
2
|
-
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { chmod, mkdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
4
|
-
import { dirname } from "node:path";
|
|
5
|
-
|
|
6
|
-
// ../core/src/errors.ts
|
|
7
|
-
function isNodeError(error) {
|
|
8
|
-
return error instanceof Error && "code" in error;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// ../core/src/atomic-files.ts
|
|
12
|
-
async function writeJsonAtomically(path, value) {
|
|
13
|
-
await writeTextAtomically(path, `${JSON.stringify(value, null, 2)}
|
|
14
|
-
`);
|
|
15
|
-
}
|
|
16
|
-
async function writeTextAtomically(path, content) {
|
|
17
|
-
await mkdir(dirname(path), { recursive: true });
|
|
18
|
-
let existingMode;
|
|
19
|
-
try {
|
|
20
|
-
existingMode = (await stat(path)).mode & 511;
|
|
21
|
-
} catch (error) {
|
|
22
|
-
if (!isNodeError(error) || error.code !== "ENOENT") throw error;
|
|
23
|
-
}
|
|
24
|
-
const tmpPath = `${path}.${randomUUID()}.tmp`;
|
|
25
|
-
try {
|
|
26
|
-
await writeFile(tmpPath, content, { encoding: "utf8", mode: existingMode });
|
|
27
|
-
if (existingMode !== void 0) await chmod(tmpPath, existingMode);
|
|
28
|
-
await rename(tmpPath, path);
|
|
29
|
-
} catch (error) {
|
|
30
|
-
await rm(tmpPath, { force: true }).catch(() => void 0);
|
|
31
|
-
throw error;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// src/resources.ts
|
|
36
|
-
import { createRunFileCoordinator } from "@vimhead.dev/norn/files";
|
|
37
|
-
import { jsonValueSchema } from "@vimhead.dev/norn/schema";
|
|
38
|
-
import { mkdir as mkdir2, readFile } from "node:fs/promises";
|
|
39
|
-
import { join, resolve } from "node:path";
|
|
40
|
-
import { isDeepStrictEqual } from "node:util";
|
|
41
|
-
import { Type } from "typebox";
|
|
42
|
-
import { Value } from "typebox/value";
|
|
43
|
-
var definitionSchema = Type.Object({ name: Type.String(), kind: Type.String({ minLength: 1 }), configuration: jsonValueSchema }, { additionalProperties: false });
|
|
44
|
-
var recordSchema = Type.Object({ ...definitionSchema.properties, isInitialized: Type.Boolean() }, { additionalProperties: false });
|
|
45
|
-
var NornRunResources = class _NornRunResources {
|
|
46
|
-
constructor(runRoot) {
|
|
47
|
-
this.runRoot = runRoot;
|
|
48
|
-
this.files = createRunFileCoordinator(runRoot);
|
|
49
|
-
}
|
|
50
|
-
runRoot;
|
|
51
|
-
files;
|
|
52
|
-
entries = /* @__PURE__ */ new Map();
|
|
53
|
-
static async initialize(runRoot) {
|
|
54
|
-
const resources = new _NornRunResources(resolve(runRoot));
|
|
55
|
-
await mkdir2(join(resources.runRoot, "current", "resources"), { recursive: true });
|
|
56
|
-
return resources;
|
|
57
|
-
}
|
|
58
|
-
async ensure(definition) {
|
|
59
|
-
if (!/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/.test(definition.name)) throw new Error(`Invalid resource name: ${definition.name}`);
|
|
60
|
-
const identity = structuredClone(Value.Parse(definitionSchema, { name: definition.name, kind: definition.kind, configuration: definition.configuration }));
|
|
61
|
-
const existing = this.entries.get(definition.name);
|
|
62
|
-
if (existing) {
|
|
63
|
-
if (!isDeepStrictEqual(existing.definition, identity)) throw new Error(`Incompatible resource definition: ${definition.name}`);
|
|
64
|
-
return existing.value;
|
|
65
|
-
}
|
|
66
|
-
const value = this.initializeResource(definition, identity);
|
|
67
|
-
const entry = { definition: identity, value };
|
|
68
|
-
this.entries.set(definition.name, entry);
|
|
69
|
-
try {
|
|
70
|
-
return await value;
|
|
71
|
-
} catch (error) {
|
|
72
|
-
if (this.entries.get(definition.name) === entry) this.entries.delete(definition.name);
|
|
73
|
-
throw error;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
async initializeResource(definition, identity) {
|
|
77
|
-
const directory = join(this.runRoot, "current", "resources", definition.name);
|
|
78
|
-
await mkdir2(directory, { recursive: true });
|
|
79
|
-
return this.files.withExclusiveLock(join(directory, "definition.json"), async (path) => {
|
|
80
|
-
let stored;
|
|
81
|
-
try {
|
|
82
|
-
stored = Value.Parse(recordSchema, JSON.parse(await readFile(path, "utf8")));
|
|
83
|
-
} catch (error) {
|
|
84
|
-
if (!isNodeError(error) || error.code !== "ENOENT") throw error;
|
|
85
|
-
}
|
|
86
|
-
if (stored) {
|
|
87
|
-
const { isInitialized: _isInitialized, ...storedIdentity } = stored;
|
|
88
|
-
if (!isDeepStrictEqual(storedIdentity, identity)) throw new Error(`Incompatible resource definition: ${definition.name}`);
|
|
89
|
-
} else {
|
|
90
|
-
await writeJsonAtomically(path, { ...identity, isInitialized: false });
|
|
91
|
-
}
|
|
92
|
-
const value = await definition.initialize({ directory, files: this.files, mode: stored?.isInitialized ? "open" : "create" });
|
|
93
|
-
if (!stored?.isInitialized) await writeJsonAtomically(path, { ...identity, isInitialized: true });
|
|
94
|
-
return value;
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
export {
|
|
99
|
-
NornRunResources
|
|
100
|
-
};
|
|
File without changes
|