intentdocs 0.10.0 → 0.11.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 +6 -1
- package/dist/chunk-64I7RLP3.js +171 -0
- package/dist/{chunk-IDNUBI2P.js → chunk-65EDM7QH.js} +6 -6
- package/dist/{chunk-NFIXRIHM.js → chunk-BNEU6TLJ.js} +55 -21
- package/dist/chunk-GFKZ5CRL.js +12 -0
- package/dist/{chunk-5USVG4DW.js → chunk-ID4B5RZ2.js} +42 -21
- package/dist/{chunk-EEKEF2FD.js → chunk-IORMKLAQ.js} +178 -121
- package/dist/{chunk-UF535HZL.js → chunk-K5SNF6CG.js} +13 -2
- package/dist/{chunk-HEHHSSUM.js → chunk-KPQ42YE6.js} +1 -1
- package/dist/{chunk-YUW3W43S.js → chunk-KTGQO3AE.js} +31 -8
- package/dist/{chunk-UR73WX5I.js → chunk-UQDMUKLP.js} +2 -2
- package/dist/{chunk-LXQXJULN.js → chunk-XZE2XP6O.js} +3 -3
- package/dist/ci-NOCV3XUV.js +11 -0
- package/dist/{complexity-ZOB3BPVD.js → complexity-OJVM37NF.js} +4 -4
- package/dist/{import-prd-MJUCIMHX.js → import-prd-5FCVXCYO.js} +14 -7
- package/dist/index.js +377 -359
- package/dist/{keys-5PA3D6CX.js → keys-2W5V56FS.js} +32 -11
- package/dist/{log-EVLWM64C.js → log-DFCCAAJN.js} +23 -7
- package/dist/{map-extract-W6WJLVOF.js → map-extract-YUCFLGJS.js} +2 -2
- package/dist/{map-import-LL4AIAQE.js → map-import-7RN2NEUZ.js} +7 -6
- package/dist/{map-schema-6GL2UKZQ.js → map-schema-5BEIJM2J.js} +1 -1
- package/dist/{projects-F7GMH66U.js → projects-AYAYVFKL.js} +2 -2
- package/dist/push-33V7ANJW.js +462 -0
- package/dist/{research-4ASCZSZN.js → research-SHO5SXVQ.js} +4 -4
- package/dist/scope-RRGJHS2G.js +13 -0
- package/dist/setup-UILQVYIB.js +14 -0
- package/package.json +6 -5
- package/dist/ci-LBOCMRKZ.js +0 -11
- package/dist/scope-S3LZZ3KB.js +0 -11
- package/dist/setup-YLUPBLK6.js +0 -14
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getAuth
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XZE2XP6O.js";
|
|
4
4
|
|
|
5
5
|
// src/lib/api.ts
|
|
6
6
|
var AuthError = class extends Error {
|
|
@@ -9,17 +9,25 @@ var AuthError = class extends Error {
|
|
|
9
9
|
this.name = "AuthError";
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
+
var ApiError = class extends Error {
|
|
13
|
+
constructor(message, status, code = null) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.status = status;
|
|
16
|
+
this.code = code;
|
|
17
|
+
this.name = "ApiError";
|
|
18
|
+
}
|
|
19
|
+
};
|
|
12
20
|
function checkoutMismatch(config, binding) {
|
|
13
21
|
const checkout = config.workspace;
|
|
14
22
|
if (!checkout || !checkout.orgId) return null;
|
|
15
23
|
const checkoutName = checkout.name ?? "another workspace";
|
|
16
24
|
const here = config.mapTitle ? `"${config.mapTitle}"` : "this checkout";
|
|
17
25
|
if (!binding) {
|
|
18
|
-
return `${here} belongs to ${checkoutName}, but your token is personal. Run \`intentdocs login\` and choose ${checkoutName}.`;
|
|
26
|
+
return `${here} belongs to ${checkoutName}, but your token is personal. Run \`npx intentdocs login\` and choose ${checkoutName}.`;
|
|
19
27
|
}
|
|
20
28
|
if (binding.orgId !== checkout.orgId) {
|
|
21
29
|
const bound = binding.workspaceName ?? "a different workspace";
|
|
22
|
-
return `This checkout is ${checkoutName}'s \u2014 ${here} \u2014 but your token is bound to ${bound}. Run \`intentdocs login\` and choose ${checkoutName}, or work from a checkout of ${bound}'s.`;
|
|
30
|
+
return `This checkout is ${checkoutName}'s \u2014 ${here} \u2014 but your token is bound to ${bound}. Run \`npx intentdocs login\` and choose ${checkoutName}, or work from a checkout of ${bound}'s.`;
|
|
23
31
|
}
|
|
24
32
|
return null;
|
|
25
33
|
}
|
|
@@ -42,18 +50,29 @@ async function refusalMessage(res) {
|
|
|
42
50
|
}
|
|
43
51
|
return null;
|
|
44
52
|
}
|
|
53
|
+
async function errorCode(res) {
|
|
54
|
+
try {
|
|
55
|
+
const body = await res.clone().json();
|
|
56
|
+
if (typeof body.error === "string") return body.error;
|
|
57
|
+
if (body.error && typeof body.error === "object" && typeof body.error.code === "string") {
|
|
58
|
+
return body.error.code;
|
|
59
|
+
}
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
45
64
|
async function apiFetch(config, path, init) {
|
|
46
65
|
const auth = getAuth();
|
|
47
66
|
const mismatch = checkoutMismatch(config, auth?.binding);
|
|
48
67
|
if (mismatch) throw new AuthError(mismatch);
|
|
49
68
|
if (!auth?.token) {
|
|
50
|
-
throw new AuthError("Not logged in \u2014 every sync runs as you now. Run `intentdocs login`.");
|
|
69
|
+
throw new AuthError("Not logged in \u2014 every sync runs as you now. Run `npx intentdocs login`.");
|
|
51
70
|
}
|
|
52
71
|
const withBearer = { ...init, headers: syncHeaders(init?.headers, auth) };
|
|
53
72
|
const res = await fetch(apiUrl(config, path), withBearer);
|
|
54
73
|
if (res.status === 401) {
|
|
55
74
|
const said = await refusalMessage(res);
|
|
56
|
-
throw new AuthError(said ?? "Your login is no longer valid. Run `intentdocs login`.");
|
|
75
|
+
throw new AuthError(said ?? "Your login is no longer valid. Run `npx intentdocs login`.");
|
|
57
76
|
}
|
|
58
77
|
if (res.status === 404) {
|
|
59
78
|
const said = await refusalMessage(res);
|
|
@@ -62,15 +81,18 @@ async function apiFetch(config, path, init) {
|
|
|
62
81
|
if (res.status === 403) {
|
|
63
82
|
const said = await refusalMessage(res);
|
|
64
83
|
throw new AuthError(
|
|
65
|
-
said ?? "Access denied \u2014 you may not have permission for this project. Run `intentdocs login` to re-authenticate."
|
|
84
|
+
said ?? "Access denied \u2014 you may not have permission for this project. Run `npx intentdocs login` to re-authenticate."
|
|
66
85
|
);
|
|
67
86
|
}
|
|
68
|
-
if (!res.ok)
|
|
87
|
+
if (!res.ok) {
|
|
88
|
+
const said = await refusalMessage(res);
|
|
89
|
+
throw new ApiError(said ?? `API error: ${res.status}`, res.status, await errorCode(res));
|
|
90
|
+
}
|
|
69
91
|
return res;
|
|
70
92
|
}
|
|
71
93
|
function apiUrl(config, path) {
|
|
72
94
|
if (!config.mapId) {
|
|
73
|
-
throw new AuthError("This checkout has no map id. Run `intentdocs init` to reconnect it.");
|
|
95
|
+
throw new AuthError("This checkout has no map id. Run `npx intentdocs init` to reconnect it.");
|
|
74
96
|
}
|
|
75
97
|
return `${config.apiBase}/api/sync/${config.mapId}${path}`;
|
|
76
98
|
}
|
|
@@ -154,6 +176,7 @@ async function retractDecision(config, decisionId, reason) {
|
|
|
154
176
|
}
|
|
155
177
|
|
|
156
178
|
export {
|
|
179
|
+
checkoutMismatch,
|
|
157
180
|
syncHeaders,
|
|
158
181
|
apiFetch,
|
|
159
182
|
apiUrl,
|
|
@@ -3,14 +3,14 @@ import chalk from "chalk";
|
|
|
3
3
|
function isPlanGated(status) {
|
|
4
4
|
return status === 402 || status === 403;
|
|
5
5
|
}
|
|
6
|
-
var UPGRADE_MESSAGE_PLAIN = "This feature requires a Pro plan or your own Anthropic key.\n Upgrade: https://intentdocs.com/pricing\n Or add your key:
|
|
6
|
+
var UPGRADE_MESSAGE_PLAIN = "This feature requires a Pro plan or your own Anthropic key.\n Upgrade: https://intentdocs.com/pricing\n Or add your key: npx intentdocs keys set";
|
|
7
7
|
function printUpgradeMessage() {
|
|
8
8
|
console.log();
|
|
9
9
|
console.log(
|
|
10
10
|
` ${chalk.yellow("This feature requires a Pro plan or your own Anthropic key.")}`
|
|
11
11
|
);
|
|
12
12
|
console.log(` Upgrade: ${chalk.cyan.underline("https://intentdocs.com/pricing")}`);
|
|
13
|
-
console.log(` Or add your key: ${chalk.cyan("intentdocs keys set")}`);
|
|
13
|
+
console.log(` Or add your key: ${chalk.cyan("npx intentdocs keys set")}`);
|
|
14
14
|
console.log();
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -66,14 +66,14 @@ async function requireValidAuth() {
|
|
|
66
66
|
if (result.valid) return result.auth;
|
|
67
67
|
switch (result.reason) {
|
|
68
68
|
case "no_file":
|
|
69
|
-
console.error("Not logged in \u2014 no auth credentials found. Run: intentdocs login");
|
|
69
|
+
console.error("Not logged in \u2014 no auth credentials found. Run: npx intentdocs login");
|
|
70
70
|
break;
|
|
71
71
|
case "revoked":
|
|
72
|
-
console.error("Your auth token has been revoked. Run: intentdocs login");
|
|
72
|
+
console.error("Your auth token has been revoked. Run: npx intentdocs login");
|
|
73
73
|
clearAuth();
|
|
74
74
|
break;
|
|
75
75
|
case "not_found":
|
|
76
|
-
console.error("Your auth token is no longer valid (it may have been deleted). Run: intentdocs login");
|
|
76
|
+
console.error("Your auth token is no longer valid (it may have been deleted). Run: npx intentdocs login");
|
|
77
77
|
clearAuth();
|
|
78
78
|
break;
|
|
79
79
|
case "network_error":
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isPlanGated,
|
|
3
3
|
printUpgradeMessage
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UQDMUKLP.js";
|
|
5
5
|
import {
|
|
6
6
|
matchesStoryRef
|
|
7
7
|
} from "./chunk-LQTPZL2Y.js";
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
apiUrl,
|
|
10
10
|
listStories,
|
|
11
11
|
syncHeaders
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-KTGQO3AE.js";
|
|
13
13
|
import {
|
|
14
14
|
requireConfig
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-K5SNF6CG.js";
|
|
16
|
+
import "./chunk-XZE2XP6O.js";
|
|
17
17
|
import "./chunk-UYTVTYNB.js";
|
|
18
18
|
|
|
19
19
|
// src/commands/complexity.ts
|
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isPlanGated,
|
|
3
3
|
printUpgradeMessage
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UQDMUKLP.js";
|
|
5
5
|
import {
|
|
6
6
|
apiUrl,
|
|
7
7
|
syncHeaders
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-KTGQO3AE.js";
|
|
9
9
|
import {
|
|
10
10
|
requireConfig
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-K5SNF6CG.js";
|
|
12
12
|
import {
|
|
13
13
|
closePrompt,
|
|
14
14
|
confirm
|
|
15
15
|
} from "./chunk-WRRUCCVZ.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-XZE2XP6O.js";
|
|
17
17
|
import "./chunk-UYTVTYNB.js";
|
|
18
18
|
|
|
19
19
|
// src/commands/import-prd.ts
|
|
20
20
|
import { readFileSync, existsSync } from "fs";
|
|
21
21
|
import ora from "ora";
|
|
22
|
-
async function importPrd(filePath) {
|
|
22
|
+
async function importPrd(filePath, opts = {}) {
|
|
23
23
|
const config = requireConfig();
|
|
24
|
+
if (!filePath && !opts.yes) {
|
|
25
|
+
console.error(" Reading the document from standard input leaves nothing to answer the confirmation with.");
|
|
26
|
+
console.error(" Pass a file to review before importing: npx intentdocs import prd.md");
|
|
27
|
+
console.error(" Or import without asking: npx intentdocs import --yes < prd.md");
|
|
28
|
+
process.exitCode = 1;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
24
31
|
let prdText;
|
|
25
32
|
let format = "PRD";
|
|
26
33
|
if (filePath) {
|
|
@@ -32,7 +39,7 @@ async function importPrd(filePath) {
|
|
|
32
39
|
if (filePath.endsWith(".md")) format = "Markdown";
|
|
33
40
|
else if (filePath.endsWith(".txt")) format = "text";
|
|
34
41
|
} else {
|
|
35
|
-
console.log(" Paste your PRD below (press Ctrl+D when done):\n");
|
|
42
|
+
if (process.stdin.isTTY) console.log(" Paste your PRD below (press Ctrl+D when done):\n");
|
|
36
43
|
const chunks = [];
|
|
37
44
|
for await (const chunk of process.stdin) {
|
|
38
45
|
chunks.push(chunk);
|
|
@@ -86,7 +93,7 @@ async function importPrd(filePath) {
|
|
|
86
93
|
}
|
|
87
94
|
console.log();
|
|
88
95
|
}
|
|
89
|
-
const doImport = await confirm(
|
|
96
|
+
const doImport = opts.yes ? true : await confirm(
|
|
90
97
|
` Import this story map structure?`
|
|
91
98
|
);
|
|
92
99
|
if (doImport) {
|