farseer-cli 1.21.0 → 1.23.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.
- package/README.md +3 -1
- package/dist/commands/code.js +23 -0
- package/dist/commands/code.js.map +2 -2
- package/dist/commands/skills.js +110 -7
- package/dist/commands/skills.js.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/tools/dashboardTools.js +1 -1
- package/dist/pipeline/create.js +1 -1
- package/dist/pipeline/generated-reference.json +6 -6
- package/dist/services/codefirst/workflow.js +3 -3
- package/dist/services/codefirst/workflow.js.map +1 -1
- package/dist/services/farseerService.js +10 -1
- package/dist/services/farseerService.js.map +1 -1
- package/dist/services/httpError.js +2 -1
- package/dist/services/httpError.js.map +1 -1
- package/dist/skills/install.js +221 -8
- package/dist/skills/install.js.map +2 -2
- package/dist/skills/userSkills.js +206 -0
- package/dist/skills/userSkills.js.map +6 -0
- package/dist/skills/workspaceSkills.js +213 -0
- package/dist/skills/workspaceSkills.js.map +6 -0
- package/docs/cli-guide.md +6 -1
- package/docs/pipeline-reference.md +1 -1
- package/package.json +1 -1
- package/skills/farseer-app-dev/SKILL.md +2 -2
- package/skills/farseer-app-dev/assignments.md +1 -1
- package/skills/farseer-app-dev/farseer-client-release-notes.md +13 -1
- package/skills/farseer-app-dev/working-patterns.md +30 -5
- package/skills/farseer-author-import-job/SKILL.md +20 -3
- package/skills/farseer-author-import-job/cell-writes.md +26 -6
- package/skills/farseer-author-import-job/deploying-a-farseer-app.md +117 -12
- package/skills/farseer-author-import-job/import-job-pattern.md +111 -13
- package/skills/farseer-build-model/SKILL.md +3 -2
- package/skills/farseer-build-model/formula-grain-alignment.md +186 -31
- package/skills/farseer-build-model/naming-conventions.md +5 -2
- package/skills/farseer-build-model/sparse-formulas-pattern.md +30 -11
- package/skills/farseer-build-pipeline/SKILL.md +36 -1
- package/skills/farseer-build-pipeline/erp-sales/README.md +8 -0
- package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/main.py +1 -1
- package/skills/farseer-build-pipeline/erp-sales/erp-sales-load/main.py +1 -1
- package/skills/farseer-build-pipeline/pipeline-app-failure-report-pattern.md +9 -6
- package/skills/farseer-data-permissions/SKILL.md +85 -0
- package/skills/farseer-modify-model/SKILL.md +3 -2
- package/skills/farseer-modify-model/model-validation-pattern.md +11 -3
- package/skills/farseer-review-model/SKILL.md +39 -8
- package/skills/pipeline-authoring/SKILL.md +3 -3
- package/skills/pipeline-authoring/practices.md +5 -3
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var userSkills_exports = {};
|
|
20
|
+
__export(userSkills_exports, {
|
|
21
|
+
checkUserSkill: () => checkUserSkill,
|
|
22
|
+
describeProblem: () => describeProblem,
|
|
23
|
+
readPublishFolder: () => readPublishFolder,
|
|
24
|
+
sameSkill: () => sameSkill,
|
|
25
|
+
skillFields: () => skillFields,
|
|
26
|
+
sorted: () => sorted,
|
|
27
|
+
userSkillName: () => userSkillName
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(userSkills_exports);
|
|
30
|
+
var import_fs = require("fs");
|
|
31
|
+
var import_path = require("path");
|
|
32
|
+
var import_bundled = require("./bundled");
|
|
33
|
+
const { load } = require("js-yaml");
|
|
34
|
+
const HEADER_KEYS = ["name", "description"];
|
|
35
|
+
const COMMAND_FENCE = /(?:`{3}|~{3})\s*!/;
|
|
36
|
+
const COMMANDS = "An agent runs !`\u2026` and a ```! block as a command when the skill loads. Write the command as text.";
|
|
37
|
+
const CONTROL = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u2028\u2029]/;
|
|
38
|
+
function reservedBecause(name, reserved) {
|
|
39
|
+
if (name.startsWith(reserved.prefix)) return `Names starting with ${reserved.prefix} are Farseer's.`;
|
|
40
|
+
if ((0, import_bundled.bundledSkillNames)().includes(name)) return `"${name}" is a Farseer skill name.`;
|
|
41
|
+
if (reserved.names.includes(name)) return `"${name}" is a reserved name.`;
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
function checkUserSkill(text, reserved) {
|
|
45
|
+
const lines = text.split(/\r?\n/);
|
|
46
|
+
const problems = [];
|
|
47
|
+
lines.forEach((line, index) => {
|
|
48
|
+
if (line.includes("!`") || COMMAND_FENCE.test(line))
|
|
49
|
+
problems.push({ rule: "no-commands", line: index + 1, message: COMMANDS });
|
|
50
|
+
});
|
|
51
|
+
const header = readHeader(lines);
|
|
52
|
+
if ("problem" in header) return sorted([...problems, header.problem]);
|
|
53
|
+
const { fields, end } = header;
|
|
54
|
+
const keyLine = (key) => headerLine(lines, end, key);
|
|
55
|
+
for (const key of Object.keys(fields).filter((key2) => !HEADER_KEYS.includes(key2)))
|
|
56
|
+
problems.push({
|
|
57
|
+
rule: "header-keys",
|
|
58
|
+
line: keyLine(key),
|
|
59
|
+
message: `The header holds only name and description; remove ${key}.`
|
|
60
|
+
});
|
|
61
|
+
const { name } = fields;
|
|
62
|
+
const taken = typeof name === "string" && reserved ? reservedBecause(name, reserved) : void 0;
|
|
63
|
+
if (typeof name !== "string" || !(0, import_bundled.isSkillName)(name))
|
|
64
|
+
problems.push({
|
|
65
|
+
rule: "name",
|
|
66
|
+
line: keyLine("name"),
|
|
67
|
+
message: "The name is lowercase letters and digits in words joined by single hyphens, at most 64 characters."
|
|
68
|
+
});
|
|
69
|
+
else if (taken)
|
|
70
|
+
problems.push({ rule: "reserved-name", line: keyLine("name"), message: `${taken} Choose another name.` });
|
|
71
|
+
const { description } = fields;
|
|
72
|
+
if (typeof description === "string" && (description.includes("!`") || COMMAND_FENCE.test(description)))
|
|
73
|
+
problems.push({ rule: "no-commands", line: keyLine("description"), message: COMMANDS });
|
|
74
|
+
if (typeof description === "string" && CONTROL.test(description))
|
|
75
|
+
problems.push({
|
|
76
|
+
rule: "description",
|
|
77
|
+
line: keyLine("description"),
|
|
78
|
+
message: "The description has a control character in it. Write it as plain text."
|
|
79
|
+
});
|
|
80
|
+
return sorted(problems);
|
|
81
|
+
}
|
|
82
|
+
function headerLine(lines, end, key) {
|
|
83
|
+
const at = lines.slice(1, end).findIndex((line) => !/^\s/.test(line) && line.split(":")[0].replace(/["']/g, "").trim() === key);
|
|
84
|
+
return at < 0 ? 1 : at + 2;
|
|
85
|
+
}
|
|
86
|
+
function skillFields(text) {
|
|
87
|
+
const lines = text.split(/\r?\n/);
|
|
88
|
+
const header = readHeader(lines);
|
|
89
|
+
if (!("fields" in header)) return void 0;
|
|
90
|
+
const { fields, end } = header;
|
|
91
|
+
const { name, description } = fields;
|
|
92
|
+
if (typeof name !== "string" || !(0, import_bundled.isSkillName)(name)) return void 0;
|
|
93
|
+
return {
|
|
94
|
+
name,
|
|
95
|
+
description: typeof description === "string" ? description : "",
|
|
96
|
+
body: lines.slice(end + 1).join("\n"),
|
|
97
|
+
lineOf: (field, line) => {
|
|
98
|
+
if (field === "name" || field === "description") return headerLine(lines, end, field);
|
|
99
|
+
return field === "body" && typeof line === "number" ? end + 1 + line : null;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function userSkillName(text) {
|
|
104
|
+
const header = readHeader(text.split(/\r?\n/));
|
|
105
|
+
const name = "fields" in header ? header.fields.name : void 0;
|
|
106
|
+
return typeof name === "string" && (0, import_bundled.isSkillName)(name) ? name : void 0;
|
|
107
|
+
}
|
|
108
|
+
function sameSkill(a, b) {
|
|
109
|
+
const meaning = (text) => {
|
|
110
|
+
const skill = readSkill(text);
|
|
111
|
+
if (!skill || Object.keys(skill.fields).some((key) => !HEADER_KEYS.includes(key))) return;
|
|
112
|
+
if (skill.header.some(hasComment)) return;
|
|
113
|
+
const { name, description } = skill.fields;
|
|
114
|
+
return typeof name === "string" && typeof description === "string" ? [name, description.trim(), skill.body] : void 0;
|
|
115
|
+
};
|
|
116
|
+
const [left, right] = [meaning(a), meaning(b)];
|
|
117
|
+
return !!left && !!right && left.every((part, index) => part === right[index]);
|
|
118
|
+
}
|
|
119
|
+
function readSkill(text) {
|
|
120
|
+
const lines = text.split(/\r?\n/);
|
|
121
|
+
const header = readHeader(lines);
|
|
122
|
+
if (!("fields" in header)) return void 0;
|
|
123
|
+
const body = lines.slice(header.end + 1).join("\n").trim();
|
|
124
|
+
return { fields: header.fields, header: lines.slice(1, header.end), body };
|
|
125
|
+
}
|
|
126
|
+
function hasComment(line) {
|
|
127
|
+
return /(^|\s)#/.test(line.replace(/"(?:[^"\\]|\\.)*"|'(?:[^']|'')*'/g, '""'));
|
|
128
|
+
}
|
|
129
|
+
function readHeader(lines) {
|
|
130
|
+
const end = lines.indexOf("---", 1);
|
|
131
|
+
if (lines[0].replace(/^\uFEFF/, "") !== "---" || end < 0)
|
|
132
|
+
return {
|
|
133
|
+
problem: { rule: "header", line: 1, message: "The skill starts with a header between two --- lines." }
|
|
134
|
+
};
|
|
135
|
+
let fields;
|
|
136
|
+
try {
|
|
137
|
+
fields = load(lines.slice(1, end).join("\n"));
|
|
138
|
+
} catch (error) {
|
|
139
|
+
const at = error.mark?.line;
|
|
140
|
+
return {
|
|
141
|
+
problem: {
|
|
142
|
+
rule: "header",
|
|
143
|
+
line: at === void 0 ? 1 : at + 2,
|
|
144
|
+
message: "The header is not readable YAML."
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if (typeof fields !== "object" || fields === null || Array.isArray(fields))
|
|
149
|
+
return { problem: { rule: "header", line: 1, message: "The header is a list of keys and values." } };
|
|
150
|
+
return { fields, end };
|
|
151
|
+
}
|
|
152
|
+
function readPublishFolder(path) {
|
|
153
|
+
const stat = (0, import_fs.statSync)(path, { throwIfNoEntry: false });
|
|
154
|
+
const dir = stat?.isFile() && (0, import_path.basename)(path) === "SKILL.md" ? (0, import_path.dirname)(path) : path;
|
|
155
|
+
if (!(0, import_fs.statSync)(dir, { throwIfNoEntry: false })?.isDirectory()) throw new Error(`${path} is not a skill folder`);
|
|
156
|
+
const files = (0, import_bundled.skillFilePaths)(dir);
|
|
157
|
+
if (!files.includes("SKILL.md")) throw new Error(`${dir} has no SKILL.md`);
|
|
158
|
+
const beside = files.filter((file) => file !== "SKILL.md");
|
|
159
|
+
if (beside.length)
|
|
160
|
+
return {
|
|
161
|
+
problems: [
|
|
162
|
+
{
|
|
163
|
+
rule: "side-files",
|
|
164
|
+
line: null,
|
|
165
|
+
message: `A workspace skill is its SKILL.md alone; move or delete ${beside.join(", ")}.`
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
};
|
|
169
|
+
const text = (0, import_fs.readFileSync)((0, import_path.join)(dir, "SKILL.md"), "utf8");
|
|
170
|
+
const skill = skillFields(text);
|
|
171
|
+
const folder = (0, import_path.basename)((0, import_path.resolve)(dir));
|
|
172
|
+
if (skill && skill.name !== folder)
|
|
173
|
+
return {
|
|
174
|
+
problems: [
|
|
175
|
+
{
|
|
176
|
+
rule: "folder-name",
|
|
177
|
+
line: skill.lineOf("name", null),
|
|
178
|
+
message: `The folder is ${folder}, but the header names ${skill.name}: name them alike.`
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
};
|
|
182
|
+
return { text };
|
|
183
|
+
}
|
|
184
|
+
function sorted(problems) {
|
|
185
|
+
const seen = /* @__PURE__ */ new Set();
|
|
186
|
+
return problems.filter((problem) => {
|
|
187
|
+
const key = `${problem.rule}:${problem.line}`;
|
|
188
|
+
if (seen.has(key)) return false;
|
|
189
|
+
seen.add(key);
|
|
190
|
+
return true;
|
|
191
|
+
}).sort((a, b) => (a.line ?? 0) - (b.line ?? 0));
|
|
192
|
+
}
|
|
193
|
+
function describeProblem(problem) {
|
|
194
|
+
return `SKILL.md${problem.line === null ? "" : `:${problem.line}`} ${problem.rule} ${problem.message}`;
|
|
195
|
+
}
|
|
196
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
197
|
+
0 && (module.exports = {
|
|
198
|
+
checkUserSkill,
|
|
199
|
+
describeProblem,
|
|
200
|
+
readPublishFolder,
|
|
201
|
+
sameSkill,
|
|
202
|
+
skillFields,
|
|
203
|
+
sorted,
|
|
204
|
+
userSkillName
|
|
205
|
+
});
|
|
206
|
+
//# sourceMappingURL=userSkills.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/skills/userSkills.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,gBAAuC;AACvC,kBAAiD;AACjD,qBAA+D;AAE/D,MAAM,EAAE,KAAK,IAA2C,QAAQ,SAAS;AAUzE,MAAM,cAAc,CAAC,QAAQ,aAAa;AAa1C,MAAM,gBAAgB;AACtB,MAAM,WAAW;AAGjB,MAAM,UAAU;AAGhB,SAAS,gBAAgB,MAAc,UAA6C;AAChF,MAAI,KAAK,WAAW,SAAS,MAAM,EAAG,QAAO,uBAAuB,SAAS,MAAM;AAEnF,UAAI,kCAAkB,EAAE,SAA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I;AAC9B,QAAM,aAAS,0BAAS,qBAAQ,GAAG,CAAC;AACpC,MAAI,SAAS,MAAM,SAAS;AACxB,WAAO;AAAA,MACH,UAAU;AAAA,QACN;AAAA,UACI,MAAM;AAAA,UACN,MAAM,MAAM,OAAO,QAAQ,IAAI;AAAA,UAC/B,SAAS,iBAAiB,MAAM,0BAA0B,MAAM,IAAI;AAAA,QACxE;AAAA,MACJ;AAAA,IACJ;AACJ,SAAO,EAAE,KAAK;AAClB;AAGO,SAAS,OAAO,UAA0C;AAC7D,QAAM,OAAO,oBAAI,IAAY;AAC7B,SAAO,SACF,OAAO,CAAC,YAAY;AACjB,UAAM,MAAM,GAAG,QAAQ,IAAI,IAAI,QAAQ,IAAI;AAC3C,QAAI,KAAK,IAAI,GAAG,EAAG,QAAO;AAC1B,SAAK,IAAI,GAAG;AACZ,WAAO;AAAA,EACX,CAAC,EACA,KAAK,CAAC,GAAG,OAAO,EAAE,QAAQ,MAAM,EAAE,QAAQ,EAAE;AACrD;AAGO,SAAS,gBAAgB,SAA+B;AAC3D,SAAO,WAAW,QAAQ,SAAS,OAAO,KAAK,IAAI,QAAQ,IAAI,EAAE,KAAK,QAAQ,IAAI,KAAK,QAAQ,OAAO;AAC1G;",
|
|
5
|
+
"names": ["key"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var workspaceSkills_exports = {};
|
|
20
|
+
__export(workspaceSkills_exports, {
|
|
21
|
+
IN_SANDBOX: () => IN_SANDBOX,
|
|
22
|
+
forbiddenReason: () => forbiddenReason,
|
|
23
|
+
installTarget: () => installTarget,
|
|
24
|
+
otherServer: () => otherServer,
|
|
25
|
+
publishUserSkill: () => publishUserSkill,
|
|
26
|
+
readUserSkills: () => readUserSkills
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(workspaceSkills_exports);
|
|
29
|
+
var import_fs = require("fs");
|
|
30
|
+
var import_os = require("os");
|
|
31
|
+
var import_path = require("path");
|
|
32
|
+
var import_httpError = require("../services/httpError");
|
|
33
|
+
var import_configService = require("../services/configService");
|
|
34
|
+
var import_preflight = require("../services/preflight");
|
|
35
|
+
var import_workspaceRoot = require("../services/codefirst/workspaceRoot");
|
|
36
|
+
var import_agentSandbox = require("../utils/agentSandbox");
|
|
37
|
+
var import_errorFormatter = require("../utils/errorFormatter");
|
|
38
|
+
var import_install = require("./install");
|
|
39
|
+
var import_userSkills = require("./userSkills");
|
|
40
|
+
async function readUserSkills(client, tenant) {
|
|
41
|
+
const server = client.basePath.replace(/\/+$/, "");
|
|
42
|
+
let skills;
|
|
43
|
+
let settings;
|
|
44
|
+
try {
|
|
45
|
+
skills = await client.skillsRequest("GET", "/skills/export");
|
|
46
|
+
settings = await client.skillsRequest("GET", "/skills/settings");
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (errorBody(error, 403)?.code === "Forbidden")
|
|
49
|
+
return {
|
|
50
|
+
user: { workspace: tenant, server, skills: [] },
|
|
51
|
+
note: `Your account in ${tenant} has no Farseer AI chat, so it gets none of its skills.`
|
|
52
|
+
};
|
|
53
|
+
return { note: await exportFailure(error, tenant) };
|
|
54
|
+
}
|
|
55
|
+
const off = !skills.length && !settings.serving;
|
|
56
|
+
return {
|
|
57
|
+
user: {
|
|
58
|
+
workspace: tenant,
|
|
59
|
+
server,
|
|
60
|
+
skills,
|
|
61
|
+
reserved: { prefix: settings.reservedPrefix, names: settings.reservedNames }
|
|
62
|
+
},
|
|
63
|
+
note: off ? `${tenant} does not serve its skills yet: a super user turns serving on in Ask Farseer's Library.` : void 0
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
async function exportFailure(error, tenant) {
|
|
67
|
+
const status = error instanceof import_httpError.HttpError ? error.status : void 0;
|
|
68
|
+
if (status === 404) return `${tenant}'s server does not serve workspace skills yet.`;
|
|
69
|
+
if (status === 401) return `${tenant} did not accept the login: run farseer login, then install again.`;
|
|
70
|
+
return `Could not read ${tenant}'s skills (${await (0, import_errorFormatter.formatClientError)(error)}); the ones installed stay as they are.`;
|
|
71
|
+
}
|
|
72
|
+
const IN_SANDBOX = "An agent sandbox gets the workspace's skills from the chat, not from an install.";
|
|
73
|
+
async function installTarget(request) {
|
|
74
|
+
const { cwd, env } = request;
|
|
75
|
+
const project = (0, import_workspaceRoot.locateCodeWorkspace)(cwd);
|
|
76
|
+
const only = (note) => project || request.tenant || env.FARSEER_TENANT ? { project, note } : { project };
|
|
77
|
+
if (request.global)
|
|
78
|
+
return only("--global installs the CLI's skills only: a workspace's go into its checkout folder.");
|
|
79
|
+
let state;
|
|
80
|
+
let unreadable;
|
|
81
|
+
if (project)
|
|
82
|
+
try {
|
|
83
|
+
state = (0, import_workspaceRoot.resolveCodeWorkspace)(cwd).state;
|
|
84
|
+
} catch (error) {
|
|
85
|
+
unreadable = error instanceof Error ? error.message : String(error);
|
|
86
|
+
}
|
|
87
|
+
if (request.names.length)
|
|
88
|
+
return only("Named skills are the CLI's own; install without names for the workspace's too.");
|
|
89
|
+
if ((0, import_agentSandbox.inAgentSandbox)(env)) return only(IN_SANDBOX);
|
|
90
|
+
if (unreadable)
|
|
91
|
+
return only(`The checkout's state cannot be read (${unreadable}): its workspace's skills were left out.`);
|
|
92
|
+
if (state && request.tenant && request.tenant !== state.tenant)
|
|
93
|
+
return only(
|
|
94
|
+
`This folder is the checkout of ${state.tenant}: ${request.tenant}'s skills would mix two workspaces, so they were left out.`
|
|
95
|
+
);
|
|
96
|
+
if (!project && (0, import_install.gitTopLevel)(cwd))
|
|
97
|
+
return only(
|
|
98
|
+
"Workspace skills go into a checkout folder (farseer code checkout <tenant>), never a repository's root, so one repository never mixes workspaces."
|
|
99
|
+
);
|
|
100
|
+
if (isPersonalFolder(project ?? cwd, env))
|
|
101
|
+
return only(
|
|
102
|
+
"This is your home folder: its .claude/skills and .agents/skills load in every project, so a workspace's skills go into its checkout folder instead."
|
|
103
|
+
);
|
|
104
|
+
if (!project && holdsCheckouts(cwd))
|
|
105
|
+
return only(
|
|
106
|
+
"This folder holds checkout folders: each takes its own workspace's skills (farseer skills install in it), so none loads another's."
|
|
107
|
+
);
|
|
108
|
+
const tenant = state?.tenant ?? request.tenant ?? env.FARSEER_TENANT;
|
|
109
|
+
if (!tenant) return { project };
|
|
110
|
+
const organisation = (
|
|
111
|
+
// `||`, as the tenant resolver has it: an empty FARSEER_ORG (some shells export one) names nothing.
|
|
112
|
+
state?.organisation || request.org || (tenant === env.FARSEER_TENANT ? env.FARSEER_ORG : void 0) || (0, import_configService.getTenantOrg)(tenant) || ((0, import_configService.getCredential)(tenant) ? tenant : void 0)
|
|
113
|
+
);
|
|
114
|
+
if (!organisation) return only(`Organisation unknown for ${tenant}: pass --org <org> for its skills too.`);
|
|
115
|
+
try {
|
|
116
|
+
const outcome = await (0, import_preflight.openTenantSession)(organisation, tenant);
|
|
117
|
+
if (!outcome.ok) return only(sessionNote(outcome.failure));
|
|
118
|
+
const { client } = (0, import_preflight.sessionFrom)(outcome.organisation, outcome.tenant, outcome.auth);
|
|
119
|
+
const other = state && otherServer(state, client);
|
|
120
|
+
if (other) return only(`${other}. Its skills were left out.`);
|
|
121
|
+
return { project, ...await readUserSkills(client, tenant) };
|
|
122
|
+
} catch (error) {
|
|
123
|
+
return only(`Could not reach ${tenant} (${await (0, import_errorFormatter.formatClientError)(error)}): its skills were left out.`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function otherServer(state, client) {
|
|
127
|
+
const resolved = client.basePath.replace(/\/+$/, "");
|
|
128
|
+
if (resolved === state.baseUrl) return void 0;
|
|
129
|
+
return `This workspace was checked out from ${state.baseUrl}, but this command would use ${resolved}; run it with the credential and FARSEER_API_URL the workspace was checked out with`;
|
|
130
|
+
}
|
|
131
|
+
function isPersonalFolder(folder, env) {
|
|
132
|
+
const real = (path) => {
|
|
133
|
+
try {
|
|
134
|
+
return (0, import_fs.realpathSync)(path);
|
|
135
|
+
} catch {
|
|
136
|
+
return (0, import_path.resolve)(path);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
const personalClaude = (0, import_path.join)(env.CLAUDE_CONFIG_DIR || (0, import_path.join)((0, import_os.homedir)(), ".claude"), "skills");
|
|
140
|
+
return real(folder) === real((0, import_os.homedir)()) || real((0, import_path.join)(folder, ".claude", "skills")) === real(personalClaude) || real((0, import_path.join)(folder, ".agents", "skills")) === real((0, import_path.join)((0, import_os.homedir)(), ".agents", "skills"));
|
|
141
|
+
}
|
|
142
|
+
function holdsCheckouts(dir, depth = 2) {
|
|
143
|
+
let entries;
|
|
144
|
+
try {
|
|
145
|
+
entries = (0, import_fs.readdirSync)(dir, { withFileTypes: true });
|
|
146
|
+
} catch {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
return entries.some(
|
|
150
|
+
(entry) => entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules" && ((0, import_fs.existsSync)((0, import_path.join)(dir, entry.name, import_workspaceRoot.STATE_FILE)) || depth > 1 && holdsCheckouts((0, import_path.join)(dir, entry.name), depth - 1))
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
function sessionNote(failure) {
|
|
154
|
+
if (failure.reason === "no-credentials")
|
|
155
|
+
return `Not signed in to ${failure.tenant}, or its server cannot be reached: run farseer login for its skills.`;
|
|
156
|
+
if (failure.reason === "org-unknown")
|
|
157
|
+
return `No Farseer organisation at ${failure.organisation}: its skills were left out.`;
|
|
158
|
+
return `${failure.tenant} is not available under ${failure.organisation}: its skills were left out.`;
|
|
159
|
+
}
|
|
160
|
+
async function publishUserSkill(client, skill) {
|
|
161
|
+
const { name, description, body } = skill;
|
|
162
|
+
try {
|
|
163
|
+
const { outcome } = await client.skillsRequest(
|
|
164
|
+
"PUT",
|
|
165
|
+
`/skills/${encodeURIComponent(name)}`,
|
|
166
|
+
{ description, body }
|
|
167
|
+
);
|
|
168
|
+
return { outcome };
|
|
169
|
+
} catch (error) {
|
|
170
|
+
const refused = errorBody(error, 400);
|
|
171
|
+
if (refused?.code === "SkillProblems" && Array.isArray(refused.problems) && refused.problems.length)
|
|
172
|
+
return { problems: problemsOn(refused.problems, skill) };
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function problemsOn(problems, skill) {
|
|
177
|
+
const placed = problems.map((value) => {
|
|
178
|
+
const problem = value;
|
|
179
|
+
return {
|
|
180
|
+
rule: clean(String(problem?.rule)),
|
|
181
|
+
line: skill.lineOf(problem?.field, problem?.line),
|
|
182
|
+
message: clean(String(problem?.message))
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
return (0, import_userSkills.sorted)(placed);
|
|
186
|
+
}
|
|
187
|
+
function forbiddenReason(error) {
|
|
188
|
+
const body = errorBody(error, 403);
|
|
189
|
+
const message = body?.message ?? body?.error;
|
|
190
|
+
return typeof message === "string" ? clean(message) : void 0;
|
|
191
|
+
}
|
|
192
|
+
function errorBody(error, status) {
|
|
193
|
+
if (!(error instanceof import_httpError.HttpError) || error.status !== status || !error.body) return void 0;
|
|
194
|
+
try {
|
|
195
|
+
const body = JSON.parse(error.body);
|
|
196
|
+
return typeof body === "object" && body !== null ? body : void 0;
|
|
197
|
+
} catch {
|
|
198
|
+
return void 0;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function clean(text) {
|
|
202
|
+
return text.replace(/[\u0000-\u001f\u007f-\u009f]/g, "").trim();
|
|
203
|
+
}
|
|
204
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
205
|
+
0 && (module.exports = {
|
|
206
|
+
IN_SANDBOX,
|
|
207
|
+
forbiddenReason,
|
|
208
|
+
installTarget,
|
|
209
|
+
otherServer,
|
|
210
|
+
publishUserSkill,
|
|
211
|
+
readUserSkills
|
|
212
|
+
});
|
|
213
|
+
//# sourceMappingURL=workspaceSkills.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/skills/workspaceSkills.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,gBAAsD;AACtD,gBAAwB;AACxB,kBAA8B;AAE9B,uBAA0B;AAC1B,2BAA4C;AAC5C,uBAAoE;AAEpE,2BAAsE;AACtE,0BAA+B;AAC/B,4BAAkC;AAClC,qBAAqE;AACrE,wBAA4D;AAuB5D,eAAsB,eAAe,QAAwB,QAA0C;AACnG,QAAM,SAAS,OAAO,SAAS,QAAQ,QAAQ,EAAE;AACjD,MAAI;AACJ,MAAI;AACJ,MAAI;AACA,aAAS,MAAM,OAAO,cAA6B,OAAO,gBAAgB;AAC1E,eAAW,MAAM,OAAO,cAA6B,OAAO,kBAAkB;AAAA,EAClF,SAAS,OAAO;AAEZ,QAAI,UAAU,OAAO,GAAG,GAAG,SAAS;AAChC,aAAO;AAAA,QACH,MAAM,EAAE,WAAW,QAAQ,QAAQ,QAAQ,CAAC,EAAE;AAAA,QAC9C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KILL.md (--path prints the
|
|
|
390
390
|
farseer skills show pipeline-authoring --file practices.md # another file of a skill
|
|
391
391
|
farseer skills install # the repo's .claude/skills (Claude Code) and .agents/skills (Codex, OpenHands)
|
|
392
392
|
farseer skills install --global # ~/.claude/skills and ~/.agents/skills instead
|
|
393
|
+
farseer skills publish ./forecast-method # save a skill folder as one of the workspace's skills
|
|
393
394
|
farseer docs # the reference docs; farseer docs troubleshooting prints one
|
|
394
395
|
```
|
|
395
396
|
|
|
396
|
-
`install` writes to the root of the git repository you are in, or to the current folder outside one. Run it again after updating the CLI: it updates the folders it installed and leaves alone a folder that was edited since, or that it did not install. `--force` shows the plan with those folders replaced too, and writes nothing; `--force -y` carries it out. `--json` prints each skill's `status`: `installed`, `updated`, `unchanged`, `skipped`, `replaced`, `obsolete` or `failed`, and in a `--force` plan `would-install`, `would-update` or `would-replace`. A Claude Code session started before `.claude/skills` existed needs `/reload-skills`.
|
|
397
|
+
`install` writes to the root of the git repository you are in, or to the current folder outside one; in a code checkout folder, it writes into that folder instead. Run it again after updating the CLI: it updates the folders it installed and leaves alone a folder that was edited since, or that it did not install. `--force` shows the plan with those folders replaced too, and writes nothing; `--force -y` carries it out. `--json` prints each skill's `status`: `installed`, `updated`, `unchanged`, `skipped`, `replaced`, `obsolete` or `failed`, and in a `--force` plan `would-install`, `would-update` or `would-replace`. A Claude Code session started before `.claude/skills` existed needs `/reload-skills`.
|
|
398
|
+
|
|
399
|
+
**Workspace skills.** A workspace can have skills of its own, written in Ask Farseer's Library or published from the CLI by its super users and the people they give the Edit skills permission. Run `install` in a workspace's checkout folder (`farseer code checkout` makes one, and installs them as it does) and it adds the skills the workspace serves to that folder's `.claude/skills` and `.agents/skills`, never above it. Outside any repository, `--tenant <slug>` (or `FARSEER_TENANT`) names the workspace and the current folder takes its skills, unless it is your home folder (whose skills folders load in every project) or holds checkout folders. Anywhere else, with `--global` or with skill names, `install` installs the CLI's skills only and says why; it says so too when the account has no Farseer AI chat or the workspace serves none, and removes the workspace's skills it installed before, as for any skill no longer served. When the workspace's skills or its settings cannot be read (an expired login, the network, a server without workspace skills), nothing is installed or deleted. Each folder holds one workspace's skills, and `.farseer-install.json` records the workspace and the revision it served. Installing for another workspace deletes the first one's skills unless one was edited here, which keeps all of them until `--force -y`. A skill the workspace no longer serves is deleted, or reported when it was edited here. A workspace skill never takes a name the CLI's skills use, and the CLI checks each one before it writes it: a skill that would run a command (`` !`…` ``, a ```` ```! ```` block), has header keys other than `name` and `description`, or has a name the workspace reserves (its settings list them) is skipped and reported. In `--json`, a workspace skill has `source: "workspace"`, its `workspace` and `revision`, and the statuses `deleted` and, in a plan, `would-delete`.
|
|
400
|
+
|
|
401
|
+
`farseer skills publish <folder> [org] [tenant]` saves the folder's `SKILL.md` as a new workspace skill, or as the new description and body of the one with its name; a folder with anything else beside it (dotfiles aside), or named other than the skill, is refused. It runs the same checks first, except for reserved names, which the workspace judges when it saves; each problem, the CLI's or the workspace's, prints on its line of the file as `SKILL.md:<line> <rule> <message>`, and the workspace's refusal of a reserved name says whose name it is; a name the skills API uses for a route of its own (`check`, `settings`, `export`) gets that route's error instead. It prints what the workspace did: `created`, `updated`, or `unchanged` when it already has that description and body, which writes nothing. Publishing needs a super user, or someone with the Edit skills permission, signed in with `farseer login`: the workspace takes skill changes from a person, never from an API key or an agent sandbox. In a checkout folder it publishes to that checkout's workspace unless you name another.
|
|
397
402
|
|
|
398
403
|
### Agent workflows
|
|
399
404
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ name: farseer-app-dev
|
|
|
3
3
|
description: >-
|
|
4
4
|
Use when the user asks to write, modify, or refactor a Farseer app (TypeScript using the `farseer-client` SDK) — import jobs, exports, transforms, reports. Inspects live model via explicit-tenant CLI reads first, follows the SDK working patterns (optimistic auth resolution — never prompt "OAuth or API key?", `error.text()` catch, `exportModel` excluding CELL, named `toRow` helper, validation-before-mutation), tests incrementally. Triggers (match by MEANING, in ANY language): "write a Farseer app", "modify the import script", "I need an app that…".
|
|
5
5
|
metadata:
|
|
6
|
-
version: "
|
|
6
|
+
version: "2"
|
|
7
7
|
domain: modeling
|
|
8
8
|
---
|
|
9
9
|
|
|
@@ -55,7 +55,7 @@ Use for any TypeScript app using the `farseer-client` SDK. A **new recurring imp
|
|
|
55
55
|
- **Model export** — exclude `CELL` from whole-model exports: `types: ["DTAB", "DMEM", "VAR"] as any`. Including `CELL` fails with "Invalid string length".
|
|
56
56
|
- **Validation before mutation** — every write app first calls `exportModel()` and confirms target variables and dimensions exist with the expected shape. Fail loudly rather than silently create the wrong thing.
|
|
57
57
|
- **Import jobs** — column order in `columns` must match `addRow([...])` order. Use a named `toRow(record): unknown[]` helper. For a **recurring, audited data load** (locked `IMPORT_` targets, scope-encoding labels, idempotent revert-then-commit re-runs), don't hand-roll it here — use the [`farseer-author-import-job`](../farseer-author-import-job/SKILL.md) skill.
|
|
58
|
-
- **Dimension discrimination** — when one source column targets a specific dimension member, use `{ type: "VARIABLE", variableName, dimensionsNames: [{ tableName: "Dim", memberName: "Member" }] }`.
|
|
58
|
+
- **Dimension discrimination** — when one source column targets a specific dimension member, use `{ type: "VARIABLE", variableName, dimensionsNames: [{ tableName: "Dim", memberName: "Member" }] }`. There is no `tables` field: the SDK ignores it and the column writes without the pin ([`working-patterns.md`](working-patterns.md#import-data--dimension-discrimination)).
|
|
59
59
|
- **Name matching is case-sensitive** — including spaces, ` IN`/` OUT` suffixes, special characters.
|
|
60
60
|
- **Logging** — structured, step-based.
|
|
61
61
|
- **Dry-run** — support `DRY_RUN=true` to preview without committing. Honour it
|
|
@@ -25,7 +25,7 @@ An Assignment defines:
|
|
|
25
25
|
| Which period | `data.intervalStart/End` | `M/YYYY`, no leading zero — `'1/2026'`, `'12/2026'` |
|
|
26
26
|
| Which version(s) | `data.versionIds` | DMEM ids from the `Versions` dim table |
|
|
27
27
|
| Categorisation | `labelIds` | labels must exist first — §2 |
|
|
28
|
-
| Auto-expiry | `expirationTime` | JS `Date` |
|
|
28
|
+
| Auto-expiry | `expirationTime` | JS `Date`. An expired assignment falls back to `VIEW` and stays visible; a plain share (no status) with a time limit switches off entirely, viewing included (read in source) |
|
|
29
29
|
| Visibility | `status` | create with `AssignmentStatus.Shared` |
|
|
30
30
|
|
|
31
31
|
The client accessors are `client.assignments` (`AssignmentsApi`) and `client.assignmentLabels` (`AssignmentLabelsApi`). Full method surface **[types]**:
|
|
@@ -65,6 +65,18 @@ before anything else:
|
|
|
65
65
|
`farseer pull` and `farseer install <tenant>` move a bucket tarball or an
|
|
66
66
|
older CLI-written pin to `npm:@farseerdev/farseer-client@1.18.1`; a pin you
|
|
67
67
|
set yourself (a newer version, a range, a path) is kept.
|
|
68
|
+
**On npm 12** an install of the old pin fails with `EALLOWREMOTE` (the
|
|
69
|
+
tarball), then `EALLOWGIT` (a git dependency of that build); a root-owned
|
|
70
|
+
`~/.npm` adds `EACCES` (field report 2026-10-20). Moving the pin to npm
|
|
71
|
+
removes `EALLOWGIT` but not `EALLOWREMOTE`: 1.18.1 also takes `xlsx` from a
|
|
72
|
+
URL. So on npm 12 install with
|
|
73
|
+
`npm install --allow-remote=all --no-audit --no-fund --cache
|
|
74
|
+
<scratch-dir> --prefix farseer-apps/<tenant>`, adding `--allow-git=all` for the
|
|
75
|
+
old pin. Those flags lift npm
|
|
76
|
+
12's supply-chain guard for **every** dependency of that install, not just
|
|
77
|
+
the SDK — use them for that one command, never in a config file. Never
|
|
78
|
+
`sudo` to fix the cache: `--cache` (or `npm_config_cache=<scratch-dir>`)
|
|
79
|
+
sidesteps it.
|
|
68
80
|
**`farseer-client-axios`** — some of these also pin it to a bucket tarball.
|
|
69
81
|
It is deprecated and will not move to npm; `farseer-client` replaces it.
|
|
70
82
|
`farseer pull` / `farseer install` drop a bucket-pinned line; delete any
|
|
@@ -73,7 +85,7 @@ before anything else:
|
|
|
73
85
|
3. **Typecheck.** The jump is from 1.4.5–1.8.12 to 1.18.1. The typed surface
|
|
74
86
|
mostly grows, but `LockRuleFilter.exclude` is gone since 1.8.19 (see
|
|
75
87
|
[Semi-breaking](#-semi-breaking)).
|
|
76
|
-
4. **Check the constructor.** Since 1.
|
|
88
|
+
4. **Check the constructor.** Since 1.8.4 the positional and no-argument forms
|
|
77
89
|
(`new FarseerClient(tenantId, apiKey, url)`, `new FarseerClient()`) read
|
|
78
90
|
`process.env.FARSEER_TOKEN` themselves and throw *"Cannot set both …"* when it and the
|
|
79
91
|
API-key variable are both present — `farseer run`
|
|
@@ -248,7 +248,7 @@ const newFolderId = result.id ?? result.folderId;
|
|
|
248
248
|
|
|
249
249
|
`allowedTypes` is required and must respect the parent's constraints. A folder under Variables must allow `VARIABLE` (and typically `FOLDER` for nesting). A folder under Dimensions must allow `DIMENSION_TABLE` (and `FOLDER`). Mixing — e.g. trying to allow `DIMENSION_TABLE` under the Variables tree — fails with `"Invalid allowed types"`.
|
|
250
250
|
|
|
251
|
-
**Folder names
|
|
251
|
+
**Folder names are not globally unique.** Measured 2026-11-05 on a sandbox tenant: the same folder name was accepted in each of the four folder trees. A tree name must be unique within its parent folder, and a folder cannot take the name of a variable in the same parent — both answer `400 BadRequest "Name already taken"`. Whether one name may repeat under two parents of the same tree was not measured. If a folder of the desired name already exists under the parent you want, search and reuse it instead of creating a duplicate:
|
|
252
252
|
|
|
253
253
|
```typescript
|
|
254
254
|
const found = await client.entities.search({ name: "Import", types: ["FOLD"] });
|
|
@@ -304,7 +304,7 @@ When refactoring a model — e.g. unifying naming style on an existing tenant
|
|
|
304
304
|
|
|
305
305
|
**Wrong approaches that look right:**
|
|
306
306
|
|
|
307
|
-
- `client.folders.renameItem({ id, name })` — fails with `400 BadRequest "Requested item is not a folder"` for variables and dim tables. The endpoint
|
|
307
|
+
- `client.folders.renameItem({ id, name })` — fails with `400 BadRequest "Requested item is not a folder"` for variables and dim tables (for every item type but a folder). The endpoint renames folders themselves only, despite "item" in the name.
|
|
308
308
|
- `client.model.load(...)` with the new name and `clear: false` — creates a new variable / dim alongside the old one. Old entity remains, old cell data stays attached to it; new entity is empty. Net effect: orphans + duplicated work.
|
|
309
309
|
|
|
310
310
|
**Right approach — `entities.mutate` with `EntityUpdate.meta.name`:**
|
|
@@ -332,6 +332,11 @@ await client.entities.mutate({
|
|
|
332
332
|
|
|
333
333
|
The platform preserves the entity ID, all cell data, and updates internal references in formulas and dependencies. No orphan, no data loss.
|
|
334
334
|
|
|
335
|
+
**A file in Farseer Files** is an entity of type `FILE`, renamed the same way:
|
|
336
|
+
`entities.mutate` with `type: "FILE"` and `meta.name`. `PUT /farseerFiles/{uuid}`
|
|
337
|
+
with a new filename keeps the old name. The minimal payload is safe for `FILE`
|
|
338
|
+
only (the backend reads just `id` and `meta.name`).
|
|
339
|
+
|
|
335
340
|
### Why include `description` in the mutate
|
|
336
341
|
|
|
337
342
|
The `MetaComponent` shape has `name` and `description` as required fields when emitted. If you set `meta: { name: newName }` and omit the description, the platform may overwrite it with null. Always read the existing description first and pass it through (or pass the new description if you intend to change it). Same for any other meta-level fields (notes, etc.) the entity carries.
|
|
@@ -452,7 +457,7 @@ shape. **When to use import:**
|
|
|
452
457
|
`DIMENSION_TABLE` + per-`VARIABLE` columns map naturally onto
|
|
453
458
|
spreadsheet/CSV shapes.
|
|
454
459
|
- **Anything you want labelled** so QA / the customer can find and review it
|
|
455
|
-
later (e.g. `labels: ["
|
|
460
|
+
later (e.g. `labels: ["actuals_load", "2025_Q4"]` — `[A-Za-z0-9_-]` only).
|
|
456
461
|
|
|
457
462
|
### Quick decision table
|
|
458
463
|
|
|
@@ -487,7 +492,7 @@ const importJob = await client.createImportJob({
|
|
|
487
492
|
{ type: "VARIABLE", variableName: "Revenue" },
|
|
488
493
|
{ type: "VARIABLE", variableName: "Cost" },
|
|
489
494
|
],
|
|
490
|
-
labels: ["automated", "
|
|
495
|
+
labels: ["automated", "source_x"],
|
|
491
496
|
});
|
|
492
497
|
|
|
493
498
|
for (const row of sourceData) {
|
|
@@ -517,6 +522,13 @@ await importJob.commit();
|
|
|
517
522
|
> [`cell-writes.md`](../farseer-author-import-job/cell-writes.md) for the `metadata`-based escape hatch that flips
|
|
518
523
|
> both flags.
|
|
519
524
|
|
|
525
|
+
> **Financial year.** The overload sends no `ignoreFinancialYearOffset` either. On a tenant
|
|
526
|
+
> whose financial year starts in month S ≠ 1 the platform reads `Years`/`Months` as calendar
|
|
527
|
+
> periods and files every cell S − 1 months earlier; a month fixed in `dimensionsNames` (next
|
|
528
|
+
> section) shifts too. Rows that carry the tenant's own periods (copies of values read from a
|
|
529
|
+
> tenant) need the flag set through the `metadata` overload:
|
|
530
|
+
> [`import-job-pattern.md` §6](../farseer-author-import-job/import-job-pattern.md#6-financial-year-an-import-job-maps-calendar-periods-to-fiscal-ones).
|
|
531
|
+
|
|
520
532
|
## Import data — dimension discrimination
|
|
521
533
|
|
|
522
534
|
When one variable is populated from multiple source columns that each represent a different dimension slice:
|
|
@@ -539,7 +551,7 @@ for (const row of sourceData) {
|
|
|
539
551
|
await importJob.commit();
|
|
540
552
|
```
|
|
541
553
|
|
|
542
|
-
|
|
554
|
+
A `VARIABLE` column is pinned with `dimensionsNames: [{ tableName, memberName }]`. There is no `tables` field: the SDK silently ignores it (checked 2026-11-09 against farseer-client on dev and on a sandbox tenant) and the column then writes without the pin. To check it before the job exists, build the metadata with `client.buildImportJobMetadata(columns)`: `columnMetas[i].applyTagsIds` must contain the member id next to the variable id. Then create the job from it with `createImportJob({ title, metadata, labels })`.
|
|
543
555
|
|
|
544
556
|
## Log progress on large imports
|
|
545
557
|
|
|
@@ -662,6 +674,17 @@ works fine.
|
|
|
662
674
|
same `id`-vs-`reference` split documented elsewhere for sheets/folder items
|
|
663
675
|
applies to uploaded files too.
|
|
664
676
|
|
|
677
|
+
## Reading a file back — by `reference`, not through `downloadUrl`
|
|
678
|
+
|
|
679
|
+
`GET /farseerFiles/{reference}/downloadUrl` signs a URL only for a file in
|
|
680
|
+
object storage; a file the tenant keeps in the database (an app script, for
|
|
681
|
+
example) answers 404 "No download URL available…" (read in source). Read
|
|
682
|
+
the content with `GET /farseerFiles/{reference}`: SDK
|
|
683
|
+
`client.farseerFiles.get(uuid)` returns a `Blob`. The id is the folder item's
|
|
684
|
+
`reference` (a uuid); a numeric id answers 400. This route buffers the whole
|
|
685
|
+
file, which is fine for a script; take the `downloadUrl` of a large file in
|
|
686
|
+
object storage. Don't `farseer pull` a whole tenant to read one script.
|
|
687
|
+
|
|
665
688
|
## Registering an uploaded script as a remote-job app — `remoteJobs.create`
|
|
666
689
|
|
|
667
690
|
```ts
|
|
@@ -730,6 +753,8 @@ first. The traps:
|
|
|
730
753
|
exist.
|
|
731
754
|
- `SheetsApi` has **no** delete / remove method (create / update /
|
|
732
755
|
duplicate / setData / getData / search / get / getByIds — no delete).
|
|
756
|
+
REST `DELETE /sheets/{id}` answers **405** `MethodNotAllowed`
|
|
757
|
+
(2026-11-06).
|
|
733
758
|
|
|
734
759
|
Sheets are **folder items** in the Sheets tree. The Folders API deletes
|
|
735
760
|
them by folder-item id:
|