@agentxm/extension-authoring 0.28.11 → 0.28.13

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 (75) hide show
  1. package/dist/src/adopt/adopt-extension.d.ts +71 -0
  2. package/dist/src/adopt/adopt-extension.js +174 -0
  3. package/dist/src/authored-declaration.d.ts +49 -0
  4. package/dist/src/authored-declaration.js +86 -0
  5. package/dist/src/authored-package-errors.d.ts +91 -0
  6. package/dist/src/authored-package-errors.js +36 -0
  7. package/dist/src/create/authoring-owner.d.ts +54 -0
  8. package/dist/src/create/authoring-owner.js +93 -0
  9. package/dist/src/create/create-extension.d.ts +127 -0
  10. package/dist/src/create/create-extension.js +440 -0
  11. package/dist/src/create/errors.d.ts +59 -0
  12. package/dist/src/create/errors.js +54 -0
  13. package/dist/src/create/scaffold-name.d.ts +15 -0
  14. package/dist/src/create/scaffold-name.js +16 -0
  15. package/dist/src/create/scaffolds/hook.d.ts +19 -0
  16. package/dist/src/create/scaffolds/hook.js +118 -0
  17. package/dist/src/create/scaffolds/knowledge.d.ts +14 -0
  18. package/dist/src/create/scaffolds/knowledge.js +45 -0
  19. package/dist/src/create/scaffolds/mcp-server.d.ts +17 -0
  20. package/dist/src/create/scaffolds/mcp-server.js +57 -0
  21. package/dist/src/create/scaffolds/pack.d.ts +13 -0
  22. package/dist/src/create/scaffolds/pack.js +37 -0
  23. package/dist/src/create/scaffolds/rule.d.ts +14 -0
  24. package/dist/src/create/scaffolds/rule.js +46 -0
  25. package/dist/src/create/scaffolds/scaffold.d.ts +51 -0
  26. package/dist/src/create/scaffolds/scaffold.js +45 -0
  27. package/dist/src/create/scaffolds/skill.d.ts +12 -0
  28. package/dist/src/create/scaffolds/skill.js +47 -0
  29. package/dist/src/create/scaffolds/subagent.d.ts +12 -0
  30. package/dist/src/create/scaffolds/subagent.js +47 -0
  31. package/dist/src/create-preflight.d.ts +3 -2
  32. package/dist/src/create-preflight.js +2 -1
  33. package/dist/src/errors.d.ts +1 -1
  34. package/dist/src/errors.js +1 -1
  35. package/dist/src/fork/fork-extension.d.ts +87 -0
  36. package/dist/src/fork/fork-extension.js +253 -0
  37. package/dist/src/fork-package.d.ts +2 -2
  38. package/dist/src/fork-package.js +4 -4
  39. package/dist/src/import/import-native-extension.d.ts +119 -0
  40. package/dist/src/import/import-native-extension.js +310 -0
  41. package/dist/src/import-native-package.d.ts +2 -2
  42. package/dist/src/import-native-package.js +4 -4
  43. package/dist/src/index.d.ts +20 -11
  44. package/dist/src/index.js +26 -13
  45. package/dist/src/packs/add-to-pack.d.ts +2 -2
  46. package/dist/src/packs/add-to-pack.js +4 -3
  47. package/dist/src/packs/change-pack-membership.d.ts +56 -0
  48. package/dist/src/packs/change-pack-membership.js +246 -0
  49. package/dist/src/packs/configured-pack-selector.d.ts +24 -0
  50. package/dist/src/packs/configured-pack-selector.js +53 -0
  51. package/dist/src/packs/glob.d.ts +14 -0
  52. package/dist/src/packs/glob.js +44 -0
  53. package/dist/src/packs/membership-errors.d.ts +122 -0
  54. package/dist/src/packs/membership-errors.js +47 -0
  55. package/dist/src/packs/remove-from-pack.d.ts +2 -2
  56. package/dist/src/packs/remove-from-pack.js +4 -3
  57. package/dist/src/step-failure.d.ts +31 -0
  58. package/dist/src/step-failure.js +253 -0
  59. package/dist/src/testing.d.ts +68 -0
  60. package/dist/src/testing.js +135 -0
  61. package/dist/src/version/change-authored-version.d.ts +73 -0
  62. package/dist/src/version/change-authored-version.js +224 -0
  63. package/dist/src/version/errors.d.ts +65 -0
  64. package/dist/src/version/errors.js +73 -0
  65. package/package.json +23 -8
  66. package/dist/src/desired-identity.d.ts +0 -19
  67. package/dist/src/desired-identity.js +0 -26
  68. package/dist/src/failure-adapter.d.ts +0 -31
  69. package/dist/src/failure-adapter.js +0 -23
  70. package/dist/src/hooks/new-hook.d.ts +0 -46
  71. package/dist/src/hooks/new-hook.js +0 -164
  72. package/dist/src/packs/new-pack.d.ts +0 -37
  73. package/dist/src/packs/new-pack.js +0 -90
  74. package/dist/src/skills/new-skill.d.ts +0 -38
  75. package/dist/src/skills/new-skill.js +0 -102
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Typed refusals the authoring request phase can settle with.
3
+ *
4
+ * Each one carries the facts a person needs to recover — the owners they
5
+ * could have meant, the settings file that records ownership, the name rule
6
+ * their name broke — and none of them carries rendered prose. The
7
+ * application boundary owns the sentence; the feature owns the decision.
8
+ *
9
+ * @experimental This API is unstable and may change without notice.
10
+ */
11
+ import * as Schema from "effect/Schema";
12
+ /**
13
+ * No owner is configured for the selected workspace and none was named, so
14
+ * the package has no authorship to carry. `candidates` are the owners the
15
+ * person could plausibly have meant, most local first; it may be empty.
16
+ */
17
+ export class AuthoringOwnerRequired extends Schema.TaggedError()("AuthoringOwnerRequired", {
18
+ /** The thing being authored, e.g. `skill`. */
19
+ subject: Schema.String,
20
+ /** The command route, so a recovery action is a runnable command. */
21
+ command: Schema.String,
22
+ /** The name the person asked to create. */
23
+ name: Schema.String,
24
+ /** Owners the person could have meant, most local first. */
25
+ candidates: Schema.Array(Schema.String),
26
+ /** Workspace-relative settings file that would record the owner. */
27
+ settingsPath: Schema.String,
28
+ }) {
29
+ }
30
+ /** An explicitly named owner disagrees with the one the workspace records. */
31
+ export class AuthoringOwnerMismatch extends Schema.TaggedError()("AuthoringOwnerMismatch", {
32
+ requested: Schema.String,
33
+ configured: Schema.String,
34
+ }) {
35
+ }
36
+ /** The requested name is not a name an authored package can carry. */
37
+ export class ScaffoldNameInvalid extends Schema.TaggedError()("ScaffoldNameInvalid", {
38
+ subject: Schema.String,
39
+ name: Schema.String,
40
+ /** The pattern source every authored name matches. */
41
+ pattern: Schema.String,
42
+ maxLength: Schema.Number,
43
+ }) {
44
+ }
45
+ /**
46
+ * Authoring was requested in a workspace scope that does not hold authored
47
+ * packages. Only the project workspace does.
48
+ */
49
+ export class AuthoringScopeUnsupported extends Schema.TaggedError()("AuthoringScopeUnsupported", {
50
+ subject: Schema.String,
51
+ scope: Schema.String,
52
+ }) {
53
+ }
54
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The name and owner vocabulary every authored package is created under.
3
+ *
4
+ * One pattern, one length bound, one owner normalization for all seven
5
+ * extension types: the name an author types becomes a directory name, a
6
+ * settings key, and a Registry package name, so a type that accepted a
7
+ * different shape would author packages the rest of the system cannot name.
8
+ *
9
+ * @experimental This API is unstable and may change without notice.
10
+ */
11
+ export declare const SCAFFOLD_NAME_PATTERN: RegExp;
12
+ export declare const SCAFFOLD_NAME_MAX_LENGTH = 64;
13
+ export declare const isValidScaffoldName: (name: string) => boolean;
14
+ export declare const normalizeScaffoldOwner: (owner: string) => string & import("effect/Brand").Brand<"Handle">;
15
+ //# sourceMappingURL=scaffold-name.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The name and owner vocabulary every authored package is created under.
3
+ *
4
+ * One pattern, one length bound, one owner normalization for all seven
5
+ * extension types: the name an author types becomes a directory name, a
6
+ * settings key, and a Registry package name, so a type that accepted a
7
+ * different shape would author packages the rest of the system cannot name.
8
+ *
9
+ * @experimental This API is unstable and may change without notice.
10
+ */
11
+ import { normalizeHandle } from "@agentxm/extension-model/unstable/extensions";
12
+ export const SCAFFOLD_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
13
+ export const SCAFFOLD_NAME_MAX_LENGTH = 64;
14
+ export const isValidScaffoldName = (name) => name.length > 0 && name.length <= SCAFFOLD_NAME_MAX_LENGTH && SCAFFOLD_NAME_PATTERN.test(name);
15
+ export const normalizeScaffoldOwner = (owner) => normalizeHandle(owner.startsWith("@") ? owner : `@${owner}`);
16
+ //# sourceMappingURL=scaffold-name.js.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The starter content a new hook is created with, including the matcher a
3
+ * tool-scoped binding defaults to.
4
+ *
5
+ * @experimental This API is unstable and may change without notice.
6
+ */
7
+ import * as Option from "effect/Option";
8
+ import type { Handle } from "@agentxm/extension-model/unstable/extensions/handle";
9
+ import { type HookEvent, type HookRuntime } from "@agentxm/extension-model/unstable/hooks/manifest-schema";
10
+ import { type AuthoredScaffold } from "./scaffold.js";
11
+ export declare const hookEntrypointFilename: (runtime: HookRuntime) => string;
12
+ export declare const hookScaffold: (args: {
13
+ readonly name: string;
14
+ readonly owner: Handle;
15
+ readonly runtime: HookRuntime;
16
+ readonly event: HookEvent;
17
+ readonly matcher: Option.Option<string>;
18
+ }) => AuthoredScaffold;
19
+ //# sourceMappingURL=hook.d.ts.map
@@ -0,0 +1,118 @@
1
+ /**
2
+ * The starter content a new hook is created with, including the matcher a
3
+ * tool-scoped binding defaults to.
4
+ *
5
+ * @experimental This API is unstable and may change without notice.
6
+ */
7
+ import * as Effect from "effect/Effect";
8
+ import * as Option from "effect/Option";
9
+ import * as Path from "effect/Path";
10
+ import { decodeExtensionNameSync } from "@agentxm/extension-model/unstable/extensions";
11
+ import { HOOK_EXTENSION_DIR, HOOK_MANIFEST_FILENAME, HOOK_MANIFEST_SCHEMA_URL, } from "@agentxm/extension-model/unstable/hooks/manifest-schema";
12
+ import { decodeVersionSync } from "@agentxm/extension-model/unstable/version-constraints";
13
+ import { manifestText, stageFileAt } from "./scaffold.js";
14
+ const INITIAL_VERSION = decodeVersionSync("0.1.0");
15
+ /**
16
+ * Tool events fire on every tool call, so a scaffold that bound them without
17
+ * a matcher would run the new hook against unrelated tools from its first
18
+ * invocation. The two write tools are the ones an author almost always means.
19
+ */
20
+ const DEFAULT_TOOL_MATCHER = "Write|Edit";
21
+ /** Only tool-scoped events carry a matcher; the rest ignore one if given. */
22
+ const isToolEvent = (event) => event === "tool.pre" || event === "tool.post";
23
+ export const hookEntrypointFilename = (runtime) => {
24
+ switch (runtime) {
25
+ case "bash":
26
+ return "hook.sh";
27
+ case "node":
28
+ return "hook.js";
29
+ case "python":
30
+ return "hook.py";
31
+ }
32
+ };
33
+ const entrypointBody = (runtime, fqn) => {
34
+ switch (runtime) {
35
+ case "bash":
36
+ return `#!/usr/bin/env bash
37
+ # ${fqn}
38
+ # Receives the agent hook event payload as JSON on stdin.
39
+ set -euo pipefail
40
+
41
+ payload="$(cat)"
42
+
43
+ # TODO: inspect "$payload" and implement the hook.
44
+ # Emit JSON on stdout or exit non-zero to influence the agent.
45
+ exit 0
46
+ `;
47
+ case "node":
48
+ return `#!/usr/bin/env node
49
+ // ${fqn}
50
+ // Receives the agent hook event payload as JSON on stdin.
51
+ let raw = "";
52
+ process.stdin.on("data", (chunk) => {
53
+ raw += chunk;
54
+ });
55
+ process.stdin.on("end", () => {
56
+ const payload = raw ? JSON.parse(raw) : {};
57
+
58
+ // TODO: inspect payload and implement the hook.
59
+ // Emit JSON on stdout or exit non-zero to influence the agent.
60
+ process.exit(0);
61
+ });
62
+ `;
63
+ case "python":
64
+ return `#!/usr/bin/env python3
65
+ """${fqn}
66
+
67
+ Receives the agent hook event payload as JSON on stdin.
68
+ """
69
+ import json
70
+ import sys
71
+
72
+ raw = sys.stdin.read()
73
+ payload = json.loads(raw) if raw else {}
74
+
75
+ # TODO: inspect payload and implement the hook.
76
+ # Emit JSON on stdout or exit non-zero to influence the agent.
77
+ sys.exit(0)
78
+ `;
79
+ }
80
+ };
81
+ export const hookScaffold = (args) => {
82
+ const entrypointFile = hookEntrypointFilename(args.runtime);
83
+ const entrypoint = `src/${entrypointFile}`;
84
+ const matcher = isToolEvent(args.event)
85
+ ? Option.getOrElse(args.matcher, () => DEFAULT_TOOL_MATCHER)
86
+ : undefined;
87
+ const fqn = `${args.owner}/${HOOK_EXTENSION_DIR}/${args.name}`;
88
+ const manifest = {
89
+ $schema: HOOK_MANIFEST_SCHEMA_URL,
90
+ owner: args.owner,
91
+ type: "hook",
92
+ name: decodeExtensionNameSync(args.name),
93
+ version: INITIAL_VERSION,
94
+ runtime: args.runtime,
95
+ entrypoint,
96
+ bindings: [
97
+ matcher === undefined ? { on: args.event } : { on: args.event, matcherRaw: matcher },
98
+ ],
99
+ };
100
+ return {
101
+ subject: "Hook",
102
+ version: INITIAL_VERSION,
103
+ contentFiles: [HOOK_MANIFEST_FILENAME, entrypoint],
104
+ entryFile: entrypoint,
105
+ populate: (stagingPath) => Effect.gen(function* () {
106
+ const path = yield* Path.Path;
107
+ yield* stageFileAt({
108
+ path: path.join(stagingPath, HOOK_MANIFEST_FILENAME),
109
+ contents: manifestText(manifest),
110
+ });
111
+ yield* stageFileAt({
112
+ path: path.join(stagingPath, "src", entrypointFile),
113
+ contents: entrypointBody(args.runtime, fqn),
114
+ });
115
+ }),
116
+ };
117
+ };
118
+ //# sourceMappingURL=hook.js.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The starter content a new Knowledge bundle is created with.
3
+ *
4
+ * @experimental This API is unstable and may change without notice.
5
+ */
6
+ import * as Option from "effect/Option";
7
+ import type { Handle } from "@agentxm/extension-model/unstable/extensions/handle";
8
+ import { type AuthoredScaffold } from "./scaffold.js";
9
+ export declare const knowledgeScaffold: (args: {
10
+ readonly name: string;
11
+ readonly owner: Handle;
12
+ readonly description: Option.Option<string>;
13
+ }) => AuthoredScaffold;
14
+ //# sourceMappingURL=knowledge.d.ts.map
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The starter content a new Knowledge bundle is created with.
3
+ *
4
+ * @experimental This API is unstable and may change without notice.
5
+ */
6
+ import * as Effect from "effect/Effect";
7
+ import * as Option from "effect/Option";
8
+ import * as Path from "effect/Path";
9
+ import { decodeExtensionNameSync } from "@agentxm/extension-model/unstable/extensions";
10
+ import { KNOWLEDGE_MANIFEST_FILENAME, KNOWLEDGE_MANIFEST_SCHEMA_URL, KNOWLEDGE_SOURCE_DIR, } from "@agentxm/extension-model/unstable/knowledge";
11
+ import { decodeVersionSync } from "@agentxm/extension-model/unstable/version-constraints";
12
+ import { manifestText, stageFileAt } from "./scaffold.js";
13
+ const BUNDLE_INDEX = `${KNOWLEDGE_SOURCE_DIR}/index.md`;
14
+ const INITIAL_VERSION = decodeVersionSync("0.1.0");
15
+ export const knowledgeScaffold = (args) => {
16
+ const name = decodeExtensionNameSync(args.name);
17
+ const manifest = {
18
+ $schema: KNOWLEDGE_MANIFEST_SCHEMA_URL,
19
+ owner: args.owner,
20
+ name,
21
+ version: INITIAL_VERSION,
22
+ type: "knowledge",
23
+ format: { name: "okf", version: "0.2" },
24
+ bundleRoot: KNOWLEDGE_SOURCE_DIR,
25
+ ...(Option.isSome(args.description) ? { description: args.description.value } : {}),
26
+ };
27
+ return {
28
+ subject: "Knowledge bundle",
29
+ version: INITIAL_VERSION,
30
+ contentFiles: [KNOWLEDGE_MANIFEST_FILENAME, BUNDLE_INDEX],
31
+ entryFile: BUNDLE_INDEX,
32
+ populate: (stagingPath) => Effect.gen(function* () {
33
+ const path = yield* Path.Path;
34
+ yield* stageFileAt({
35
+ path: path.join(stagingPath, KNOWLEDGE_MANIFEST_FILENAME),
36
+ contents: manifestText(manifest),
37
+ });
38
+ yield* stageFileAt({
39
+ path: path.join(stagingPath, KNOWLEDGE_SOURCE_DIR, "index.md"),
40
+ contents: `---\nokf_version: "0.2"\n---\n# ${name}\n\n<!-- Discovery map: describe this bundle's scope, then group and annotate links to its concepts. -->\n`,
41
+ });
42
+ }),
43
+ };
44
+ };
45
+ //# sourceMappingURL=knowledge.js.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The starter manifest a new MCP server is created with.
3
+ *
4
+ * The scaffold declares a placeholder npm stdio package under an example
5
+ * reverse-DNS server name: a new server has no published artifact yet, and
6
+ * the author replaces both before publishing.
7
+ *
8
+ * @experimental This API is unstable and may change without notice.
9
+ */
10
+ import type { Handle } from "@agentxm/extension-model/unstable/extensions/handle";
11
+ import { type AuthoredScaffold } from "./scaffold.js";
12
+ export declare const mcpServerScaffold: (args: {
13
+ readonly name: string;
14
+ readonly owner: Handle;
15
+ readonly description: string;
16
+ }) => AuthoredScaffold;
17
+ //# sourceMappingURL=mcp-server.d.ts.map
@@ -0,0 +1,57 @@
1
+ /**
2
+ * The starter manifest a new MCP server is created with.
3
+ *
4
+ * The scaffold declares a placeholder npm stdio package under an example
5
+ * reverse-DNS server name: a new server has no published artifact yet, and
6
+ * the author replaces both before publishing.
7
+ *
8
+ * @experimental This API is unstable and may change without notice.
9
+ */
10
+ import * as Effect from "effect/Effect";
11
+ import * as Path from "effect/Path";
12
+ import { decodeExtensionNameSync } from "@agentxm/extension-model/unstable/extensions";
13
+ import { MCP_SERVER_MANIFEST_FILENAME, MCP_SERVER_MANIFEST_SCHEMA_URL, MCP_SERVER_REGISTRY_SERVER_SCHEMA_URL, } from "@agentxm/extension-model/unstable/mcps/manifest-schema";
14
+ import { decodeVersionSync } from "@agentxm/extension-model/unstable/version-constraints";
15
+ import { manifestText, stageFileAt } from "./scaffold.js";
16
+ const INITIAL_VERSION = decodeVersionSync("0.1.0");
17
+ const PLACEHOLDER_SERVER_NAMESPACE = "io.github.example";
18
+ export const mcpServerScaffold = (args) => {
19
+ const description = args.description || `MCP server ${args.name}`;
20
+ const manifest = {
21
+ $schema: MCP_SERVER_MANIFEST_SCHEMA_URL,
22
+ owner: args.owner,
23
+ type: "mcp-server",
24
+ name: decodeExtensionNameSync(args.name),
25
+ version: INITIAL_VERSION,
26
+ description,
27
+ license: "MIT",
28
+ server: {
29
+ $schema: MCP_SERVER_REGISTRY_SERVER_SCHEMA_URL,
30
+ name: `${PLACEHOLDER_SERVER_NAMESPACE}/${args.name}`,
31
+ description,
32
+ version: INITIAL_VERSION,
33
+ packages: [
34
+ {
35
+ registryType: "npm",
36
+ identifier: args.name,
37
+ version: INITIAL_VERSION,
38
+ transport: { type: "stdio" },
39
+ },
40
+ ],
41
+ },
42
+ };
43
+ return {
44
+ subject: "MCP server",
45
+ version: INITIAL_VERSION,
46
+ contentFiles: [MCP_SERVER_MANIFEST_FILENAME],
47
+ entryFile: MCP_SERVER_MANIFEST_FILENAME,
48
+ populate: (stagingPath) => Effect.gen(function* () {
49
+ const path = yield* Path.Path;
50
+ yield* stageFileAt({
51
+ path: path.join(stagingPath, MCP_SERVER_MANIFEST_FILENAME),
52
+ contents: manifestText(manifest),
53
+ });
54
+ }),
55
+ };
56
+ };
57
+ //# sourceMappingURL=mcp-server.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The starter manifest a new pack is created with: an empty membership the
3
+ * author fills with `axm packs add`.
4
+ *
5
+ * @experimental This API is unstable and may change without notice.
6
+ */
7
+ import type { Handle } from "@agentxm/extension-model/unstable/extensions/handle";
8
+ import { type AuthoredScaffold } from "./scaffold.js";
9
+ export declare const packScaffold: (args: {
10
+ readonly name: string;
11
+ readonly owner: Handle;
12
+ }) => AuthoredScaffold;
13
+ //# sourceMappingURL=pack.d.ts.map
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The starter manifest a new pack is created with: an empty membership the
3
+ * author fills with `axm packs add`.
4
+ *
5
+ * @experimental This API is unstable and may change without notice.
6
+ */
7
+ import * as Effect from "effect/Effect";
8
+ import * as Path from "effect/Path";
9
+ import { decodeExtensionNameSync } from "@agentxm/extension-model/unstable/extensions";
10
+ import { PACK_MANIFEST_FILENAME, PACK_MANIFEST_SCHEMA_URL, } from "@agentxm/extension-model/unstable/packs/manifest-schema";
11
+ import { decodeVersionSync } from "@agentxm/extension-model/unstable/version-constraints";
12
+ import { manifestText, stageFileAt } from "./scaffold.js";
13
+ const INITIAL_VERSION = decodeVersionSync("0.0.1");
14
+ export const packScaffold = (args) => {
15
+ const manifest = {
16
+ $schema: PACK_MANIFEST_SCHEMA_URL,
17
+ owner: args.owner,
18
+ type: "pack",
19
+ name: decodeExtensionNameSync(args.name),
20
+ version: INITIAL_VERSION,
21
+ dependencies: {},
22
+ };
23
+ return {
24
+ subject: "Pack",
25
+ version: INITIAL_VERSION,
26
+ contentFiles: [PACK_MANIFEST_FILENAME],
27
+ entryFile: PACK_MANIFEST_FILENAME,
28
+ populate: (stagingPath) => Effect.gen(function* () {
29
+ const path = yield* Path.Path;
30
+ yield* stageFileAt({
31
+ path: path.join(stagingPath, PACK_MANIFEST_FILENAME),
32
+ contents: manifestText(manifest),
33
+ });
34
+ }),
35
+ };
36
+ };
37
+ //# sourceMappingURL=pack.js.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The starter content a new rule is created with.
3
+ *
4
+ * @experimental This API is unstable and may change without notice.
5
+ */
6
+ import * as Option from "effect/Option";
7
+ import type { Handle } from "@agentxm/extension-model/unstable/extensions/handle";
8
+ import { type AuthoredScaffold } from "./scaffold.js";
9
+ export declare const ruleScaffold: (args: {
10
+ readonly name: string;
11
+ readonly owner: Handle;
12
+ readonly title: Option.Option<string>;
13
+ }) => AuthoredScaffold;
14
+ //# sourceMappingURL=rule.d.ts.map
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The starter content a new rule is created with.
3
+ *
4
+ * @experimental This API is unstable and may change without notice.
5
+ */
6
+ import * as Effect from "effect/Effect";
7
+ import * as Option from "effect/Option";
8
+ import * as Path from "effect/Path";
9
+ import { decodeExtensionNameSync } from "@agentxm/extension-model/unstable/extensions";
10
+ import { RULE_BODY_FILENAME, RULE_MANIFEST_FILENAME, RULE_MANIFEST_SCHEMA_URL, } from "@agentxm/extension-model/unstable/rules/manifest-schema";
11
+ import { decodeVersionSync } from "@agentxm/extension-model/unstable/version-constraints";
12
+ import { manifestText, stageFileAt } from "./scaffold.js";
13
+ /** Rule bodies live under `src/` alongside every other package-body type. */
14
+ const RULE_SOURCE_DIR = "src";
15
+ const RULE_BODY = `${RULE_SOURCE_DIR}/${RULE_BODY_FILENAME}`;
16
+ const INITIAL_VERSION = decodeVersionSync("0.1.0");
17
+ export const ruleScaffold = (args) => {
18
+ const name = decodeExtensionNameSync(args.name);
19
+ const title = Option.getOrElse(args.title, () => String(name));
20
+ const manifest = {
21
+ $schema: RULE_MANIFEST_SCHEMA_URL,
22
+ owner: args.owner,
23
+ name,
24
+ version: INITIAL_VERSION,
25
+ type: "rule",
26
+ title,
27
+ };
28
+ return {
29
+ subject: "Rule",
30
+ version: INITIAL_VERSION,
31
+ contentFiles: [RULE_MANIFEST_FILENAME, RULE_BODY],
32
+ entryFile: RULE_BODY,
33
+ populate: (stagingPath) => Effect.gen(function* () {
34
+ const path = yield* Path.Path;
35
+ yield* stageFileAt({
36
+ path: path.join(stagingPath, RULE_MANIFEST_FILENAME),
37
+ contents: manifestText(manifest),
38
+ });
39
+ yield* stageFileAt({
40
+ path: path.join(stagingPath, RULE_SOURCE_DIR, RULE_BODY_FILENAME),
41
+ contents: `# ${title}\n\nDescribe the behavior this rule asks agents to follow.\n`,
42
+ });
43
+ }),
44
+ };
45
+ };
46
+ //# sourceMappingURL=rule.js.map
@@ -0,0 +1,51 @@
1
+ /**
2
+ * What a scaffold for one extension type contributes to a creation.
3
+ *
4
+ * Everything that differs between the seven types — the manifest, the starter
5
+ * body, the file the author edits next, the initial version — is decided
6
+ * here; everything they share — ownership, naming, the canonical location,
7
+ * the create-only preflight, desired state, projection, the transaction — is
8
+ * decided once by the create use case.
9
+ *
10
+ * @experimental This API is unstable and may change without notice.
11
+ */
12
+ import * as Effect from "effect/Effect";
13
+ import * as FileSystem from "effect/FileSystem";
14
+ import * as Path from "effect/Path";
15
+ import type { Version } from "@agentxm/extension-model/unstable/version-constraints";
16
+ import { AuthoringFailed } from "../../errors.js";
17
+ /** One extension type's contribution to a creation. */
18
+ export interface AuthoredScaffold {
19
+ /** Sentence-cased subject used in refusals, e.g. `Knowledge bundle`. */
20
+ readonly subject: string;
21
+ /** Version the scaffolded manifest carries. */
22
+ readonly version: Version;
23
+ /**
24
+ * Package-relative files the scaffold writes, in the order a plan lists
25
+ * them. They are also the files the canonical staging requires before the
26
+ * package is swapped into place.
27
+ */
28
+ readonly contentFiles: ReadonlyArray<string>;
29
+ /** Package-relative file the author edits next. */
30
+ readonly entryFile: string;
31
+ /** Write the package body into a staging directory. */
32
+ readonly populate: (stagingPath: string) => Effect.Effect<void, AuthoringFailed, FileSystem.FileSystem | Path.Path>;
33
+ }
34
+ /** Serialize a manifest the way every authored manifest is written. */
35
+ export declare const manifestText: (manifest: unknown) => string;
36
+ /**
37
+ * Create a directory inside the staging tree, reporting the failure as an
38
+ * authoring failure rather than a raw platform error.
39
+ */
40
+ export declare const stageDirectory: (directory: string) => Effect.Effect<void, AuthoringFailed, FileSystem.FileSystem>;
41
+ /** Write one staged file, naming the file in the failure. */
42
+ export declare const stageFile: (args: {
43
+ readonly path: string;
44
+ readonly contents: string;
45
+ }) => Effect.Effect<void, AuthoringFailed, FileSystem.FileSystem>;
46
+ /** Stage a file and every directory above it inside the staging tree. */
47
+ export declare const stageFileAt: (args: {
48
+ readonly path: string;
49
+ readonly contents: string;
50
+ }) => Effect.Effect<void, AuthoringFailed, FileSystem.FileSystem | Path.Path>;
51
+ //# sourceMappingURL=scaffold.d.ts.map
@@ -0,0 +1,45 @@
1
+ /**
2
+ * What a scaffold for one extension type contributes to a creation.
3
+ *
4
+ * Everything that differs between the seven types — the manifest, the starter
5
+ * body, the file the author edits next, the initial version — is decided
6
+ * here; everything they share — ownership, naming, the canonical location,
7
+ * the create-only preflight, desired state, projection, the transaction — is
8
+ * decided once by the create use case.
9
+ *
10
+ * @experimental This API is unstable and may change without notice.
11
+ */
12
+ import * as Effect from "effect/Effect";
13
+ import * as FileSystem from "effect/FileSystem";
14
+ import * as Path from "effect/Path";
15
+ import { AuthoringFailed } from "../../errors.js";
16
+ /** Serialize a manifest the way every authored manifest is written. */
17
+ export const manifestText = (manifest) => `${JSON.stringify(manifest, null, 2)}\n`;
18
+ /**
19
+ * Create a directory inside the staging tree, reporting the failure as an
20
+ * authoring failure rather than a raw platform error.
21
+ */
22
+ export const stageDirectory = (directory) => Effect.gen(function* () {
23
+ const fs = yield* FileSystem.FileSystem;
24
+ yield* fs.makeDirectory(directory, { recursive: true }).pipe(Effect.mapError((cause) => new AuthoringFailed({
25
+ category: "internal",
26
+ detail: `Failed to create the staged directory ${directory}`,
27
+ cause,
28
+ })));
29
+ });
30
+ /** Write one staged file, naming the file in the failure. */
31
+ export const stageFile = (args) => Effect.gen(function* () {
32
+ const fs = yield* FileSystem.FileSystem;
33
+ yield* fs.writeFileString(args.path, args.contents).pipe(Effect.mapError((cause) => new AuthoringFailed({
34
+ category: "internal",
35
+ detail: `Failed to write the staged file ${args.path}`,
36
+ cause,
37
+ })));
38
+ });
39
+ /** Stage a file and every directory above it inside the staging tree. */
40
+ export const stageFileAt = (args) => Effect.gen(function* () {
41
+ const path = yield* Path.Path;
42
+ yield* stageDirectory(path.dirname(args.path));
43
+ yield* stageFile(args);
44
+ });
45
+ //# sourceMappingURL=scaffold.js.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The starter content a new skill is created with.
3
+ *
4
+ * @experimental This API is unstable and may change without notice.
5
+ */
6
+ import type { Handle } from "@agentxm/extension-model/unstable/extensions/handle";
7
+ import { type AuthoredScaffold } from "./scaffold.js";
8
+ export declare const skillScaffold: (args: {
9
+ readonly name: string;
10
+ readonly owner: Handle;
11
+ }) => AuthoredScaffold;
12
+ //# sourceMappingURL=skill.d.ts.map
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The starter content a new skill is created with.
3
+ *
4
+ * @experimental This API is unstable and may change without notice.
5
+ */
6
+ import * as Effect from "effect/Effect";
7
+ import * as Path from "effect/Path";
8
+ import { decodeExtensionNameSync } from "@agentxm/extension-model/unstable/extensions";
9
+ import { MANIFEST_FILENAME, MANIFEST_SCHEMA_URL, } from "@agentxm/extension-model/unstable/skills/manifest-schema";
10
+ import { decodeVersionSync } from "@agentxm/extension-model/unstable/version-constraints";
11
+ import { manifestText, stageFileAt } from "./scaffold.js";
12
+ const SKILL_BODY = "src/SKILL.md";
13
+ const INITIAL_VERSION = decodeVersionSync("0.0.1");
14
+ const skillBody = (name) => `---
15
+ name: ${name}
16
+ description: Describe when this skill should be triggered by the agent
17
+ ---
18
+
19
+ Describe what this skill does and when to use it.
20
+ `;
21
+ export const skillScaffold = (args) => {
22
+ const manifest = {
23
+ $schema: MANIFEST_SCHEMA_URL,
24
+ owner: args.owner,
25
+ type: "skill",
26
+ name: decodeExtensionNameSync(args.name),
27
+ version: INITIAL_VERSION,
28
+ };
29
+ return {
30
+ subject: "Skill",
31
+ version: INITIAL_VERSION,
32
+ contentFiles: [MANIFEST_FILENAME, SKILL_BODY],
33
+ entryFile: SKILL_BODY,
34
+ populate: (stagingPath) => Effect.gen(function* () {
35
+ const path = yield* Path.Path;
36
+ yield* stageFileAt({
37
+ path: path.join(stagingPath, MANIFEST_FILENAME),
38
+ contents: manifestText(manifest),
39
+ });
40
+ yield* stageFileAt({
41
+ path: path.join(stagingPath, ...SKILL_BODY.split("/")),
42
+ contents: skillBody(args.name),
43
+ });
44
+ }),
45
+ };
46
+ };
47
+ //# sourceMappingURL=skill.js.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The starter content a new subagent is created with.
3
+ *
4
+ * @experimental This API is unstable and may change without notice.
5
+ */
6
+ import type { Handle } from "@agentxm/extension-model/unstable/extensions/handle";
7
+ import { type AuthoredScaffold } from "./scaffold.js";
8
+ export declare const subagentScaffold: (args: {
9
+ readonly name: string;
10
+ readonly owner: Handle;
11
+ }) => AuthoredScaffold;
12
+ //# sourceMappingURL=subagent.d.ts.map