@tagma/sdk 0.5.2 → 0.6.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.
@@ -1,3 +0,0 @@
1
- import type { DriverPlugin } from '../types';
2
- export declare const ClaudeCodeDriver: DriverPlugin;
3
- //# sourceMappingURL=claude-code.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"claude-code.d.ts","sourceRoot":"","sources":["../../src/drivers/claude-code.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EAQb,MAAM,UAAU,CAAC;AAmIlB,eAAO,MAAM,gBAAgB,EAAE,YA2G9B,CAAC"}
@@ -1,225 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { isAbsolute, relative, dirname, join } from 'node:path';
3
- // Claude Code CLI reference: https://code.claude.com/docs/en/cli-reference
4
- const DEFAULT_MODEL = 'sonnet';
5
- // Claude Code CLI accepts --effort low|medium|high|max. tagma's vocabulary
6
- // is low|medium|high, so low/medium/high pass through unchanged; users who
7
- // want the claude-specific "max" tier can also set it explicitly.
8
- const VALID_EFFORT = new Set(['low', 'medium', 'high', 'max']);
9
- function resolveModel() {
10
- return DEFAULT_MODEL;
11
- }
12
- function resolveTools(permissions) {
13
- const tools = ['Grep', 'Glob'];
14
- if (permissions.read)
15
- tools.push('Read');
16
- if (permissions.write)
17
- tools.push('Edit', 'Write');
18
- if (permissions.execute)
19
- tools.push('Bash');
20
- return tools.join(',');
21
- }
22
- // Maps our Permissions to Claude Code's --permission-mode. In print (-p) mode
23
- // Claude needs non-interactive permission handling:
24
- // - `bypassPermissions` skips all checks (required for reliable Bash automation
25
- // under `execute: true`, matches the "full trust" semantics of that tier).
26
- // - `dontAsk` auto-denies anything outside `--allowedTools`, which is exactly
27
- // what we want for read/write tiers: the allowedTools whitelist already
28
- // enumerates what Claude may do, and dontAsk makes violations fail fast
29
- // instead of hanging on a prompt no one can answer in headless mode.
30
- // See: https://code.claude.com/docs/en/permission-modes
31
- function resolvePermissionMode(permissions) {
32
- if (permissions.execute)
33
- return 'bypassPermissions';
34
- return 'dontAsk';
35
- }
36
- // Returns true if `sub` is inside `root` (or equal to it).
37
- function isInside(root, sub) {
38
- const rel = relative(root, sub);
39
- return rel === '' || (!rel.startsWith('..') && !isAbsolute(rel));
40
- }
41
- // Claude Code requires CLAUDE_CODE_GIT_BASH_PATH on Windows pointing to
42
- // Git Bash (bin\bash.exe under a Git for Windows install). See:
43
- // https://code.claude.com/docs/en/troubleshooting#windows-claude-code-on-windows-requires-git-bash
44
- // The path must use native Windows backslashes — forward slashes are rejected
45
- // by Claude Code's path validation.
46
- function resolveGitBashEnv() {
47
- if (process.platform !== 'win32')
48
- return {};
49
- // Respect user-provided value if it points to an actual file. If the user
50
- // set it to a non-existent path, fall through to discovery rather than
51
- // propagating the broken config.
52
- const existing = process.env.CLAUDE_CODE_GIT_BASH_PATH;
53
- if (existing && existsSync(existing))
54
- return {};
55
- const discovered = discoverGitBash();
56
- return discovered ? { CLAUDE_CODE_GIT_BASH_PATH: discovered } : {};
57
- }
58
- function discoverGitBash() {
59
- // Strategy 1: find git.exe in PATH (equivalent to `where.exe git`) and
60
- // walk up looking for bin\bash.exe under a Git install root. Git for
61
- // Windows may expose multiple git.exe locations (cmd\git.exe,
62
- // mingw64\bin\git.exe, mingw64\libexec\git-core\git.exe), so we walk up
63
- // several levels rather than assuming a fixed depth.
64
- const gitExe = findExeInPath('git.exe');
65
- if (gitExe) {
66
- let dir = dirname(gitExe);
67
- for (let depth = 0; depth < 5; depth++) {
68
- const candidate = join(dir, 'bin', 'bash.exe');
69
- if (existsSync(candidate))
70
- return candidate;
71
- const parent = dirname(dir);
72
- if (parent === dir)
73
- break;
74
- dir = parent;
75
- }
76
- }
77
- // Strategy 2: check common Git for Windows install locations.
78
- // Uses %ProgramFiles%/%LOCALAPPDATA%/%USERPROFILE% env vars so it works on
79
- // systems where those aren't mapped to C:\ (e.g. localized Windows).
80
- const programFiles = process.env['ProgramFiles'] ?? 'C:\\Program Files';
81
- const programFilesX86 = process.env['ProgramFiles(x86)'] ?? 'C:\\Program Files (x86)';
82
- const localAppData = process.env['LOCALAPPDATA'];
83
- const userProfile = process.env['USERPROFILE'];
84
- const candidates = [
85
- join(programFiles, 'Git', 'bin', 'bash.exe'),
86
- join(programFilesX86, 'Git', 'bin', 'bash.exe'),
87
- // Git for Windows user-level install
88
- localAppData && join(localAppData, 'Programs', 'Git', 'bin', 'bash.exe'),
89
- // Scoop
90
- userProfile && join(userProfile, 'scoop', 'apps', 'git', 'current', 'bin', 'bash.exe'),
91
- // Chocolatey default
92
- 'C:\\tools\\git\\bin\\bash.exe',
93
- ].filter((p) => Boolean(p));
94
- for (const c of candidates) {
95
- if (existsSync(c))
96
- return c;
97
- }
98
- // Strategy 3: scan PATH for any entry containing "git" (e.g. Git's
99
- // mingw64/bin or usr/bin already in PATH), walk up to find bash.exe.
100
- // Catches custom install locations.
101
- const pathEntries = (process.env.PATH ?? '').split(';');
102
- for (const entry of pathEntries) {
103
- if (!/git/i.test(entry))
104
- continue;
105
- const normalized = entry.replace(/\//g, '\\').replace(/\\+$/, '');
106
- const parts = normalized.split('\\');
107
- for (let depth = 1; depth <= 4; depth++) {
108
- const root = parts.slice(0, parts.length - depth).join('\\');
109
- if (!root)
110
- continue;
111
- const candidate = root + '\\bin\\bash.exe';
112
- if (existsSync(candidate))
113
- return candidate;
114
- }
115
- }
116
- return null;
117
- }
118
- function findExeInPath(exe) {
119
- const pathDirs = (process.env.PATH ?? '').split(';');
120
- for (const dir of pathDirs) {
121
- if (!dir)
122
- continue;
123
- const full = join(dir, exe);
124
- if (existsSync(full))
125
- return full;
126
- }
127
- return null;
128
- }
129
- export const ClaudeCodeDriver = {
130
- name: 'claude-code',
131
- capabilities: {
132
- sessionResume: true,
133
- systemPrompt: true,
134
- outputFormat: true,
135
- },
136
- resolveModel,
137
- resolveTools,
138
- async buildCommand(task, track, ctx) {
139
- const permissions = task.permissions ?? track.permissions;
140
- const model = task.model ?? track.model ?? DEFAULT_MODEL;
141
- // SDK schema layer already resolved task → track → pipeline inheritance.
142
- // Drop unknown effort values so a typo can't break `claude -p` startup;
143
- // validateRaw / the UI should prevent this from reaching us in practice.
144
- const rawEffort = task.reasoning_effort ?? track.reasoning_effort;
145
- const effort = rawEffort && VALID_EFFORT.has(rawEffort) ? rawEffort : null;
146
- const tools = resolveTools(permissions);
147
- const permissionMode = resolvePermissionMode(permissions);
148
- // Pass the prompt via stdin instead of as a -p argument value. On Windows,
149
- // multi-line strings in CLI arguments break cmd.exe argument parsing when
150
- // the executable is a .cmd wrapper — newlines cause all subsequent flags
151
- // (--output-format, --model, etc.) to be silently dropped.
152
- const stdin = task.prompt;
153
- const args = [
154
- 'claude',
155
- '-p', // no value — prompt is piped via stdin
156
- '--model',
157
- model,
158
- '--allowedTools',
159
- tools,
160
- '--permission-mode',
161
- permissionMode,
162
- '--output-format',
163
- 'json',
164
- // NOTE: do NOT use --verbose here. It changes stdout from a single JSON
165
- // result object to a JSON event-stream array, breaking parseResult's
166
- // session_id extraction (needed for continue_from) and normalizedOutput.
167
- // The engine already captures stdout/stderr for pipeline logs.
168
- // Pin to project+local settings only; don't inherit arbitrary user-level
169
- // config (hooks, MCP servers, etc.) into pipeline automation.
170
- '--setting-sources',
171
- 'project,local',
172
- ];
173
- if (effort) {
174
- args.push('--effort', effort);
175
- }
176
- // If the task runs in a subdirectory of the project, grant read/edit
177
- // access to the project root via --add-dir so Claude can still see
178
- // shared files (configs, types, etc.) outside task.cwd.
179
- const effectiveCwd = task.cwd ?? ctx.workDir;
180
- if (effectiveCwd !== ctx.workDir && isInside(ctx.workDir, effectiveCwd)) {
181
- args.push('--add-dir', ctx.workDir);
182
- }
183
- // Native session resume
184
- if (task.continue_from) {
185
- const sessionId = ctx.sessionMap.get(task.continue_from);
186
- if (sessionId) {
187
- args.push('--resume', sessionId);
188
- }
189
- }
190
- // --append-system-prompt MUST be last: its value may contain newlines,
191
- // and on Windows cmd.exe can silently drop any flags that follow a
192
- // newline-containing argument.
193
- const profile = task.agent_profile ?? track.agent_profile;
194
- if (profile) {
195
- args.push('--append-system-prompt', profile);
196
- }
197
- return { args, cwd: effectiveCwd, env: resolveGitBashEnv(), stdin };
198
- },
199
- parseResult(stdout) {
200
- try {
201
- let json = JSON.parse(stdout);
202
- // --verbose produces a JSON array of events; extract the final "result"
203
- // event so session_id and normalizedOutput are correctly populated.
204
- if (Array.isArray(json)) {
205
- const resultEvent = json.findLast((e) => e.type === 'result');
206
- if (!resultEvent)
207
- return { normalizedOutput: stdout };
208
- json = resultEvent;
209
- }
210
- // Extract canonical text: strip JSON envelope so downstream drivers
211
- // get the actual AI response, not metadata
212
- const normalizedOutput = json.result ?? json.text ?? json.content ?? stdout;
213
- return {
214
- sessionId: json.session_id,
215
- normalizedOutput: typeof normalizedOutput === 'string'
216
- ? normalizedOutput
217
- : JSON.stringify(normalizedOutput),
218
- };
219
- }
220
- catch {
221
- return { normalizedOutput: stdout };
222
- }
223
- },
224
- };
225
- //# sourceMappingURL=claude-code.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"claude-code.js","sourceRoot":"","sources":["../../src/drivers/claude-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAYhE,2EAA2E;AAE3E,MAAM,aAAa,GAAG,QAAQ,CAAC;AAE/B,2EAA2E;AAC3E,2EAA2E;AAC3E,kEAAkE;AAClE,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAE/D,SAAS,YAAY;IACnB,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,SAAS,YAAY,CAAC,WAAwB;IAC5C,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,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AK,CAAC,aAAa,CAAC;QAC1D,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,iBAAiB,EAAE,EAAE,KAAK,EAAE,CAAC;IACtE,CAAC;IAED,WAAW,CAAC,MAAc;QACxB,IAAI,CAAC;YACH,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAE9B,wEAAwE;YACxE,oEAAoE;YACpE,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxB,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAA0B,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;gBACvF,IAAI,CAAC,WAAW;oBAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC;gBACtD,IAAI,GAAG,WAAW,CAAC;YACrB,CAAC;YAED,oEAAoE;YACpE,2CAA2C;YAC3C,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC;YAC5E,OAAO;gBACL,SAAS,EAAE,IAAI,CAAC,UAAU;gBAC1B,gBAAgB,EACd,OAAO,gBAAgB,KAAK,QAAQ;oBAClC,CAAC,CAAC,gBAAgB;oBAClB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC;aACvC,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC;QACtC,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -1,20 +0,0 @@
1
- import type { TemplateConfig } from './types';
2
- export interface TemplateManifest extends TemplateConfig {
3
- /** The package ref as it would appear in `task.use`, e.g. `@tagma/template-review`. */
4
- readonly ref: string;
5
- }
6
- /**
7
- * Scan the workspace's `node_modules/@tagma/*` for packages whose name starts
8
- * with `template-` and load each one's manifest. Packages without a valid
9
- * `template.yaml` (or that fail to parse) are silently skipped.
10
- *
11
- * Returns an empty array when `workDir` doesn't exist or has no such packages.
12
- */
13
- export declare function discoverTemplates(workDir: string): TemplateManifest[];
14
- /**
15
- * Load a single template's manifest by its ref (e.g. `@tagma/template-review`)
16
- * from the given workspace's `node_modules`. Returns `null` if the package
17
- * isn't installed or its manifest can't be parsed.
18
- */
19
- export declare function loadTemplateManifest(ref: string, workDir: string): TemplateManifest | null;
20
- //# sourceMappingURL=templates.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD,uFAAuF;IACvF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,EAAE,CA8BrE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAO1F"}
package/dist/templates.js DELETED
@@ -1,93 +0,0 @@
1
- // ═══ Template Discovery (F1) ═══
2
- //
3
- // Public helpers so editors / UIs can enumerate installed `@tagma/template-*`
4
- // packages in a workspace and read each template's declarative metadata
5
- // (name, description, params) without actually expanding the template.
6
- //
7
- // The legacy private `loadTemplate` in schema.ts uses Bun-specific APIs
8
- // (Bun.file, require.resolve). These helpers are Node-compatible because
9
- // the editor server runs on Node, not Bun.
10
- import { readFileSync, existsSync, readdirSync, statSync } from 'fs';
11
- import { join } from 'path';
12
- import yaml from 'js-yaml';
13
- /**
14
- * Scan the workspace's `node_modules/@tagma/*` for packages whose name starts
15
- * with `template-` and load each one's manifest. Packages without a valid
16
- * `template.yaml` (or that fail to parse) are silently skipped.
17
- *
18
- * Returns an empty array when `workDir` doesn't exist or has no such packages.
19
- */
20
- export function discoverTemplates(workDir) {
21
- const out = [];
22
- const scopeDir = join(workDir, 'node_modules', '@tagma');
23
- if (!existsSync(scopeDir))
24
- return out;
25
- let entries = [];
26
- try {
27
- entries = readdirSync(scopeDir);
28
- }
29
- catch {
30
- return out;
31
- }
32
- for (const entry of entries) {
33
- if (!entry.startsWith('template-'))
34
- continue;
35
- const pkgDir = join(scopeDir, entry);
36
- try {
37
- const st = statSync(pkgDir);
38
- if (!st.isDirectory())
39
- continue;
40
- }
41
- catch {
42
- continue;
43
- }
44
- const ref = `@tagma/${entry}`;
45
- const manifest = loadTemplateManifestFromDir(pkgDir, ref);
46
- if (manifest)
47
- out.push(manifest);
48
- }
49
- // Sort alphabetically for deterministic UI rendering.
50
- out.sort((a, b) => a.ref.localeCompare(b.ref));
51
- return out;
52
- }
53
- /**
54
- * Load a single template's manifest by its ref (e.g. `@tagma/template-review`)
55
- * from the given workspace's `node_modules`. Returns `null` if the package
56
- * isn't installed or its manifest can't be parsed.
57
- */
58
- export function loadTemplateManifest(ref, workDir) {
59
- // Only @tagma/template-* refs are supported (matches SDK validateTemplateRef).
60
- const stripped = ref.replace(/@v\d+$/, '');
61
- if (!stripped.startsWith('@tagma/template-'))
62
- return null;
63
- const pkgDir = join(workDir, 'node_modules', stripped);
64
- if (!existsSync(pkgDir))
65
- return null;
66
- return loadTemplateManifestFromDir(pkgDir, stripped);
67
- }
68
- /**
69
- * Resolve a template manifest from an absolute package directory. Tries
70
- * `template.yaml` first (the documented convention), then a `template` export
71
- * from `package.json`'s `main`. Returns `null` on any failure so discovery
72
- * stays robust against malformed packages.
73
- */
74
- function loadTemplateManifestFromDir(pkgDir, ref) {
75
- const yamlPath = join(pkgDir, 'template.yaml');
76
- if (existsSync(yamlPath)) {
77
- try {
78
- const content = readFileSync(yamlPath, 'utf-8');
79
- const doc = yaml.load(content);
80
- const tpl = (doc && typeof doc === 'object' && 'template' in doc
81
- ? doc.template
82
- : doc);
83
- if (tpl && typeof tpl === 'object' && tpl.name && Array.isArray(tpl.tasks)) {
84
- return { ...tpl, ref };
85
- }
86
- }
87
- catch {
88
- return null;
89
- }
90
- }
91
- return null;
92
- }
93
- //# sourceMappingURL=templates.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,EAAE;AACF,8EAA8E;AAC9E,wEAAwE;AACxE,uEAAuE;AACvE,EAAE;AACF,wEAAwE;AACxE,yEAAyE;AACzE,2CAA2C;AAE3C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,IAAI,MAAM,SAAS,CAAC;AAQ3B;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,MAAM,GAAG,GAAuB,EAAE,CAAC;IACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;IACzD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,GAAG,CAAC;IAEtC,IAAI,OAAO,GAAa,EAAE,CAAC;IAC3B,IAAI,CAAC;QACH,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC;IACb,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC;YAAE,SAAS;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,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