@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
@@ -1,164 +0,0 @@
1
- /**
2
- * New hook operation — scaffolds a new hook directory with the manifest and a
3
- * starter entrypoint.
4
- *
5
- * @experimental This API is unstable and may change without notice.
6
- */
7
- import * as FileSystem from "effect/FileSystem";
8
- import * as Path from "effect/Path";
9
- import * as Effect from "effect/Effect";
10
- import { AuthoringFailed } from "../errors.js";
11
- import { AuthoringFailureAdapter, withAdaptedStepFailures } from "../failure-adapter.js";
12
- import { createCanonicalDirectory, recoverCanonicalDirectory } from "@agentxm/extension-workspace";
13
- import { preflightCreateOnly } from "../create-preflight.js";
14
- import { decodeExtensionNameSync } from "@agentxm/extension-model/unstable/extensions";
15
- import { WorkspaceMutations } from "@agentxm/workspace-state";
16
- import { decodeVersionSync } from "@agentxm/extension-model/unstable/version-constraints";
17
- import { HOOK_EXTENSION_DIR, HOOK_MANIFEST_FILENAME, HOOK_MANIFEST_SCHEMA_URL, } from "@agentxm/extension-model/unstable/hooks/manifest-schema";
18
- // -----------------------------------------------------------------------------
19
- // Helpers
20
- // -----------------------------------------------------------------------------
21
- const INITIAL_HOOK_VERSION = decodeVersionSync("0.1.0");
22
- const entrypointFilename = (runtime) => {
23
- switch (runtime) {
24
- case "bash":
25
- return "hook.sh";
26
- case "node":
27
- return "hook.js";
28
- case "python":
29
- return "hook.py";
30
- }
31
- };
32
- const matcherForBinding = (event, matcher) => event === "tool.pre" || event === "tool.post" ? matcher : undefined;
33
- const makeEntrypoint = (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
- // -----------------------------------------------------------------------------
82
- // Public API
83
- // -----------------------------------------------------------------------------
84
- /**
85
- * New-hook operation handler.
86
- *
87
- * 1. Compute managed extension directory path
88
- * 2. Check if the hook already exists (directory or settings entry)
89
- * 3. Create the managed extension + src directories
90
- * 4. Write hook.json manifest
91
- * 5. Write starter entrypoint in src/
92
- */
93
- export const newHook = (op) => Effect.gen(function* () {
94
- const fs = yield* FileSystem.FileSystem;
95
- const path = yield* Path.Path;
96
- const ws = yield* WorkspaceMutations;
97
- const base = ws.baseDir;
98
- if (ws.layout.scope !== "project") {
99
- return yield* new AuthoringFailed({
100
- category: "validation",
101
- detail: "New hooks can only be scaffolded in a project workspace",
102
- });
103
- }
104
- const { name, owner, runtime, event, matcher } = op.args;
105
- const fqn = `${owner}/${HOOK_EXTENSION_DIR}/${name}`;
106
- const configuredHooks = yield* ws.getConfiguredHookEntries();
107
- const canonicalPath = path.join(ws.layout.authoredRoot("hook"), name);
108
- yield* recoverCanonicalDirectory({ baseDir: base, canonicalPath });
109
- yield* preflightCreateOnly({
110
- subject: "Hook",
111
- name,
112
- configured: Object.hasOwn(configuredHooks, name),
113
- destinations: [canonicalPath],
114
- });
115
- const entrypointFile = entrypointFilename(runtime);
116
- const bindingMatcher = matcherForBinding(event, matcher);
117
- const manifest = {
118
- $schema: HOOK_MANIFEST_SCHEMA_URL,
119
- owner,
120
- type: "hook",
121
- name: decodeExtensionNameSync(name),
122
- version: INITIAL_HOOK_VERSION,
123
- runtime,
124
- entrypoint: `src/${entrypointFile}`,
125
- bindings: [
126
- bindingMatcher === undefined ? { on: event } : { on: event, matcherRaw: bindingMatcher },
127
- ],
128
- };
129
- yield* createCanonicalDirectory({
130
- baseDir: base,
131
- canonicalPath,
132
- subject: "Hook",
133
- requiredFiles: [HOOK_MANIFEST_FILENAME, `src/${entrypointFile}`],
134
- populate: (stagingPath) => {
135
- const srcDir = path.join(stagingPath, "src");
136
- return Effect.gen(function* () {
137
- yield* fs.makeDirectory(srcDir, { recursive: true }).pipe(Effect.mapError((e) => new AuthoringFailed({
138
- category: "validation",
139
- detail: `Failed to create hook directory: ${srcDir}`,
140
- cause: e,
141
- })));
142
- yield* fs
143
- .writeFileString(path.join(stagingPath, HOOK_MANIFEST_FILENAME), JSON.stringify(manifest, null, 2) + "\n")
144
- .pipe(Effect.mapError((e) => new AuthoringFailed({
145
- category: "validation",
146
- detail: "Hook manifest could not be written",
147
- cause: e,
148
- })));
149
- yield* fs
150
- .writeFileString(path.join(srcDir, entrypointFile), makeEntrypoint(runtime, fqn))
151
- .pipe(Effect.mapError((e) => new AuthoringFailed({
152
- category: "validation",
153
- detail: `Failed to write ${entrypointFile}`,
154
- cause: e,
155
- })));
156
- });
157
- },
158
- });
159
- return {
160
- result: "success",
161
- message: `Created hook ${fqn}`,
162
- };
163
- }).pipe(withAdaptedStepFailures);
164
- //# sourceMappingURL=new-hook.js.map
@@ -1,37 +0,0 @@
1
- /**
2
- * New pack operation — scaffolds a new pack directory with manifest.
3
- *
4
- * @experimental This API is unstable and may change without notice.
5
- */
6
- import * as FileSystem from "effect/FileSystem";
7
- import * as Path from "effect/Path";
8
- import { AuthoringFailureAdapter } from "../failure-adapter.js";
9
- import type { Handle } from "@agentxm/extension-model/unstable/extensions/handle";
10
- import type { OperationHandler } from "@agentxm/workspace-operations";
11
- import type { Operation } from "@agentxm/workspace-operations";
12
- import { WorkspaceMutations } from "@agentxm/workspace-state";
13
- /**
14
- * Args for the new pack operation.
15
- */
16
- export interface NewPackOperationArgs {
17
- /** Pack name (without owner). */
18
- readonly name: string;
19
- /** Profile (e.g., "@myorg"). */
20
- readonly owner: Handle;
21
- }
22
- /**
23
- * Scaffold a new pack in the workspace.
24
- *
25
- * @experimental This API is unstable and may change without notice.
26
- */
27
- export type NewPackOperation = Operation<"new-pack", NewPackOperationArgs>;
28
- /**
29
- * New pack operation handler.
30
- *
31
- * 1. Compute pack directory path
32
- * 2. Check if pack manifest already exists
33
- * 3. Create pack directory
34
- * 4. Write pack.json manifest
35
- */
36
- export declare const newPack: OperationHandler<NewPackOperation, FileSystem.FileSystem | Path.Path | WorkspaceMutations | AuthoringFailureAdapter>;
37
- //# sourceMappingURL=new-pack.d.ts.map
@@ -1,90 +0,0 @@
1
- /**
2
- * New pack operation — scaffolds a new pack directory with manifest.
3
- *
4
- * @experimental This API is unstable and may change without notice.
5
- */
6
- import * as FileSystem from "effect/FileSystem";
7
- import * as Path from "effect/Path";
8
- import * as Effect from "effect/Effect";
9
- import { AuthoringFailed } from "../errors.js";
10
- import { AuthoringFailureAdapter, withAdaptedStepFailures } from "../failure-adapter.js";
11
- import { createCanonicalDirectory, recoverCanonicalDirectory } from "@agentxm/extension-workspace";
12
- import { preflightCreateOnly } from "../create-preflight.js";
13
- import { decodeExtensionNameSync, formatFqn } from "@agentxm/extension-model/unstable/extensions";
14
- import { PACK_MANIFEST_FILENAME, PACK_MANIFEST_SCHEMA_URL, } from "@agentxm/extension-model/unstable/packs/manifest-schema";
15
- import { WorkspaceMutations } from "@agentxm/workspace-state";
16
- import { decodeVersionSync } from "@agentxm/extension-model/unstable/version-constraints";
17
- // -----------------------------------------------------------------------------
18
- // Public API
19
- // -----------------------------------------------------------------------------
20
- /**
21
- * New pack operation handler.
22
- *
23
- * 1. Compute pack directory path
24
- * 2. Check if pack manifest already exists
25
- * 3. Create pack directory
26
- * 4. Write pack.json manifest
27
- */
28
- export const newPack = (op) => Effect.gen(function* () {
29
- const fs = yield* FileSystem.FileSystem;
30
- const path = yield* Path.Path;
31
- const ws = yield* WorkspaceMutations;
32
- const base = ws.baseDir;
33
- if (ws.layout.scope !== "project") {
34
- return yield* new AuthoringFailed({
35
- category: "validation",
36
- detail: "New packs can only be scaffolded in a project workspace",
37
- });
38
- }
39
- const initialVersion = decodeVersionSync("0.0.1");
40
- const { name, owner } = op.args;
41
- const extensionName = decodeExtensionNameSync(name);
42
- const fqn = formatFqn({ owner, type: "pack", name: extensionName });
43
- // 1. Compute pack directory path
44
- const canonicalPath = path.join(ws.layout.authoredRoot("pack"), name);
45
- const configuredPacks = yield* ws.getConfiguredPackEntries();
46
- yield* recoverCanonicalDirectory({
47
- baseDir: base,
48
- canonicalPath,
49
- });
50
- yield* preflightCreateOnly({
51
- subject: "Pack",
52
- name,
53
- configured: Object.hasOwn(configuredPacks, name),
54
- destinations: [canonicalPath],
55
- });
56
- const manifest = {
57
- $schema: PACK_MANIFEST_SCHEMA_URL,
58
- owner,
59
- type: "pack",
60
- name: extensionName,
61
- version: initialVersion,
62
- dependencies: {},
63
- };
64
- yield* createCanonicalDirectory({
65
- baseDir: base,
66
- canonicalPath,
67
- subject: "Pack",
68
- requiredFiles: [PACK_MANIFEST_FILENAME],
69
- populate: (stagingPath) => {
70
- const manifestPath = path.join(stagingPath, PACK_MANIFEST_FILENAME);
71
- return Effect.gen(function* () {
72
- yield* fs.makeDirectory(stagingPath, { recursive: true }).pipe(Effect.mapError((e) => new AuthoringFailed({
73
- category: "internal",
74
- detail: `Failed to create pack directory: ${stagingPath}`,
75
- cause: e,
76
- })));
77
- yield* fs.writeFileString(manifestPath, JSON.stringify(manifest, null, 2) + "\n").pipe(Effect.mapError((e) => new AuthoringFailed({
78
- category: "internal",
79
- detail: `Failed to write pack manifest: ${manifestPath}`,
80
- cause: e,
81
- })));
82
- });
83
- },
84
- });
85
- return {
86
- result: "success",
87
- message: `Created pack ${fqn}`,
88
- };
89
- }).pipe(withAdaptedStepFailures);
90
- //# sourceMappingURL=new-pack.js.map
@@ -1,38 +0,0 @@
1
- /**
2
- * New skill operation — scaffolds a new skill directory with manifest and SKILL.md.
3
- *
4
- * @experimental This API is unstable and may change without notice.
5
- */
6
- import * as FileSystem from "effect/FileSystem";
7
- import * as Path from "effect/Path";
8
- import { AuthoringFailureAdapter } from "../failure-adapter.js";
9
- import type { Handle } from "@agentxm/extension-model/unstable/extensions/handle";
10
- import type { OperationHandler } from "@agentxm/workspace-operations";
11
- import type { Operation } from "@agentxm/workspace-operations";
12
- import { WorkspaceMutations } from "@agentxm/workspace-state";
13
- /**
14
- * Args for the new-skill operation.
15
- */
16
- export interface NewSkillOperationArgs {
17
- /** Skill name (validated, lowercase with hyphens). */
18
- readonly name: string;
19
- /** Profile (e.g., "@myorg"). */
20
- readonly owner: Handle;
21
- }
22
- /**
23
- * Scaffold a new skill in the workspace.
24
- *
25
- * @experimental This API is unstable and may change without notice.
26
- */
27
- export type NewSkillOperation = Operation<"new-skill", NewSkillOperationArgs>;
28
- /**
29
- * New-skill operation handler.
30
- *
31
- * 1. Compute paths from the resolved workspace layout
32
- * 2. Check if skill already exists in settings
33
- * 3. Create skill directory (src/)
34
- * 4. Write skill.json manifest
35
- * 5. Write starter SKILL.md
36
- */
37
- export declare const newSkill: OperationHandler<NewSkillOperation, FileSystem.FileSystem | Path.Path | WorkspaceMutations | AuthoringFailureAdapter>;
38
- //# sourceMappingURL=new-skill.d.ts.map
@@ -1,102 +0,0 @@
1
- /**
2
- * New skill operation — scaffolds a new skill directory with manifest and SKILL.md.
3
- *
4
- * @experimental This API is unstable and may change without notice.
5
- */
6
- import * as FileSystem from "effect/FileSystem";
7
- import * as Path from "effect/Path";
8
- import * as Effect from "effect/Effect";
9
- import { AuthoringFailed } from "../errors.js";
10
- import { AuthoringFailureAdapter, withAdaptedStepFailures } from "../failure-adapter.js";
11
- import { createCanonicalDirectory, recoverCanonicalDirectory } from "@agentxm/extension-workspace";
12
- import { preflightCreateOnly } from "../create-preflight.js";
13
- import { decodeExtensionNameSync } from "@agentxm/extension-model/unstable/extensions";
14
- import { WorkspaceMutations } from "@agentxm/workspace-state";
15
- import { MANIFEST_FILENAME, MANIFEST_SCHEMA_URL, } from "@agentxm/extension-model/unstable/skills/manifest-schema";
16
- import { decodeVersionSync } from "@agentxm/extension-model/unstable/version-constraints";
17
- // -----------------------------------------------------------------------------
18
- // Helpers
19
- // -----------------------------------------------------------------------------
20
- const makeSkillMd = (name) => `---
21
- name: ${name}
22
- description: Describe when this skill should be triggered by the agent
23
- ---
24
-
25
- Describe what this skill does and when to use it.
26
- `;
27
- const INITIAL_SKILL_VERSION = decodeVersionSync("0.0.1");
28
- // -----------------------------------------------------------------------------
29
- // Public API
30
- // -----------------------------------------------------------------------------
31
- /**
32
- * New-skill operation handler.
33
- *
34
- * 1. Compute paths from the resolved workspace layout
35
- * 2. Check if skill already exists in settings
36
- * 3. Create skill directory (src/)
37
- * 4. Write skill.json manifest
38
- * 5. Write starter SKILL.md
39
- */
40
- export const newSkill = (op) => Effect.gen(function* () {
41
- const fs = yield* FileSystem.FileSystem;
42
- const path = yield* Path.Path;
43
- const ws = yield* WorkspaceMutations;
44
- const base = ws.baseDir;
45
- if (ws.layout.scope !== "project") {
46
- return yield* new AuthoringFailed({
47
- category: "validation",
48
- detail: "New skills can only be scaffolded in a project workspace",
49
- });
50
- }
51
- const { name, owner } = op.args;
52
- const fqn = `${owner}/skills/${name}`;
53
- const configuredSkills = yield* ws.getConfiguredSkillEntries();
54
- const canonicalPath = path.join(ws.layout.authoredRoot("skill"), name);
55
- yield* recoverCanonicalDirectory({ baseDir: base, canonicalPath });
56
- yield* preflightCreateOnly({
57
- subject: "Skill",
58
- name,
59
- configured: Object.hasOwn(configuredSkills, name),
60
- destinations: [canonicalPath],
61
- });
62
- const manifest = {
63
- $schema: MANIFEST_SCHEMA_URL,
64
- owner,
65
- type: "skill",
66
- name: decodeExtensionNameSync(name),
67
- version: INITIAL_SKILL_VERSION,
68
- };
69
- yield* createCanonicalDirectory({
70
- baseDir: base,
71
- canonicalPath,
72
- subject: "Skill",
73
- requiredFiles: [MANIFEST_FILENAME, "src/SKILL.md"],
74
- populate: (stagingPath) => {
75
- const skillSrcPath = path.join(stagingPath, "src");
76
- return Effect.gen(function* () {
77
- yield* fs.makeDirectory(skillSrcPath, { recursive: true }).pipe(Effect.mapError((e) => new AuthoringFailed({
78
- category: "validation",
79
- detail: `Failed to create skill directory: ${skillSrcPath}`,
80
- cause: e,
81
- })));
82
- yield* fs
83
- .writeFileString(path.join(stagingPath, MANIFEST_FILENAME), JSON.stringify(manifest, null, 2) + "\n")
84
- .pipe(Effect.mapError((e) => new AuthoringFailed({
85
- category: "validation",
86
- detail: "Skill manifest could not be written",
87
- cause: e,
88
- })));
89
- yield* fs.writeFileString(path.join(skillSrcPath, "SKILL.md"), makeSkillMd(name)).pipe(Effect.mapError((e) => new AuthoringFailed({
90
- category: "validation",
91
- detail: "Failed to write SKILL.md",
92
- cause: e,
93
- })));
94
- });
95
- },
96
- });
97
- return {
98
- result: "success",
99
- message: `Created skill ${fqn}`,
100
- };
101
- }).pipe(withAdaptedStepFailures);
102
- //# sourceMappingURL=new-skill.js.map