dataiku-sdk 0.1.1 → 0.2.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.
@@ -0,0 +1,33 @@
1
+ export interface AgentDef {
2
+ /** Display name */
3
+ name: string;
4
+ /** CLI binary name (for `which` detection) */
5
+ binary: string;
6
+ /** Config directory relative to HOME (for fallback detection) */
7
+ configDir: string;
8
+ /** Require config dir to exist even when binary is found (disambiguates shared binary names) */
9
+ configDirRequired?: boolean;
10
+ /** Skill path relative to HOME (global install) */
11
+ globalPath: (home: string) => string;
12
+ /** Skill path relative to CWD (project install). null = not supported. */
13
+ projectPath: string | null;
14
+ /** File to write inside the skill directory */
15
+ filename: string;
16
+ /** Content generator: standard SKILL.md or Cursor MDC */
17
+ content: () => string;
18
+ }
19
+ export declare const AGENTS: Record<string, AgentDef>;
20
+ export interface DetectedAgent {
21
+ id: string;
22
+ def: AgentDef;
23
+ via: "binary" | "config-dir" | "flag";
24
+ }
25
+ export declare function detectAgents(): DetectedAgent[];
26
+ export interface InstallResult {
27
+ agent: string;
28
+ path: string;
29
+ }
30
+ export declare function installSkill(agents: DetectedAgent[], opts: {
31
+ global: boolean;
32
+ cwd: string;
33
+ }): InstallResult[];
@@ -0,0 +1,229 @@
1
+ import { execFileSync, } from "node:child_process";
2
+ import { existsSync, mkdirSync, writeFileSync, } from "node:fs";
3
+ import { homedir, } from "node:os";
4
+ import { join, } from "node:path";
5
+ const SKILL_BODY = `# Dataiku DSS CLI
6
+
7
+ The \`dss\` CLI (npm: dataiku-sdk) manages Dataiku DSS resources from the terminal.
8
+
9
+ ## When to use
10
+
11
+ - Query, create, or modify DSS projects, datasets, recipes, jobs, or scenarios.
12
+ - Build datasets or run scenarios and wait for completion.
13
+ - Download or upload recipe code, dataset data, or managed folder files.
14
+ - Run SQL queries against DSS connections.
15
+ - Inspect project flows, job logs, or dataset schemas.
16
+
17
+ ## Installation
18
+
19
+ Requires [Bun](https://bun.sh) runtime.
20
+
21
+ \`\`\`bash
22
+ bun add -g dataiku-sdk # global install \u2014 provides the \`dss\` command
23
+ \`\`\`
24
+
25
+ Or run without installing:
26
+
27
+ \`\`\`bash
28
+ bunx dataiku-sdk <command> # e.g. bunx dataiku-sdk auth login
29
+ \`\`\`
30
+
31
+ ## Authentication
32
+
33
+ \`\`\`bash
34
+ dss auth login # interactive: prompts for URL, API key, project key
35
+ dss auth login --url https://dss.example.com --api-key YOUR_KEY
36
+ dss auth status # verify connection
37
+ \`\`\`
38
+
39
+ Credentials are saved to \`~/.dss/credentials.json\`. Alternatively set environment variables:
40
+
41
+ \`\`\`bash
42
+ export DATAIKU_URL=https://dss.example.com
43
+ export DATAIKU_API_KEY=your-api-key
44
+ export DATAIKU_PROJECT_KEY=MYPROJ # optional default project
45
+ \`\`\`
46
+
47
+ ## Workflows
48
+
49
+ ### Inspect a project
50
+
51
+ \`\`\`bash
52
+ dss project list # find the project key
53
+ dss dataset list --project-key MYPROJ # list its datasets
54
+ dss dataset preview orders --max-rows 10 # peek at data
55
+ dss dataset schema orders # inspect columns
56
+ \`\`\`
57
+
58
+ ### Edit recipe code
59
+
60
+ \`\`\`bash
61
+ dss recipe download-code my-recipe -o code.py # download
62
+ # ... edit code.py ...
63
+ dss recipe diff my-recipe --file code.py # review changes
64
+ dss recipe set-payload my-recipe --file code.py # upload
65
+ \`\`\`
66
+
67
+ ### Build and monitor
68
+
69
+ \`\`\`bash
70
+ dss job build-and-wait my-dataset --include-logs # build + wait + stream logs
71
+ dss job list # recent jobs
72
+ dss job log <job-id> # full log output
73
+ \`\`\`
74
+
75
+ ### Run a scenario
76
+
77
+ \`\`\`bash
78
+ dss scenario run my-scenario
79
+ dss scenario status my-scenario # check if finished
80
+ \`\`\`
81
+
82
+ ## Command reference
83
+
84
+ \`\`\`
85
+ dss <resource> <action> [args...] [--flags]
86
+
87
+ Resources: project, dataset, recipe, job, scenario, folder, notebook,
88
+ variable, code-env, connection, sql, auth, install-skill
89
+ \`\`\`
90
+
91
+ Use \`dss <resource> --help\` to see all actions and flags for any resource.
92
+
93
+ ## Key flags
94
+
95
+ \`\`\`
96
+ -f, --format FORMAT json (default) | tsv | table | quiet
97
+ -o, --output PATH write output to file instead of stdout
98
+ -v, --verbose log HTTP requests to stderr
99
+ --project-key KEY override default project for any command
100
+ --timeout MS request timeout (default: 30000)
101
+ --stdin read JSON input from stdin
102
+ \`\`\`
103
+
104
+ ## Gotchas
105
+
106
+ - **Most commands need a project key.** Set it once via \`dss auth login\` or \`DATAIKU_PROJECT_KEY\` to avoid passing \`--project-key\` on every call.
107
+ - **Output is JSON by default.** Use \`-f table\` when showing results to a user; use \`-f tsv\` when piping to scripts.
108
+ - **\`dss job build\` returns immediately.** Use \`dss job build-and-wait\` to block until the build finishes. Add \`--include-logs\` to stream log output.
109
+ - **Folder commands accept names or IDs.** If a folder name contains spaces, quote it. The CLI resolves names to IDs automatically.
110
+ - **Recipe set-payload overwrites the entire payload.** Always download first, edit, diff, then upload.
111
+ - **Transient errors exit code 3, API errors exit code 2, usage errors exit code 1.** Check exit codes to distinguish retriable failures.
112
+ `;
113
+ const SKILL_FRONTMATTER = `---
114
+ name: dataiku-dss
115
+ description: >-
116
+ Interact with Dataiku DSS from the command line \u2014 list projects, query datasets,
117
+ download and upload recipe code, build datasets, run scenarios, and manage jobs.
118
+ Use when the user wants to work with Dataiku DSS resources, inspect a DSS project,
119
+ modify recipes, trigger builds, check job logs, or run SQL against DSS connections,
120
+ even if they don't explicitly mention the dss CLI.
121
+ ---
122
+
123
+ `;
124
+ function skillContent() {
125
+ return SKILL_FRONTMATTER + SKILL_BODY;
126
+ }
127
+ export const AGENTS = {
128
+ claude: {
129
+ name: "Claude Code",
130
+ binary: "claude",
131
+ configDir: ".claude",
132
+ globalPath: (home) => join(home, ".claude", "skills", "dataiku-dss"),
133
+ projectPath: ".claude/skills/dataiku-dss",
134
+ filename: "SKILL.md",
135
+ content: skillContent,
136
+ },
137
+ codex: {
138
+ name: "Codex",
139
+ binary: "codex",
140
+ configDir: ".codex",
141
+ globalPath: (home) => join(home, ".codex", "skills", "dataiku-dss"),
142
+ projectPath: ".codex/skills/dataiku-dss",
143
+ filename: "SKILL.md",
144
+ content: skillContent,
145
+ },
146
+ cursor: {
147
+ name: "Cursor",
148
+ binary: "cursor",
149
+ configDir: ".cursor",
150
+ globalPath: (home) => join(home, ".cursor", "skills", "dataiku-dss"),
151
+ projectPath: ".cursor/skills/dataiku-dss",
152
+ filename: "SKILL.md",
153
+ content: skillContent,
154
+ },
155
+ pi: {
156
+ name: "Pi",
157
+ binary: "pi",
158
+ configDir: ".pi",
159
+ globalPath: (home) => join(home, ".pi", "agent", "skills", "dataiku-dss"),
160
+ projectPath: ".pi/skills/dataiku-dss",
161
+ filename: "SKILL.md",
162
+ content: skillContent,
163
+ },
164
+ omp: {
165
+ name: "OhMyPi",
166
+ binary: "omp",
167
+ configDir: join(".omp", "agent"),
168
+ configDirRequired: true,
169
+ globalPath: (home) => join(home, ".omp", "agent", "skills", "dataiku-dss"),
170
+ projectPath: ".omp/skills/dataiku-dss",
171
+ filename: "SKILL.md",
172
+ content: skillContent,
173
+ },
174
+ };
175
+ // ---------------------------------------------------------------------------
176
+ // Agent detection
177
+ // ---------------------------------------------------------------------------
178
+ function binaryExists(name) {
179
+ const cmd = process.platform === "win32" ? "where" : "which";
180
+ try {
181
+ execFileSync(cmd, [name,], { stdio: "pipe", });
182
+ return true;
183
+ }
184
+ catch {
185
+ return false;
186
+ }
187
+ }
188
+ export function detectAgents() {
189
+ const home = homedir();
190
+ const found = [];
191
+ for (const [id, def,] of Object.entries(AGENTS)) {
192
+ const hasBinary = binaryExists(def.binary);
193
+ const hasConfigDir = existsSync(join(home, def.configDir));
194
+ if (hasBinary && (!def.configDirRequired || hasConfigDir)) {
195
+ found.push({ id, def, via: "binary", });
196
+ }
197
+ else if (hasConfigDir) {
198
+ found.push({ id, def, via: "config-dir", });
199
+ }
200
+ }
201
+ return found;
202
+ }
203
+ export function installSkill(agents, opts) {
204
+ const home = homedir();
205
+ const results = [];
206
+ for (const { id, def, } of agents) {
207
+ let dir;
208
+ if (opts.global) {
209
+ const globalDir = def.globalPath(home);
210
+ if (!globalDir) {
211
+ process.stderr.write(` ${def.name}: skipped (no global path available)\n`);
212
+ continue;
213
+ }
214
+ dir = globalDir;
215
+ }
216
+ else {
217
+ if (!def.projectPath) {
218
+ process.stderr.write(` ${def.name}: skipped (no project path available)\n`);
219
+ continue;
220
+ }
221
+ dir = join(opts.cwd, def.projectPath);
222
+ }
223
+ mkdirSync(dir, { recursive: true, });
224
+ const filePath = join(dir, def.filename);
225
+ writeFileSync(filePath, def.content(), "utf-8");
226
+ results.push({ agent: id, path: filePath, });
227
+ }
228
+ return results;
229
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dataiku-sdk",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Dataiku DSS SDK and CLI for programmatic access to DSS REST APIs",
5
5
  "type": "module",
6
6
  "workspaces": [
@@ -298,8 +298,8 @@ export declare const JupyterNotebookSummarySchema: import("@sinclair/typebox").T
298
298
  language: import("@sinclair/typebox").TString;
299
299
  kernelSpec: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
300
300
  name: import("@sinclair/typebox").TString;
301
- display_name: import("@sinclair/typebox").TString;
302
- language: import("@sinclair/typebox").TString;
301
+ display_name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
302
+ language: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
303
303
  }>>;
304
304
  }>;
305
305
  export type JupyterNotebookSummary = Static<typeof JupyterNotebookSummarySchema>;
@@ -438,8 +438,8 @@ export declare const JupyterNotebookSummaryArraySchema: import("@sinclair/typebo
438
438
  language: import("@sinclair/typebox").TString;
439
439
  kernelSpec: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
440
440
  name: import("@sinclair/typebox").TString;
441
- display_name: import("@sinclair/typebox").TString;
442
- language: import("@sinclair/typebox").TString;
441
+ display_name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
442
+ language: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
443
443
  }>>;
444
444
  }>>;
445
445
  export declare const SqlNotebookSummaryArraySchema: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
@@ -306,8 +306,8 @@ export const JupyterNotebookSummarySchema = Type.Object({
306
306
  language: Type.String(),
307
307
  kernelSpec: Type.Optional(Type.Object({
308
308
  name: Type.String(),
309
- display_name: Type.String(),
310
- language: Type.String(),
309
+ display_name: Type.Optional(Type.String()),
310
+ language: Type.Optional(Type.String()),
311
311
  }, { additionalProperties: true, })),
312
312
  }, { additionalProperties: true, });
313
313
  export const JupyterNotebookContentSchema = Type.Object({