@taskless/cli 0.10.2 → 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 +65 -195
- package/dist/index.js +13167 -17243
- package/dist/prompts/index.d.ts +89 -0
- package/dist/prompts/recipes.d.ts +89 -0
- package/dist/prompts.js +53 -0
- package/dist/recipes-C_i98mTO.js +6975 -0
- package/dist/rules/capabilities.d.ts +311 -0
- package/dist/schemas/rules-create.d.ts +18 -0
- package/dist/schemas/rules-improve.d.ts +21 -0
- package/dist/util/invocation.d.ts +42 -0
- package/package.json +24 -13
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type RecipeOptions, type RecipeText } from "./recipes.js";
|
|
2
|
+
/**
|
|
3
|
+
* Public entry for `@taskless/cli/prompts`.
|
|
4
|
+
*
|
|
5
|
+
* Everything here renders through the same embedded recipe text and the same
|
|
6
|
+
* render path `taskless agent <topic>` serves, so the two surfaces cannot emit
|
|
7
|
+
* different guidance. Nothing in this graph reaches the CLI runtime: no citty
|
|
8
|
+
* command tree, no telemetry, no filesystem or network, so a Worker can import
|
|
9
|
+
* it without dragging the CLI in behind it.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Topics exported as public API. Hand-maintained rather than derived from the
|
|
13
|
+
* recipe files, because an exported name is a promise held for a major version
|
|
14
|
+
* and a new `agent/*.txt` must not be able to publish one by existing. The
|
|
15
|
+
* completeness check in `test/prompts.test.ts` asserts this list plus
|
|
16
|
+
* {@link INTERNAL_TOPICS} accounts for every canonical recipe on disk.
|
|
17
|
+
*
|
|
18
|
+
* The list starts at what a consumer has actually asked for and grows on
|
|
19
|
+
* demand. It is the authoring recipe for each engine a rule can be routed to,
|
|
20
|
+
* so a consumer that can decide a rule belongs to an engine can also reach the
|
|
21
|
+
* procedure for writing one. Exporting a chooser without its destinations
|
|
22
|
+
* reproduces, for the platform generator, the dead end this surface exists to
|
|
23
|
+
* remove.
|
|
24
|
+
*
|
|
25
|
+
* `engine-selection` used to be exported alongside them. It no longer exists:
|
|
26
|
+
* the criterion it carried now lives in `route`, stated once. `route` is not
|
|
27
|
+
* exported yet because it still contains local mechanics (`taskless detect`,
|
|
28
|
+
* on-device authoring) a Worker cannot run; until it is, a consumer gets each
|
|
29
|
+
* destination's own scope from these three and adjudicates genuinely ambiguous
|
|
30
|
+
* calls itself.
|
|
31
|
+
*/
|
|
32
|
+
export declare const TOPICS: readonly ["create-sg-rule", "create-vale-rule", "create-runtime-rule"];
|
|
33
|
+
/**
|
|
34
|
+
* Recipes deliberately withheld from the export, recorded so they stay visible
|
|
35
|
+
* decisions rather than oversights. Two groups:
|
|
36
|
+
*
|
|
37
|
+
* - Command recipes (`auth` … `update`) walk an agent through running a CLI
|
|
38
|
+
* subcommand on a developer's machine. There is no caller for them outside
|
|
39
|
+
* the CLI that hosts those commands.
|
|
40
|
+
* - Authoring recipes are unreachable server-side: `route` picks an authoring
|
|
41
|
+
* destination before the service is involved, `create-remote-rule` states
|
|
42
|
+
* the boundary from the client's side, `detect` documents a CLI subprocess a
|
|
43
|
+
* Worker cannot spawn, `create-legacy-rule` targets a local toolchain, and
|
|
44
|
+
* `rule-meta` reads an `improve-rule` sidecar file.
|
|
45
|
+
*/
|
|
46
|
+
export declare const INTERNAL_TOPICS: readonly ["auth", "check", "ci", "create-legacy-rule", "create-remote-rule", "delete-rule", "detect", "improve-rule", "info", "init", "onboard", "route", "rule", "rule-meta", "update", "verify-rule"];
|
|
47
|
+
/** A topic name the package exports. Unknown names fail to type-check. */
|
|
48
|
+
export type PromptTopic = (typeof TOPICS)[number];
|
|
49
|
+
/** Options accepted by every prompt render function. */
|
|
50
|
+
export type PromptOptions = RecipeOptions;
|
|
51
|
+
/**
|
|
52
|
+
* Render a prompt to finished text. Every `%(KEY)s` placeholder is resolved
|
|
53
|
+
* from values the package already holds, so the caller never handles a
|
|
54
|
+
* template dialect.
|
|
55
|
+
*
|
|
56
|
+
* @throws when the topic has no canonical recipe in the build, which means
|
|
57
|
+
* {@link TOPICS} and the recipe files have diverged.
|
|
58
|
+
*/
|
|
59
|
+
export declare function getPrompt(topic: PromptTopic, options?: PromptOptions): string;
|
|
60
|
+
/**
|
|
61
|
+
* A prompt's text together with the sprintf variable names its template
|
|
62
|
+
* contains. The names come from `sprintf-js`'s own parse, not from a pattern
|
|
63
|
+
* match over the text.
|
|
64
|
+
*/
|
|
65
|
+
export type Instructions = RecipeText;
|
|
66
|
+
/**
|
|
67
|
+
* Render a prompt and report which variables its template carries.
|
|
68
|
+
*
|
|
69
|
+
* `text` is byte-identical to {@link getPrompt} for the same arguments; the
|
|
70
|
+
* addition is `variables`, which tells a consumer what this topic's template
|
|
71
|
+
* was parameterized by without making them parse it.
|
|
72
|
+
*
|
|
73
|
+
* @throws when the topic has no canonical recipe in the build.
|
|
74
|
+
*/
|
|
75
|
+
export declare function getInstructions(topic: PromptTopic, options?: PromptOptions): Instructions;
|
|
76
|
+
/**
|
|
77
|
+
* The **unrendered** template for a prompt, plus the variables it contains.
|
|
78
|
+
*
|
|
79
|
+
* Use this when the host knows a value the package cannot: which launcher the
|
|
80
|
+
* reader will actually use, which package manager the target repository runs.
|
|
81
|
+
* Render it with `sprintf-js`'s named-argument form; the text is the source
|
|
82
|
+
* template verbatim, so its `%%` escapes are intact and it is safe to render
|
|
83
|
+
* exactly once.
|
|
84
|
+
*
|
|
85
|
+
* @throws when the topic has no canonical recipe in the build.
|
|
86
|
+
*/
|
|
87
|
+
export declare function getRawInstructions(topic: PromptTopic, options?: PromptOptions): Instructions;
|
|
88
|
+
/** Every exported topic as a render function, keyed by topic name. */
|
|
89
|
+
export declare const PROMPTS: Record<PromptTopic, (options?: PromptOptions) => string>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** The canonical `<topic>.txt` recipe names present in the build. */
|
|
2
|
+
export declare function canonicalRecipeTopics(): string[];
|
|
3
|
+
/** Options accepted by the shared render path. */
|
|
4
|
+
export interface RecipeOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Select the `.anonymous` variant of the topic, falling back to the
|
|
7
|
+
* canonical recipe when the topic has no variant.
|
|
8
|
+
*
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
anonymous?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Value substituted for the `%(PACKAGE_MANAGER_DLX)s` placeholder. The
|
|
14
|
+
* default is an agent-fill marker, which is the right answer whenever
|
|
15
|
+
* the caller does not know the consuming repo's package manager.
|
|
16
|
+
*
|
|
17
|
+
* @default "<package-manager-dlx>"
|
|
18
|
+
*/
|
|
19
|
+
packageManagerDlx?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Value substituted for the `%(TASKLESS_CLI)s` placeholder: the full command
|
|
22
|
+
* a reader would type to run this CLI, launcher and package specifier
|
|
23
|
+
* included (`npx @taskless/cli@latest`, `pnpm dlx @taskless/cli-nightly@…`).
|
|
24
|
+
*
|
|
25
|
+
* THIS IS AN ARGUMENT, NEVER AN AMBIENT READ. Detecting the launcher needs
|
|
26
|
+
* `process.argv` and `process.env`, and this module is imported by Workers
|
|
27
|
+
* without `nodejs_compat`, where a module-scope `process` read throws at
|
|
28
|
+
* import time. `assert-prompts-graph` in `vite.config.ts` would not catch it
|
|
29
|
+
* either — `process` is a global, not an import — so the constraint is kept
|
|
30
|
+
* by shape: the CLI detects and passes the value in (see
|
|
31
|
+
* `src/util/package-manager.ts`), and a host that imports
|
|
32
|
+
* `@taskless/cli/prompts` passes nothing and gets the marker.
|
|
33
|
+
*
|
|
34
|
+
* Omitting it falls back to this build's own invocation when the build is
|
|
35
|
+
* not prod, and to the agent-fill marker otherwise.
|
|
36
|
+
*
|
|
37
|
+
* @default "<taskless-cli>"
|
|
38
|
+
*/
|
|
39
|
+
invocation?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Include the `# Topic: <name> (CLI v<version> / topic vN)` first line.
|
|
42
|
+
* Suppressing it drops the CLI version from the text, which matters to
|
|
43
|
+
* an LLM consumer whose prompt-cache key would otherwise churn on every
|
|
44
|
+
* CLI publish.
|
|
45
|
+
*
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
header?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Render a recipe by interpolating sprintf-js named arguments. The recipe
|
|
52
|
+
* source uses `%(KEY)s` placeholders; the variable table built here resolves
|
|
53
|
+
* each known placeholder to its rendered string. Recipes that contain a
|
|
54
|
+
* literal `%` character must escape it as `%%` per sprintf-js conventions.
|
|
55
|
+
*
|
|
56
|
+
* Two flavors of substitution coexist in the variables table:
|
|
57
|
+
* - System-resolved values (e.g. `CLI_VERSION`) — rendered to a real value.
|
|
58
|
+
* - Agent-fill markers (e.g. `PACKAGE_MANAGER_DLX`) — rendered as
|
|
59
|
+
* `<lower-kebab-name>` so the consuming agent knows to substitute.
|
|
60
|
+
*/
|
|
61
|
+
export declare function buildVariables(content: string, topic: string, options?: RecipeOptions): Record<string, string>;
|
|
62
|
+
/** A recipe's text plus the sprintf variables its template contains. */
|
|
63
|
+
export interface RecipeText {
|
|
64
|
+
text: string;
|
|
65
|
+
variables: string[];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Look up an agent recipe topic from the embedded recipe map and return the rendered
|
|
69
|
+
* text. Anonymous variants are preferred when `anonymous` is set and a
|
|
70
|
+
* variant exists; otherwise the canonical recipe is returned. Returns
|
|
71
|
+
* `undefined` when the topic is unknown.
|
|
72
|
+
*/
|
|
73
|
+
export declare function getRecipe(topic: string, options?: RecipeOptions): string | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* The **unrendered** template for a topic, plus the variables it contains.
|
|
76
|
+
*
|
|
77
|
+
* `text` is the source recipe with the build-target invocation rewrite applied
|
|
78
|
+
* and nothing else. The rewrite belongs here: it is build-target substitution
|
|
79
|
+
* rather than templating, and omitting it would make the raw text render to
|
|
80
|
+
* something the CLI never emits. Every `%(KEY)s` is left standing so a host
|
|
81
|
+
* that knows a value this package cannot know — its own launcher, its own
|
|
82
|
+
* package manager — can render the text itself.
|
|
83
|
+
*
|
|
84
|
+
* Returns `undefined` for an unknown topic, matching {@link getRecipe}. The
|
|
85
|
+
* public accessors in `./index.ts` turn that into a throw.
|
|
86
|
+
*/
|
|
87
|
+
export declare function getRawRecipe(topic: string, options?: RecipeOptions): RecipeText | undefined;
|
|
88
|
+
/** A topic's rendered text plus the variables its template contains. */
|
|
89
|
+
export declare function getRenderedRecipe(topic: string, options?: RecipeOptions): RecipeText | undefined;
|
package/dist/prompts.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { H as n, a6 as i, a7 as u } from "./recipes-C_i98mTO.js";
|
|
2
|
+
const a = [
|
|
3
|
+
"create-sg-rule",
|
|
4
|
+
"create-vale-rule",
|
|
5
|
+
"create-runtime-rule"
|
|
6
|
+
], s = [
|
|
7
|
+
"auth",
|
|
8
|
+
"check",
|
|
9
|
+
"ci",
|
|
10
|
+
"create-legacy-rule",
|
|
11
|
+
"create-remote-rule",
|
|
12
|
+
"delete-rule",
|
|
13
|
+
"detect",
|
|
14
|
+
"improve-rule",
|
|
15
|
+
"info",
|
|
16
|
+
"init",
|
|
17
|
+
"onboard",
|
|
18
|
+
"route",
|
|
19
|
+
"rule",
|
|
20
|
+
"rule-meta",
|
|
21
|
+
"update",
|
|
22
|
+
"verify-rule"
|
|
23
|
+
];
|
|
24
|
+
function o(e, r) {
|
|
25
|
+
return t(n(e, r), e);
|
|
26
|
+
}
|
|
27
|
+
function l(e, r) {
|
|
28
|
+
return t(i(e, r), e);
|
|
29
|
+
}
|
|
30
|
+
function d(e, r) {
|
|
31
|
+
return t(u(e, r), e);
|
|
32
|
+
}
|
|
33
|
+
function t(e, r) {
|
|
34
|
+
if (e === void 0)
|
|
35
|
+
throw new Error(
|
|
36
|
+
`No recipe is embedded for prompt topic "${r}". This is a packaging fault: TOPICS lists a topic with no agent/${r}.txt behind it.`
|
|
37
|
+
);
|
|
38
|
+
return e;
|
|
39
|
+
}
|
|
40
|
+
const f = Object.fromEntries(
|
|
41
|
+
a.map((e) => [
|
|
42
|
+
e,
|
|
43
|
+
(r) => o(e, r)
|
|
44
|
+
])
|
|
45
|
+
);
|
|
46
|
+
export {
|
|
47
|
+
s as INTERNAL_TOPICS,
|
|
48
|
+
f as PROMPTS,
|
|
49
|
+
a as TOPICS,
|
|
50
|
+
l as getInstructions,
|
|
51
|
+
o as getPrompt,
|
|
52
|
+
d as getRawInstructions
|
|
53
|
+
};
|