@acrylblends/system-prompt 0.0.0-stage → 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.
package/README.md CHANGED
@@ -1,3 +1,15 @@
1
- # Temporary Holding Version
1
+ # acryl-system-prompt
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ACRYL's shaping of the system prompt, in the shape pi.dev builds its own (`packages/coding-agent/src/core/system-prompt.ts`): one identity line, then
4
+ every section as a tagged block. It is a pass-through on the harness's `system-prompt/assemble` waterfall: only the identity line is replaced, sections
5
+ are tagged and empties dropped, and every other section keeps its upstream text, so harness updates still reach the model. It records what upstream
6
+ contributed so a harness update shows exactly what changed (`drift/`). See `docs/system-prompt/README.md` in the repository for where the whole prompt
7
+ comes from and how to change it.
8
+
9
+ It also adds one section of its own, the reply style (`acryl:reply-style`, tagged `<reply_style>`): plain, short sentences and no em dash.
10
+
11
+ Config (row `acryl-system-prompt`): `identity` (the opening line; ACRYL's by default, and every ACRYL Blends app's composition sets the Blends
12
+ one), `style` (the reply style; empty leaves it out), `tagSections`, `dropEmpty`.
13
+
14
+ Source: `src/index.ts` (the plugin) and `src/transform.ts` (the pure shaping, also exported as `acryl-system-prompt/transform`). One package
15
+ for ACRYL and for the Blends frame, which publishes it as `@acrylblends/system-prompt` (spec 051).
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: acryl-system-prompt
3
+ name: '@acrylblends/system-prompt'
@@ -0,0 +1,10 @@
1
+ {
2
+ "web": {
3
+ "systemChars": 8900,
4
+ "toolsChars": 31200
5
+ },
6
+ "cli": {
7
+ "systemChars": 5800,
8
+ "toolsChars": 21700
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "web": {
3
+ "systemChars": 9100,
4
+ "toolsChars": 32400
5
+ },
6
+ "cli": {
7
+ "systemChars": 6000,
8
+ "toolsChars": 22900
9
+ }
10
+ }
package/drift/cli.json ADDED
@@ -0,0 +1,70 @@
1
+ [
2
+ {
3
+ "name": "harness:identity",
4
+ "hash": "1dd6363fa551"
5
+ },
6
+ {
7
+ "name": "deployment:persona-prefix",
8
+ "hash": "e3b0c44298fc"
9
+ },
10
+ {
11
+ "name": "plan:policy",
12
+ "hash": "e3b0c44298fc"
13
+ },
14
+ {
15
+ "name": "tool:bash",
16
+ "hash": "647bd85ba2e8"
17
+ },
18
+ {
19
+ "name": "tool:read",
20
+ "hash": "4a23d2ec84aa"
21
+ },
22
+ {
23
+ "name": "tool:write",
24
+ "hash": "06221af32d81"
25
+ },
26
+ {
27
+ "name": "tool:edit",
28
+ "hash": "89df623d3529"
29
+ },
30
+ {
31
+ "name": "tool:glob",
32
+ "hash": "2a21a1ccfe63"
33
+ },
34
+ {
35
+ "name": "tool:grep",
36
+ "hash": "5cf488ba882d"
37
+ },
38
+ {
39
+ "name": "tool:jobs",
40
+ "hash": "ba71da85048b"
41
+ },
42
+ {
43
+ "name": "tool:web_search",
44
+ "hash": "4142c297778f"
45
+ },
46
+ {
47
+ "name": "tool:web_fetch",
48
+ "hash": "4fe4c0ce663c"
49
+ },
50
+ {
51
+ "name": "tool:goal",
52
+ "hash": "ebf10b6ae984"
53
+ },
54
+ {
55
+ "name": "tool:workflow",
56
+ "hash": "4e6240cecbf5"
57
+ },
58
+ {
59
+ "name": "tool:subagent",
60
+ "hash": "7f02d244c70b"
61
+ },
62
+ {
63
+ "name": "mcp-resource-servers",
64
+ "hash": "e3b0c44298fc"
65
+ },
66
+ {
67
+ "name": "deployment:persona-suffix",
68
+ "hash": "e3b0c44298fc"
69
+ }
70
+ ]
@@ -0,0 +1,70 @@
1
+ [
2
+ {
3
+ "name": "harness:identity",
4
+ "hash": "1dd6363fa551"
5
+ },
6
+ {
7
+ "name": "deployment:persona-prefix",
8
+ "hash": "e3b0c44298fc"
9
+ },
10
+ {
11
+ "name": "plan:policy",
12
+ "hash": "e3b0c44298fc"
13
+ },
14
+ {
15
+ "name": "tool:pwsh",
16
+ "hash": "c01abf413b19"
17
+ },
18
+ {
19
+ "name": "tool:read",
20
+ "hash": "4a23d2ec84aa"
21
+ },
22
+ {
23
+ "name": "tool:write",
24
+ "hash": "06221af32d81"
25
+ },
26
+ {
27
+ "name": "tool:edit",
28
+ "hash": "89df623d3529"
29
+ },
30
+ {
31
+ "name": "tool:glob",
32
+ "hash": "2a21a1ccfe63"
33
+ },
34
+ {
35
+ "name": "tool:grep",
36
+ "hash": "5cf488ba882d"
37
+ },
38
+ {
39
+ "name": "tool:jobs",
40
+ "hash": "ba71da85048b"
41
+ },
42
+ {
43
+ "name": "tool:web_search",
44
+ "hash": "4142c297778f"
45
+ },
46
+ {
47
+ "name": "tool:web_fetch",
48
+ "hash": "4fe4c0ce663c"
49
+ },
50
+ {
51
+ "name": "tool:goal",
52
+ "hash": "ebf10b6ae984"
53
+ },
54
+ {
55
+ "name": "tool:workflow",
56
+ "hash": "4e6240cecbf5"
57
+ },
58
+ {
59
+ "name": "tool:subagent",
60
+ "hash": "7f02d244c70b"
61
+ },
62
+ {
63
+ "name": "mcp-resource-servers",
64
+ "hash": "e3b0c44298fc"
65
+ },
66
+ {
67
+ "name": "deployment:persona-suffix",
68
+ "hash": "e3b0c44298fc"
69
+ }
70
+ ]
package/drift/web.json ADDED
@@ -0,0 +1,90 @@
1
+ [
2
+ {
3
+ "name": "harness:identity",
4
+ "hash": "1dd6363fa551"
5
+ },
6
+ {
7
+ "name": "deployment:persona-prefix",
8
+ "hash": "e0eb4484e486"
9
+ },
10
+ {
11
+ "name": "plan:policy",
12
+ "hash": "e3b0c44298fc"
13
+ },
14
+ {
15
+ "name": "context:file-reference",
16
+ "hash": "63738afd0d9f"
17
+ },
18
+ {
19
+ "name": "tool:bash",
20
+ "hash": "647bd85ba2e8"
21
+ },
22
+ {
23
+ "name": "tool:read",
24
+ "hash": "4a23d2ec84aa"
25
+ },
26
+ {
27
+ "name": "tool:write",
28
+ "hash": "06221af32d81"
29
+ },
30
+ {
31
+ "name": "tool:edit",
32
+ "hash": "89df623d3529"
33
+ },
34
+ {
35
+ "name": "tool:glob",
36
+ "hash": "2a21a1ccfe63"
37
+ },
38
+ {
39
+ "name": "tool:grep",
40
+ "hash": "5cf488ba882d"
41
+ },
42
+ {
43
+ "name": "tool:jobs",
44
+ "hash": "ba71da85048b"
45
+ },
46
+ {
47
+ "name": "tool:web_search",
48
+ "hash": "4142c297778f"
49
+ },
50
+ {
51
+ "name": "tool:web_fetch",
52
+ "hash": "4fe4c0ce663c"
53
+ },
54
+ {
55
+ "name": "tool:goal",
56
+ "hash": "ebf10b6ae984"
57
+ },
58
+ {
59
+ "name": "tool:workflow",
60
+ "hash": "4e6240cecbf5"
61
+ },
62
+ {
63
+ "name": "tool:subagent",
64
+ "hash": "7f02d244c70b"
65
+ },
66
+ {
67
+ "name": "tool:subagent_fork",
68
+ "hash": "762559ae5281"
69
+ },
70
+ {
71
+ "name": "mcp-resource-servers",
72
+ "hash": "e3b0c44298fc"
73
+ },
74
+ {
75
+ "name": "ui:deliverable-file-references",
76
+ "hash": "e8a2eb8da7f6"
77
+ },
78
+ {
79
+ "name": "harness:source",
80
+ "hash": "414d63a35846"
81
+ },
82
+ {
83
+ "name": "app:web-surface",
84
+ "hash": "103429ae00b5"
85
+ },
86
+ {
87
+ "name": "deployment:persona-suffix",
88
+ "hash": "3484a8eb5011"
89
+ }
90
+ ]
@@ -0,0 +1,90 @@
1
+ [
2
+ {
3
+ "name": "harness:identity",
4
+ "hash": "1dd6363fa551"
5
+ },
6
+ {
7
+ "name": "deployment:persona-prefix",
8
+ "hash": "e0eb4484e486"
9
+ },
10
+ {
11
+ "name": "plan:policy",
12
+ "hash": "e3b0c44298fc"
13
+ },
14
+ {
15
+ "name": "context:file-reference",
16
+ "hash": "63738afd0d9f"
17
+ },
18
+ {
19
+ "name": "tool:pwsh",
20
+ "hash": "c01abf413b19"
21
+ },
22
+ {
23
+ "name": "tool:read",
24
+ "hash": "4a23d2ec84aa"
25
+ },
26
+ {
27
+ "name": "tool:write",
28
+ "hash": "06221af32d81"
29
+ },
30
+ {
31
+ "name": "tool:edit",
32
+ "hash": "89df623d3529"
33
+ },
34
+ {
35
+ "name": "tool:glob",
36
+ "hash": "2a21a1ccfe63"
37
+ },
38
+ {
39
+ "name": "tool:grep",
40
+ "hash": "5cf488ba882d"
41
+ },
42
+ {
43
+ "name": "tool:jobs",
44
+ "hash": "ba71da85048b"
45
+ },
46
+ {
47
+ "name": "tool:web_search",
48
+ "hash": "4142c297778f"
49
+ },
50
+ {
51
+ "name": "tool:web_fetch",
52
+ "hash": "4fe4c0ce663c"
53
+ },
54
+ {
55
+ "name": "tool:goal",
56
+ "hash": "ebf10b6ae984"
57
+ },
58
+ {
59
+ "name": "tool:workflow",
60
+ "hash": "4e6240cecbf5"
61
+ },
62
+ {
63
+ "name": "tool:subagent",
64
+ "hash": "7f02d244c70b"
65
+ },
66
+ {
67
+ "name": "tool:subagent_fork",
68
+ "hash": "762559ae5281"
69
+ },
70
+ {
71
+ "name": "mcp-resource-servers",
72
+ "hash": "e3b0c44298fc"
73
+ },
74
+ {
75
+ "name": "ui:deliverable-file-references",
76
+ "hash": "e8a2eb8da7f6"
77
+ },
78
+ {
79
+ "name": "harness:source",
80
+ "hash": "87454d47e42c"
81
+ },
82
+ {
83
+ "name": "app:web-surface",
84
+ "hash": "103429ae00b5"
85
+ },
86
+ {
87
+ "name": "deployment:persona-suffix",
88
+ "hash": "3484a8eb5011"
89
+ }
90
+ ]
package/lib/index.js ADDED
@@ -0,0 +1,33 @@
1
+ import { DEFAULT_IDENTITY, DEFAULT_STYLE, STYLE_SECTION, shapeSections, upstreamSnapshot } from "./transform.js";
2
+ import Schema from "@deepseek-ai/schemastery";
3
+ //#region src/index.ts
4
+ const name = "@acrylblends/system-prompt";
5
+ const inject = ["systemPrompt"];
6
+ const Config = Schema.object({
7
+ identity: Schema.string().default(DEFAULT_IDENTITY).description("The opening identity line (replaces the harness \"You are an AI agent powered by ...\" line)."),
8
+ style: Schema.string().default(DEFAULT_STYLE).description("How the agent writes its replies; empty leaves the section out."),
9
+ tagSections: Schema.boolean().default(true).description("Wrap every section in a pi.dev-style tag."),
10
+ dropEmpty: Schema.boolean().default(true).description("Drop sections with no text.")
11
+ });
12
+ function apply(ctx, config) {
13
+ let upstream = [];
14
+ ctx.provide("acrylSystemPrompt", { lastUpstream: () => upstream });
15
+ const systemPrompt = ctx.systemPrompt;
16
+ if (config.style.trim() !== "") ctx.effect(() => systemPrompt.section({
17
+ ...STYLE_SECTION,
18
+ text: config.style
19
+ }), "acryl-system-prompt: reply style");
20
+ const on = ctx.on.bind(ctx);
21
+ ctx.effect(() => on("system-prompt/assemble", async (_assembly, _context, next) => {
22
+ const assembled = await next();
23
+ upstream = upstreamSnapshot(assembled.sections);
24
+ return {
25
+ ...assembled,
26
+ sections: shapeSections(assembled.sections, config)
27
+ };
28
+ }), "acryl-system-prompt: assemble listener");
29
+ }
30
+ //#endregion
31
+ export { Config, apply, inject, name };
32
+
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * ACRYL system prompt shaping (ACRYL spec 037, pi.dev-like prompt). pi.dev owns one builder function that produces a structured, tagged prompt; the\n * frame composes its agent's prompt from the harness's sections (a pinned upstream we do not fork), so this plugin applies the same shape as a\n * pass-through: on the harness's `system-prompt/assemble` waterfall it puts the identity first, wraps every other section in a tag, drops empty ones,\n * and records what upstream contributed so a harness update shows exactly what changed. It rewrites nothing else.\n *\n * It also contributes one section of its own, the reply style (`acryl:reply-style`, tagged `<reply_style>`): plain words and no em dash.\n *\n * Provides: `acrylSystemPrompt` ({ lastUpstream() }) and the reply style section. Requires: `systemPrompt`.\n */\nimport type { Context } from '@deepseek-ai/cordis'\nimport Schema from '@deepseek-ai/schemastery'\nimport { DEFAULT_IDENTITY, DEFAULT_STYLE, type PromptSection, STYLE_SECTION, shapeSections, upstreamSnapshot } from './transform.ts'\n\nexport const name = 'acryl-system-prompt'\nexport const inject = ['systemPrompt']\n\nexport interface Config {\n identity: string\n style: string\n tagSections: boolean\n dropEmpty: boolean\n}\n\nexport const Config: Schema<Config> = Schema.object({\n identity: Schema.string().default(DEFAULT_IDENTITY).description('The opening identity line (replaces the harness \"You are an AI agent powered by ...\" line).'),\n style: Schema.string().default(DEFAULT_STYLE).description('How the agent writes its replies; empty leaves the section out.'),\n tagSections: Schema.boolean().default(true).description('Wrap every section in a pi.dev-style tag.'),\n dropEmpty: Schema.boolean().default(true).description('Drop sections with no text.'),\n})\n\n/** The assembled prompt as the waterfall passes it: its sections, and whatever else the harness carries, kept as it is. */\ninterface Assembled {\n readonly sections: readonly PromptSection[]\n}\n\ninterface SystemPrompt {\n section(section: { name: string; order: number; text: string }): () => void\n}\n\ntype AssembleListener = (assembly: unknown, context: unknown, next: () => Promise<Assembled>) => Promise<Assembled>\n\nexport function apply(ctx: Context, config: Config): void {\n let upstream: { name: string; hash: string }[] = []\n ctx.provide('acrylSystemPrompt', { lastUpstream: () => upstream })\n const systemPrompt = (ctx as unknown as { systemPrompt: SystemPrompt }).systemPrompt\n if (config.style.trim() !== '')\n ctx.effect(() => systemPrompt.section({ ...STYLE_SECTION, text: config.style }), 'acryl-system-prompt: reply style')\n const on = ctx.on.bind(ctx) as unknown as (name: 'system-prompt/assemble', listener: AssembleListener) => () => void\n ctx.effect(() => on('system-prompt/assemble', async (_assembly, _context, next) => {\n const assembled = await next()\n upstream = upstreamSnapshot(assembled.sections)\n return { ...assembled, sections: shapeSections(assembled.sections, config) }\n }), 'acryl-system-prompt: assemble listener')\n}\n"],"mappings":";;;AAcA,MAAa,OAAO;AACpB,MAAa,SAAS,CAAC,cAAc;AASrC,MAAa,SAAyB,OAAO,OAAO;CAClD,UAAU,OAAO,OAAO,CAAC,CAAC,QAAQ,gBAAgB,CAAC,CAAC,YAAY,+FAA6F;CAC7J,OAAO,OAAO,OAAO,CAAC,CAAC,QAAQ,aAAa,CAAC,CAAC,YAAY,iEAAiE;CAC3H,aAAa,OAAO,QAAQ,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,YAAY,2CAA2C;CACnG,WAAW,OAAO,QAAQ,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,YAAY,6BAA6B;AACrF,CAAC;AAaD,SAAgB,MAAM,KAAc,QAAsB;CACxD,IAAI,WAA6C,CAAC;CAClD,IAAI,QAAQ,qBAAqB,EAAE,oBAAoB,SAAS,CAAC;CACjE,MAAM,eAAgB,IAAkD;CACxE,IAAI,OAAO,MAAM,KAAK,MAAM,IAC1B,IAAI,aAAa,aAAa,QAAQ;EAAE,GAAG;EAAe,MAAM,OAAO;CAAM,CAAC,GAAG,kCAAkC;CACrH,MAAM,KAAK,IAAI,GAAG,KAAK,GAAG;CAC1B,IAAI,aAAa,GAAG,0BAA0B,OAAO,WAAW,UAAU,SAAS;EACjF,MAAM,YAAY,MAAM,KAAK;EAC7B,WAAW,iBAAiB,UAAU,QAAQ;EAC9C,OAAO;GAAE,GAAG;GAAW,UAAU,cAAc,UAAU,UAAU,MAAM;EAAE;CAC7E,CAAC,GAAG,wCAAwC;AAC9C"}
@@ -0,0 +1,89 @@
1
+ import { createHash } from "node:crypto";
2
+ //#region src/transform.ts
3
+ /**
4
+ * pi.dev opens its prompt with one identity line ("You are an expert coding assistant operating inside pi, ..."). This is ACRYL's; a product built
5
+ * on ACRYL passes its own line through the plugin's `identity` config (the Blends frame does, in every app's composition).
6
+ */
7
+ const DEFAULT_IDENTITY = "You are an expert coding assistant operating inside ACRYL, a coding agent harness that can extend itself with plugins. You help users by reading files, executing commands, editing code, and writing new files, and by building, changing and removing ACRYL extensions when asked.";
8
+ /**
9
+ * How the agent writes its replies to the person: plain words, short, and with a plain dash instead of an em dash (the owner's rule for everything
10
+ * ACRYL writes, which a model otherwise breaks in nearly every answer).
11
+ */
12
+ const DEFAULT_STYLE = "Write replies in plain, short sentences the person can act on. Never use the em dash character (U+2014) or the en dash (U+2013) in replies, code comments or files you write; use a plain hyphen-minus (-) or a comma instead.";
13
+ /** The reply style's section: right after the identity line (the harness identity is -1000, the deployment persona 0). */
14
+ const STYLE_SECTION = {
15
+ name: "acryl:reply-style",
16
+ order: -900
17
+ };
18
+ /** Section names the harness registers for its identity line. */
19
+ const IDENTITY_SECTION = "harness:identity";
20
+ /** Readable tag names for sections whose harness name is not tag-friendly (pi.dev uses tags such as `docs`, `cwd`, `skills`). */
21
+ const TAG_ALIASES = {
22
+ "deployment:persona-prefix": "persona",
23
+ "deployment:persona-suffix": "cwd",
24
+ "acryl:plugin-router": "acryl_plugin_docs",
25
+ "acryl:reply-style": "reply_style"
26
+ };
27
+ /** `tool:read` becomes `tool_read`; anything outside `[a-z0-9_-]` becomes `_`, and a tag never starts with a digit or separator. */
28
+ function tagName(sectionName) {
29
+ const alias = TAG_ALIASES[sectionName];
30
+ if (alias !== void 0) return alias;
31
+ const tag = sectionName.toLowerCase().replace(/[^a-z0-9_-]+/gu, "_").replace(/^[^a-z]+/u, "").replace(/_+$/u, "");
32
+ return tag === "" ? "section" : tag;
33
+ }
34
+ /** A section whose text already is one complete tagged block (the plugin docs router carries its own tag). */
35
+ const alreadyTagged = (text) => /^<([a-z][a-z0-9_-]*)>[\s\S]*<\/\1>\s*$/u.test(text.trim());
36
+ /**
37
+ * Shape the harness's assembled sections the way pi.dev's `buildSystemPromptSections` shapes its own: an untagged opening identity line,
38
+ * then every other section as a tagged block, with empty sections dropped. Nothing else is rewritten: every section that is not the
39
+ * identity passes through with its upstream text unchanged, so upstream improvements to tool guidance still reach the model.
40
+ * @param sections - upstream sections in final order.
41
+ */
42
+ function shapeSections(sections, options = {}) {
43
+ const identity = options.identity ?? "You are an expert coding assistant operating inside ACRYL, a coding agent harness that can extend itself with plugins. You help users by reading files, executing commands, editing code, and writing new files, and by building, changing and removing ACRYL extensions when asked.";
44
+ const tagSections = options.tagSections ?? true;
45
+ const dropEmpty = options.dropEmpty ?? true;
46
+ const out = [];
47
+ for (const section of sections) {
48
+ if (section.name === "harness:identity") {
49
+ out.push({
50
+ name: section.name,
51
+ text: identity
52
+ });
53
+ continue;
54
+ }
55
+ const text = String(section.text ?? "");
56
+ if (dropEmpty && text.trim() === "") continue;
57
+ if (!tagSections || alreadyTagged(text)) {
58
+ out.push({
59
+ name: section.name,
60
+ text
61
+ });
62
+ continue;
63
+ }
64
+ const tag = tagName(section.name);
65
+ out.push({
66
+ name: section.name,
67
+ text: `<${tag}>\n${text.trim()}\n</${tag}>`
68
+ });
69
+ }
70
+ return out;
71
+ }
72
+ /** Text that legitimately differs per run (the web surface section names its random local port) must not look like drift. */
73
+ function normalizeVolatile(text) {
74
+ return String(text ?? "").replace(/\b(127\.0\.0\.1|localhost|0\.0\.0\.0):\d+/gu, "$1:<port>");
75
+ }
76
+ /**
77
+ * What upstream contributed, for drift detection: name and a short hash of the text, excluding ACRYL's own sections (they carry
78
+ * machine-specific paths and are ours to change). Variables such as `{{cwd}}` are not yet interpolated at this stage, so the hashes are stable.
79
+ */
80
+ function upstreamSnapshot(sections) {
81
+ return sections.filter((section) => !section.name.startsWith("acryl:")).map((section) => ({
82
+ name: section.name,
83
+ hash: createHash("sha256").update(normalizeVolatile(section.text)).digest("hex").slice(0, 12)
84
+ }));
85
+ }
86
+ //#endregion
87
+ export { DEFAULT_IDENTITY, DEFAULT_STYLE, IDENTITY_SECTION, STYLE_SECTION, normalizeVolatile, shapeSections, tagName, upstreamSnapshot };
88
+
89
+ //# sourceMappingURL=transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.js","names":[],"sources":["../src/transform.ts"],"sourcesContent":["import { createHash } from 'node:crypto'\n\n/**\n * pi.dev opens its prompt with one identity line (\"You are an expert coding assistant operating inside pi, ...\"). This is ACRYL's; a product built\n * on ACRYL passes its own line through the plugin's `identity` config (the Blends frame does, in every app's composition).\n */\nexport const DEFAULT_IDENTITY =\n 'You are an expert coding assistant operating inside ACRYL, a coding agent harness that can extend itself with plugins. You help users by reading files, executing commands, editing code, and writing new files, and by building, changing and removing ACRYL extensions when asked.'\n\n/**\n * How the agent writes its replies to the person: plain words, short, and with a plain dash instead of an em dash (the owner's rule for everything\n * ACRYL writes, which a model otherwise breaks in nearly every answer).\n */\nexport const DEFAULT_STYLE =\n 'Write replies in plain, short sentences the person can act on. Never use the em dash character (U+2014) or the en dash (U+2013) in replies, code comments or files you write; use a plain hyphen-minus (-) or a comma instead.'\n\n/** The reply style's section: right after the identity line (the harness identity is -1000, the deployment persona 0). */\nexport const STYLE_SECTION = { name: 'acryl:reply-style', order: -900 } as const\n\n/** Section names the harness registers for its identity line. */\nexport const IDENTITY_SECTION = 'harness:identity'\n\n/** Readable tag names for sections whose harness name is not tag-friendly (pi.dev uses tags such as `docs`, `cwd`, `skills`). */\nconst TAG_ALIASES: Readonly<Record<string, string>> = {\n 'deployment:persona-prefix': 'persona',\n 'deployment:persona-suffix': 'cwd',\n 'acryl:plugin-router': 'acryl_plugin_docs',\n 'acryl:reply-style': 'reply_style',\n}\n\n/** One section of the assembled prompt, as the harness's `system-prompt/assemble` waterfall carries it. */\nexport interface PromptSection {\n readonly name: string\n readonly text: string\n}\n\nexport interface ShapeOptions {\n readonly identity?: string\n readonly tagSections?: boolean\n readonly dropEmpty?: boolean\n}\n\n/** `tool:read` becomes `tool_read`; anything outside `[a-z0-9_-]` becomes `_`, and a tag never starts with a digit or separator. */\nexport function tagName(sectionName: string): string {\n const alias = TAG_ALIASES[sectionName]\n if (alias !== undefined) return alias\n const tag = sectionName.toLowerCase().replace(/[^a-z0-9_-]+/gu, '_').replace(/^[^a-z]+/u, '').replace(/_+$/u, '')\n return tag === '' ? 'section' : tag\n}\n\n/** A section whose text already is one complete tagged block (the plugin docs router carries its own tag). */\nconst alreadyTagged = (text: string): boolean => /^<([a-z][a-z0-9_-]*)>[\\s\\S]*<\\/\\1>\\s*$/u.test(text.trim())\n\n/**\n * Shape the harness's assembled sections the way pi.dev's `buildSystemPromptSections` shapes its own: an untagged opening identity line,\n * then every other section as a tagged block, with empty sections dropped. Nothing else is rewritten: every section that is not the\n * identity passes through with its upstream text unchanged, so upstream improvements to tool guidance still reach the model.\n * @param sections - upstream sections in final order.\n */\nexport function shapeSections(sections: readonly PromptSection[], options: ShapeOptions = {}): PromptSection[] {\n const identity = options.identity ?? DEFAULT_IDENTITY\n const tagSections = options.tagSections ?? true\n const dropEmpty = options.dropEmpty ?? true\n const out: PromptSection[] = []\n for (const section of sections) {\n if (section.name === IDENTITY_SECTION) {\n out.push({ name: section.name, text: identity })\n continue\n }\n const text = String(section.text ?? '')\n if (dropEmpty && text.trim() === '') continue\n if (!tagSections || alreadyTagged(text)) {\n out.push({ name: section.name, text })\n continue\n }\n const tag = tagName(section.name)\n out.push({ name: section.name, text: `<${tag}>\\n${text.trim()}\\n</${tag}>` })\n }\n return out\n}\n\n/** Text that legitimately differs per run (the web surface section names its random local port) must not look like drift. */\nexport function normalizeVolatile(text: string): string {\n return String(text ?? '').replace(/\\b(127\\.0\\.0\\.1|localhost|0\\.0\\.0\\.0):\\d+/gu, '$1:<port>')\n}\n\n/**\n * What upstream contributed, for drift detection: name and a short hash of the text, excluding ACRYL's own sections (they carry\n * machine-specific paths and are ours to change). Variables such as `{{cwd}}` are not yet interpolated at this stage, so the hashes are stable.\n */\nexport function upstreamSnapshot(sections: readonly PromptSection[]): { name: string; hash: string }[] {\n return sections\n .filter(section => !section.name.startsWith('acryl:'))\n .map(section => ({ name: section.name, hash: createHash('sha256').update(normalizeVolatile(section.text)).digest('hex').slice(0, 12) }))\n}\n"],"mappings":";;;;;;AAMA,MAAa,mBACX;;;;;AAMF,MAAa,gBACX;;AAGF,MAAa,gBAAgB;CAAE,MAAM;CAAqB,OAAO;AAAK;;AAGtE,MAAa,mBAAmB;;AAGhC,MAAM,cAAgD;CACpD,6BAA6B;CAC7B,6BAA6B;CAC7B,uBAAuB;CACvB,qBAAqB;AACvB;;AAeA,SAAgB,QAAQ,aAA6B;CACnD,MAAM,QAAQ,YAAY;CAC1B,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,MAAM,MAAM,YAAY,YAAY,CAAC,CAAC,QAAQ,kBAAkB,GAAG,CAAC,CAAC,QAAQ,aAAa,EAAE,CAAC,CAAC,QAAQ,QAAQ,EAAE;CAChH,OAAO,QAAQ,KAAK,YAAY;AAClC;;AAGA,MAAM,iBAAiB,SAA0B,0CAA0C,KAAK,KAAK,KAAK,CAAC;;;;;;;AAQ3G,SAAgB,cAAc,UAAoC,UAAwB,CAAC,GAAoB;CAC7G,MAAM,WAAW,QAAQ,YAAA;CACzB,MAAM,cAAc,QAAQ,eAAe;CAC3C,MAAM,YAAY,QAAQ,aAAa;CACvC,MAAM,MAAuB,CAAC;CAC9B,KAAK,MAAM,WAAW,UAAU;EAC9B,IAAI,QAAQ,SAAA,oBAA2B;GACrC,IAAI,KAAK;IAAE,MAAM,QAAQ;IAAM,MAAM;GAAS,CAAC;GAC/C;EACF;EACA,MAAM,OAAO,OAAO,QAAQ,QAAQ,EAAE;EACtC,IAAI,aAAa,KAAK,KAAK,MAAM,IAAI;EACrC,IAAI,CAAC,eAAe,cAAc,IAAI,GAAG;GACvC,IAAI,KAAK;IAAE,MAAM,QAAQ;IAAM;GAAK,CAAC;GACrC;EACF;EACA,MAAM,MAAM,QAAQ,QAAQ,IAAI;EAChC,IAAI,KAAK;GAAE,MAAM,QAAQ;GAAM,MAAM,IAAI,IAAI,KAAK,KAAK,KAAK,EAAE,MAAM,IAAI;EAAG,CAAC;CAC9E;CACA,OAAO;AACT;;AAGA,SAAgB,kBAAkB,MAAsB;CACtD,OAAO,OAAO,QAAQ,EAAE,CAAC,CAAC,QAAQ,+CAA+C,WAAW;AAC9F;;;;;AAMA,SAAgB,iBAAiB,UAAsE;CACrG,OAAO,SACJ,QAAO,YAAW,CAAC,QAAQ,KAAK,WAAW,QAAQ,CAAC,CAAC,CACrD,KAAI,aAAY;EAAE,MAAM,QAAQ;EAAM,MAAM,WAAW,QAAQ,CAAC,CAAC,OAAO,kBAAkB,QAAQ,IAAI,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,EAAE;CAAE,EAAE;AAC3I"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * ACRYL system prompt shaping (ACRYL spec 037, pi.dev-like prompt). pi.dev owns one builder function that produces a structured, tagged prompt; the
3
+ * frame composes its agent's prompt from the harness's sections (a pinned upstream we do not fork), so this plugin applies the same shape as a
4
+ * pass-through: on the harness's `system-prompt/assemble` waterfall it puts the identity first, wraps every other section in a tag, drops empty ones,
5
+ * and records what upstream contributed so a harness update shows exactly what changed. It rewrites nothing else.
6
+ *
7
+ * It also contributes one section of its own, the reply style (`acryl:reply-style`, tagged `<reply_style>`): plain words and no em dash.
8
+ *
9
+ * Provides: `acrylSystemPrompt` ({ lastUpstream() }) and the reply style section. Requires: `systemPrompt`.
10
+ */
11
+ import type { Context } from '@deepseek-ai/cordis';
12
+ import Schema from '@deepseek-ai/schemastery';
13
+ export declare const name = "@acrylblends/system-prompt";
14
+ export declare const inject: string[];
15
+ export interface Config {
16
+ identity: string;
17
+ style: string;
18
+ tagSections: boolean;
19
+ dropEmpty: boolean;
20
+ }
21
+ export declare const Config: Schema<Config>;
22
+ export declare function apply(ctx: Context, config: Config): void;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * pi.dev opens its prompt with one identity line ("You are an expert coding assistant operating inside pi, ..."). This is ACRYL's; a product built
3
+ * on ACRYL passes its own line through the plugin's `identity` config (the Blends frame does, in every app's composition).
4
+ */
5
+ export declare const DEFAULT_IDENTITY = "You are an expert coding assistant operating inside ACRYL, a coding agent harness that can extend itself with plugins. You help users by reading files, executing commands, editing code, and writing new files, and by building, changing and removing ACRYL extensions when asked.";
6
+ /**
7
+ * How the agent writes its replies to the person: plain words, short, and with a plain dash instead of an em dash (the owner's rule for everything
8
+ * ACRYL writes, which a model otherwise breaks in nearly every answer).
9
+ */
10
+ export declare const DEFAULT_STYLE = "Write replies in plain, short sentences the person can act on. Never use the em dash character (U+2014) or the en dash (U+2013) in replies, code comments or files you write; use a plain hyphen-minus (-) or a comma instead.";
11
+ /** The reply style's section: right after the identity line (the harness identity is -1000, the deployment persona 0). */
12
+ export declare const STYLE_SECTION: {
13
+ readonly name: "acryl:reply-style";
14
+ readonly order: -900;
15
+ };
16
+ /** Section names the harness registers for its identity line. */
17
+ export declare const IDENTITY_SECTION = "harness:identity";
18
+ /** One section of the assembled prompt, as the harness's `system-prompt/assemble` waterfall carries it. */
19
+ export interface PromptSection {
20
+ readonly name: string;
21
+ readonly text: string;
22
+ }
23
+ export interface ShapeOptions {
24
+ readonly identity?: string;
25
+ readonly tagSections?: boolean;
26
+ readonly dropEmpty?: boolean;
27
+ }
28
+ /** `tool:read` becomes `tool_read`; anything outside `[a-z0-9_-]` becomes `_`, and a tag never starts with a digit or separator. */
29
+ export declare function tagName(sectionName: string): string;
30
+ /**
31
+ * Shape the harness's assembled sections the way pi.dev's `buildSystemPromptSections` shapes its own: an untagged opening identity line,
32
+ * then every other section as a tagged block, with empty sections dropped. Nothing else is rewritten: every section that is not the
33
+ * identity passes through with its upstream text unchanged, so upstream improvements to tool guidance still reach the model.
34
+ * @param sections - upstream sections in final order.
35
+ */
36
+ export declare function shapeSections(sections: readonly PromptSection[], options?: ShapeOptions): PromptSection[];
37
+ /** Text that legitimately differs per run (the web surface section names its random local port) must not look like drift. */
38
+ export declare function normalizeVolatile(text: string): string;
39
+ /**
40
+ * What upstream contributed, for drift detection: name and a short hash of the text, excluding ACRYL's own sections (they carry
41
+ * machine-specific paths and are ours to change). Variables such as `{{cwd}}` are not yet interpolated at this stage, so the hashes are stable.
42
+ */
43
+ export declare function upstreamSnapshot(sections: readonly PromptSection[]): {
44
+ name: string;
45
+ hash: string;
46
+ }[];
package/package.json CHANGED
@@ -1,6 +1,67 @@
1
1
  {
2
2
  "name": "@acrylblends/system-prompt",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "ACRYL's own shaping of the system prompt on top of the harness's sections: ACRYL identity, pi.dev-style tagged sections, no empty sections, and a drift record of what upstream contributes",
5
+ "license": "MIT",
6
+ "publishConfig": {
7
+ "access": "public",
8
+ "registry": "https://registry.npmjs.org"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/acryldev/acryl.git",
13
+ "directory": "plugins/acryl-system-prompt"
14
+ },
15
+ "homepage": "https://github.com/acryldev/acryl/tree/main/plugins/acryl-system-prompt#readme",
16
+ "bugs": {
17
+ "url": "https://github.com/acryldev/acryl/issues"
18
+ },
19
+ "type": "module",
20
+ "main": "lib/index.js",
21
+ "types": "lib/types/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./lib/types/index.d.ts",
25
+ "default": "./lib/index.js"
26
+ },
27
+ "./package.json": "./package.json",
28
+ "./transform": {
29
+ "types": "./lib/types/transform.d.ts",
30
+ "default": "./lib/transform.js"
31
+ }
32
+ },
33
+ "files": [
34
+ "cordis.patch.yml",
35
+ "lib/**",
36
+ "drift/**",
37
+ "README.md"
38
+ ],
39
+ "dsh": {
40
+ "bundle": {
41
+ "patch": "./cordis.patch.yml"
42
+ }
43
+ },
44
+ "scripts": {
45
+ "build": "node scripts/clean.mjs && tsdown && tsc -p tsconfig.json --emitDeclarationOnly",
46
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.tests.json --noEmit",
47
+ "test": "vitest run",
48
+ "check": "pnpm run build && pnpm run typecheck && pnpm run test",
49
+ "prepack": "pnpm run check"
50
+ },
51
+ "engines": {
52
+ "node": "^22.19.0 || >=24.0.0"
53
+ },
54
+ "dependencies": {
55
+ "@deepseek-ai/schemastery": "~3.18.4"
56
+ },
57
+ "peerDependencies": {
58
+ "@deepseek-ai/cordis": "^4.0.4"
59
+ },
60
+ "devDependencies": {
61
+ "@deepseek-ai/cordis": "4.0.4",
62
+ "@types/node": "^22.20.0",
63
+ "tsdown": "0.22.2",
64
+ "typescript": "6.0.3",
65
+ "vitest": "4.1.11"
66
+ }
67
+ }