@zhin.js/agent 1.1.1 → 1.1.3

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.
Files changed (107) hide show
  1. package/lib/bootstrap.d.ts +12 -0
  2. package/lib/bootstrap.d.ts.map +1 -1
  3. package/lib/bootstrap.js +65 -0
  4. package/lib/bootstrap.js.map +1 -1
  5. package/lib/builtin/deferred-tool-meta.d.ts +5 -0
  6. package/lib/builtin/deferred-tool-meta.d.ts.map +1 -1
  7. package/lib/builtin/deferred-tool-meta.js +13 -0
  8. package/lib/builtin/deferred-tool-meta.js.map +1 -1
  9. package/lib/config/zhin-agent-config.d.ts +6 -0
  10. package/lib/config/zhin-agent-config.d.ts.map +1 -1
  11. package/lib/config/zhin-agent-defaults.d.ts.map +1 -1
  12. package/lib/config/zhin-agent-defaults.js +3 -0
  13. package/lib/config/zhin-agent-defaults.js.map +1 -1
  14. package/lib/config/zhin-agent-dependencies.d.ts +1 -0
  15. package/lib/config/zhin-agent-dependencies.d.ts.map +1 -1
  16. package/lib/core/agent-loop-standalone.d.ts.map +1 -1
  17. package/lib/core/agent-loop-standalone.js +84 -34
  18. package/lib/core/agent-loop-standalone.js.map +1 -1
  19. package/lib/discovery/skills.js +3 -3
  20. package/lib/discovery/skills.js.map +1 -1
  21. package/lib/event/session-events.d.ts +3 -2
  22. package/lib/event/session-events.d.ts.map +1 -1
  23. package/lib/event/session-events.js.map +1 -1
  24. package/lib/init/configure-zhin-agent.d.ts +1 -0
  25. package/lib/init/configure-zhin-agent.d.ts.map +1 -1
  26. package/lib/init/configure-zhin-agent.js +4 -0
  27. package/lib/init/configure-zhin-agent.js.map +1 -1
  28. package/lib/init/register-builtin-tools.d.ts.map +1 -1
  29. package/lib/init/register-builtin-tools.js +8 -1
  30. package/lib/init/register-builtin-tools.js.map +1 -1
  31. package/lib/internal/agent-host.d.ts +4 -6
  32. package/lib/internal/agent-host.d.ts.map +1 -1
  33. package/lib/media/media-normalize.d.ts +5 -0
  34. package/lib/media/media-normalize.d.ts.map +1 -1
  35. package/lib/media/media-normalize.js +24 -0
  36. package/lib/media/media-normalize.js.map +1 -1
  37. package/lib/prompt/assembly.d.ts.map +1 -1
  38. package/lib/prompt/assembly.js +11 -0
  39. package/lib/prompt/assembly.js.map +1 -1
  40. package/lib/prompt/git-context.d.ts +7 -0
  41. package/lib/prompt/git-context.d.ts.map +1 -0
  42. package/lib/prompt/git-context.js +75 -0
  43. package/lib/prompt/git-context.js.map +1 -0
  44. package/lib/prompt/model-aware-builder.d.ts +8 -0
  45. package/lib/prompt/model-aware-builder.d.ts.map +1 -0
  46. package/lib/prompt/model-aware-builder.js +62 -0
  47. package/lib/prompt/model-aware-builder.js.map +1 -0
  48. package/lib/prompt/model-prompt-strategy.d.ts +12 -0
  49. package/lib/prompt/model-prompt-strategy.d.ts.map +1 -0
  50. package/lib/prompt/model-prompt-strategy.js +92 -0
  51. package/lib/prompt/model-prompt-strategy.js.map +1 -0
  52. package/lib/prompt/rules/code-references.d.ts +2 -0
  53. package/lib/prompt/rules/code-references.d.ts.map +1 -0
  54. package/lib/prompt/rules/code-references.js +11 -0
  55. package/lib/prompt/rules/code-references.js.map +1 -0
  56. package/lib/prompt/rules/critical-rules.d.ts +2 -0
  57. package/lib/prompt/rules/critical-rules.d.ts.map +1 -0
  58. package/lib/prompt/rules/critical-rules.js +19 -0
  59. package/lib/prompt/rules/critical-rules.js.map +1 -0
  60. package/lib/prompt/rules/editing.d.ts +2 -0
  61. package/lib/prompt/rules/editing.d.ts.map +1 -0
  62. package/lib/prompt/rules/editing.js +18 -0
  63. package/lib/prompt/rules/editing.js.map +1 -0
  64. package/lib/prompt/rules/error-handling.d.ts +2 -0
  65. package/lib/prompt/rules/error-handling.d.ts.map +1 -0
  66. package/lib/prompt/rules/error-handling.js +18 -0
  67. package/lib/prompt/rules/error-handling.js.map +1 -0
  68. package/lib/prompt/rules/index.d.ts +8 -0
  69. package/lib/prompt/rules/index.d.ts.map +1 -0
  70. package/lib/prompt/rules/index.js +8 -0
  71. package/lib/prompt/rules/index.js.map +1 -0
  72. package/lib/prompt/rules/memory.d.ts +2 -0
  73. package/lib/prompt/rules/memory.d.ts.map +1 -0
  74. package/lib/prompt/rules/memory.js +13 -0
  75. package/lib/prompt/rules/memory.js.map +1 -0
  76. package/lib/prompt/rules/task-completion.d.ts +2 -0
  77. package/lib/prompt/rules/task-completion.d.ts.map +1 -0
  78. package/lib/prompt/rules/task-completion.js +11 -0
  79. package/lib/prompt/rules/task-completion.js.map +1 -0
  80. package/lib/prompt/rules/workflow-rules.d.ts +2 -0
  81. package/lib/prompt/rules/workflow-rules.d.ts.map +1 -0
  82. package/lib/prompt/rules/workflow-rules.js +27 -0
  83. package/lib/prompt/rules/workflow-rules.js.map +1 -0
  84. package/lib/prompt/system-prompt.d.ts +16 -0
  85. package/lib/prompt/system-prompt.d.ts.map +1 -1
  86. package/lib/prompt/system-prompt.js +167 -21
  87. package/lib/prompt/system-prompt.js.map +1 -1
  88. package/lib/session/session-system.d.ts +6 -0
  89. package/lib/session/session-system.d.ts.map +1 -1
  90. package/lib/session/session-system.js +34 -0
  91. package/lib/session/session-system.js.map +1 -1
  92. package/lib/subagent-parent-context.d.ts +9 -0
  93. package/lib/subagent-parent-context.d.ts.map +1 -1
  94. package/lib/subagent-parent-context.js +8 -0
  95. package/lib/subagent-parent-context.js.map +1 -1
  96. package/lib/turn/auto-continue.d.ts +2 -12
  97. package/lib/turn/auto-continue.d.ts.map +1 -1
  98. package/lib/turn/auto-continue.js.map +1 -1
  99. package/lib/zhin-agent/index.d.ts +15 -35
  100. package/lib/zhin-agent/index.d.ts.map +1 -1
  101. package/lib/zhin-agent/index.js +26 -118
  102. package/lib/zhin-agent/index.js.map +1 -1
  103. package/lib/zhin-agent/runtime-modules.d.ts +1 -0
  104. package/lib/zhin-agent/runtime-modules.d.ts.map +1 -1
  105. package/lib/zhin-agent/runtime-modules.js +16 -0
  106. package/lib/zhin-agent/runtime-modules.js.map +1 -1
  107. package/package.json +7 -7
@@ -0,0 +1,92 @@
1
+ export const DEFAULT_STRATEGY = Object.freeze({
2
+ family: 'unknown',
3
+ contextWindowThreshold: 128000,
4
+ preferConcise: true,
5
+ detailedToolInstructions: true,
6
+ detailedSecurityRules: true,
7
+ maxPromptChars: 80000,
8
+ style: 'balanced',
9
+ });
10
+ const MODEL_STRATEGIES = [
11
+ [/gpt-?5/i, {
12
+ family: 'gpt-5',
13
+ contextWindowThreshold: 200000,
14
+ preferConcise: false,
15
+ maxPromptChars: 100000,
16
+ style: 'detailed',
17
+ }],
18
+ [/gpt-?4o/i, {
19
+ family: 'gpt-4o',
20
+ contextWindowThreshold: 128000,
21
+ preferConcise: true,
22
+ maxPromptChars: 80000,
23
+ style: 'balanced',
24
+ }],
25
+ [/claude.*opus/i, {
26
+ family: 'claude-opus',
27
+ contextWindowThreshold: 200000,
28
+ preferConcise: false,
29
+ maxPromptChars: 100000,
30
+ style: 'detailed',
31
+ }],
32
+ [/claude.*sonnet/i, {
33
+ family: 'claude-sonnet',
34
+ contextWindowThreshold: 200000,
35
+ preferConcise: true,
36
+ maxPromptChars: 80000,
37
+ style: 'balanced',
38
+ }],
39
+ [/claude.*haiku/i, {
40
+ family: 'claude-haiku',
41
+ contextWindowThreshold: 200000,
42
+ preferConcise: true,
43
+ detailedToolInstructions: false,
44
+ detailedSecurityRules: false,
45
+ maxPromptChars: 40000,
46
+ style: 'concise',
47
+ }],
48
+ [/deepseek/i, {
49
+ family: 'deepseek',
50
+ contextWindowThreshold: 128000,
51
+ preferConcise: true,
52
+ detailedSecurityRules: false,
53
+ maxPromptChars: 60000,
54
+ style: 'balanced',
55
+ }],
56
+ [/qwen/i, {
57
+ family: 'qwen',
58
+ contextWindowThreshold: 128000,
59
+ preferConcise: true,
60
+ detailedSecurityRules: false,
61
+ maxPromptChars: 60000,
62
+ style: 'balanced',
63
+ }],
64
+ [/llama/i, {
65
+ family: 'llama',
66
+ contextWindowThreshold: 8192,
67
+ preferConcise: true,
68
+ detailedToolInstructions: false,
69
+ detailedSecurityRules: false,
70
+ maxPromptChars: 30000,
71
+ style: 'concise',
72
+ }],
73
+ [/gemma/i, {
74
+ family: 'gemma',
75
+ contextWindowThreshold: 8192,
76
+ preferConcise: true,
77
+ detailedToolInstructions: false,
78
+ detailedSecurityRules: false,
79
+ maxPromptChars: 30000,
80
+ style: 'concise',
81
+ }],
82
+ ];
83
+ export function resolveModelStrategy(modelId) {
84
+ const root = modelId.includes('/') ? modelId.slice(modelId.indexOf('/') + 1) : modelId;
85
+ for (const [pattern, partial] of MODEL_STRATEGIES) {
86
+ if (pattern.test(root)) {
87
+ return { ...DEFAULT_STRATEGY, ...partial };
88
+ }
89
+ }
90
+ return DEFAULT_STRATEGY;
91
+ }
92
+ //# sourceMappingURL=model-prompt-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-prompt-strategy.js","sourceRoot":"","sources":["../../src/prompt/model-prompt-strategy.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,gBAAgB,GAAwB,MAAM,CAAC,MAAM,CAAC;IACjE,MAAM,EAAE,SAAS;IACjB,sBAAsB,EAAE,MAAM;IAC9B,aAAa,EAAE,IAAI;IACnB,wBAAwB,EAAE,IAAI;IAC9B,qBAAqB,EAAE,IAAI;IAC3B,cAAc,EAAE,KAAK;IACrB,KAAK,EAAE,UAAU;CAClB,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAsF;IAC1G,CAAC,SAAS,EAAE;YACV,MAAM,EAAE,OAAO;YACf,sBAAsB,EAAE,MAAM;YAC9B,aAAa,EAAE,KAAK;YACpB,cAAc,EAAE,MAAM;YACtB,KAAK,EAAE,UAAU;SAClB,CAAC;IACF,CAAC,UAAU,EAAE;YACX,MAAM,EAAE,QAAQ;YAChB,sBAAsB,EAAE,MAAM;YAC9B,aAAa,EAAE,IAAI;YACnB,cAAc,EAAE,KAAK;YACrB,KAAK,EAAE,UAAU;SAClB,CAAC;IACF,CAAC,eAA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C/B,qBAAqB,EAAE,KAAK;YAC5B,cAAc,EAAE,KAAK;YACrB,KAAK,EAAE,SAAS;SACjB,CAAC;CACH,CAAC;AAEF,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAClD,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IACvF,KAAK,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,gBAAgB,EAAE,CAAC;QAClD,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,OAAO,EAAE,GAAG,gBAAgB,EAAE,GAAG,OAAO,EAAE,CAAC;QAC7C,CAAC;IACH,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const CODE_REFERENCE_RULES: string;
2
+ //# sourceMappingURL=code-references.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-references.d.ts","sourceRoot":"","sources":["../../../src/prompt/rules/code-references.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,QASzB,CAAC"}
@@ -0,0 +1,11 @@
1
+ export const CODE_REFERENCE_RULES = `
2
+ <code_references>
3
+ When referencing specific functions or code locations, use the pattern:
4
+ \`file_path:line_number\`
5
+
6
+ Examples:
7
+ - "The error is handled in src/main.ts:45"
8
+ - "See the implementation in src/utils/helper.ts:123-145"
9
+ </code_references>
10
+ `.trim();
11
+ //# sourceMappingURL=code-references.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-references.js","sourceRoot":"","sources":["../../../src/prompt/rules/code-references.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;CASnC,CAAC,IAAI,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const CRITICAL_RULES: string;
2
+ //# sourceMappingURL=critical-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"critical-rules.d.ts","sourceRoot":"","sources":["../../../src/prompt/rules/critical-rules.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,QAiBnB,CAAC"}
@@ -0,0 +1,19 @@
1
+ export const CRITICAL_RULES = `
2
+ <critical_rules>
3
+ These rules override everything else. Follow them strictly:
4
+
5
+ 1. **READ BEFORE EDIT**: Never edit a file you haven't read the relevant context for.
6
+ 2. **BE AUTONOMOUS**: Don't ask questions - search, read, think, decide, act.
7
+ 3. **TEST AFTER CHANGES**: Run tests immediately after each modification.
8
+ 4. **BE CONCISE**: Keep output concise (default <4 lines), unless explaining complex changes.
9
+ 5. **USE EXACT MATCHES**: When editing, match text exactly including whitespace and line breaks.
10
+ 6. **NEVER COMMIT** unless user explicitly says "commit".
11
+ 7. **FOLLOW MEMORY**: If memory files contain specific instructions, you MUST follow them.
12
+ 8. **NEVER ADD COMMENTS** unless asked. Focus on *why* not *what*.
13
+ 9. **SECURITY FIRST**: Only assist with defensive security tasks.
14
+ 10. **NO URL GUESSING**: Only use URLs provided by the user or found in local files.
15
+ 11. **NEVER PUSH** to remote unless explicitly asked.
16
+ 12. **LOAD MATCHING SKILLS**: If any available skill matches the current task, you MUST load it.
17
+ </critical_rules>
18
+ `.trim();
19
+ //# sourceMappingURL=critical-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"critical-rules.js","sourceRoot":"","sources":["../../../src/prompt/rules/critical-rules.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;CAiB7B,CAAC,IAAI,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const EDITING_RULES: string;
2
+ //# sourceMappingURL=editing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editing.d.ts","sourceRoot":"","sources":["../../../src/prompt/rules/editing.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,QAgBlB,CAAC"}
@@ -0,0 +1,18 @@
1
+ export const EDITING_RULES = `
2
+ <whitespace_and_exact_matching>
3
+ The Edit tool is extremely literal. "Close enough" will fail.
4
+
5
+ **Before every edit:**
6
+ 1. View the file and locate the exact lines to change
7
+ 2. Copy the text EXACTLY including spaces, tabs, blank lines
8
+ 3. Include enough surrounding lines (3-5) to make it unique
9
+ 4. Double-check indentation level matches
10
+
11
+ **If edit fails:**
12
+ - View the file again at the specific location
13
+ - Copy even more context
14
+ - Check for tabs vs spaces
15
+ - Never retry with guessed changes - get the exact text first
16
+ </whitespace_and_exact_matching>
17
+ `.trim();
18
+ //# sourceMappingURL=editing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editing.js","sourceRoot":"","sources":["../../../src/prompt/rules/editing.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;CAgB5B,CAAC,IAAI,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const ERROR_HANDLING_RULES: string;
2
+ //# sourceMappingURL=error-handling.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handling.d.ts","sourceRoot":"","sources":["../../../src/prompt/rules/error-handling.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,QAgBzB,CAAC"}
@@ -0,0 +1,18 @@
1
+ export const ERROR_HANDLING_RULES = `
2
+ <error_handling>
3
+ When errors occur:
4
+ 1. Read complete error message
5
+ 2. Understand root cause (isolate with minimal reproduction)
6
+ 3. Try different approach (don't repeat same action)
7
+ 4. Search for similar code that works
8
+ 5. Make targeted fix
9
+ 6. Test to verify
10
+
11
+ **Edit tool "old_string not found":**
12
+ - View the file again at the target location
13
+ - Copy the EXACT text including all whitespace
14
+ - Include more surrounding context (full function if needed)
15
+ - Check for tabs vs spaces, extra/missing blank lines
16
+ </error_handling>
17
+ `.trim();
18
+ //# sourceMappingURL=error-handling.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handling.js","sourceRoot":"","sources":["../../../src/prompt/rules/error-handling.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;CAgBnC,CAAC,IAAI,EAAE,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { CRITICAL_RULES } from './critical-rules.js';
2
+ export { WORKFLOW_RULES } from './workflow-rules.js';
3
+ export { ERROR_HANDLING_RULES } from './error-handling.js';
4
+ export { TASK_COMPLETION_RULES } from './task-completion.js';
5
+ export { EDITING_RULES } from './editing.js';
6
+ export { MEMORY_INSTRUCTIONS } from './memory.js';
7
+ export { CODE_REFERENCE_RULES } from './code-references.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/prompt/rules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { CRITICAL_RULES } from './critical-rules.js';
2
+ export { WORKFLOW_RULES } from './workflow-rules.js';
3
+ export { ERROR_HANDLING_RULES } from './error-handling.js';
4
+ export { TASK_COMPLETION_RULES } from './task-completion.js';
5
+ export { EDITING_RULES } from './editing.js';
6
+ export { MEMORY_INSTRUCTIONS } from './memory.js';
7
+ export { CODE_REFERENCE_RULES } from './code-references.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/prompt/rules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const MEMORY_INSTRUCTIONS: string;
2
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/prompt/rules/memory.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,QAWxB,CAAC"}
@@ -0,0 +1,13 @@
1
+ export const MEMORY_INSTRUCTIONS = `
2
+ <memory_instructions>
3
+ Memory files store commands, preferences, and codebase info.
4
+ Update them when you discover:
5
+ - Build/test/lint commands
6
+ - Code style preferences
7
+ - Important codebase patterns
8
+ - Useful project information
9
+
10
+ Check memory before executing tasks. Follow stored instructions when found.
11
+ </memory_instructions>
12
+ `.trim();
13
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../src/prompt/rules/memory.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;CAWlC,CAAC,IAAI,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const TASK_COMPLETION_RULES: string;
2
+ //# sourceMappingURL=task-completion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-completion.d.ts","sourceRoot":"","sources":["../../../src/prompt/rules/task-completion.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,QAS1B,CAAC"}
@@ -0,0 +1,11 @@
1
+ export const TASK_COMPLETION_RULES = `
2
+ <task_completion>
3
+ Ensure every task is implemented completely:
4
+ 1. **Think before acting** — identify all components that need changes
5
+ 2. **Implement end-to-end** — update all affected files, no TODOs
6
+ 3. **Verify before finishing** — re-read original request, run tests
7
+
8
+ Only say "Done" when truly done — never stop mid-task.
9
+ </task_completion>
10
+ `.trim();
11
+ //# sourceMappingURL=task-completion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-completion.js","sourceRoot":"","sources":["../../../src/prompt/rules/task-completion.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;CASpC,CAAC,IAAI,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const WORKFLOW_RULES: string;
2
+ //# sourceMappingURL=workflow-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-rules.d.ts","sourceRoot":"","sources":["../../../src/prompt/rules/workflow-rules.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,QAyBnB,CAAC"}
@@ -0,0 +1,27 @@
1
+ export const WORKFLOW_RULES = `
2
+ <workflow>
3
+ For every task, follow this sequence internally (don't narrate it):
4
+
5
+ **Before acting:**
6
+ - Search codebase for relevant files
7
+ - Read files to understand current state
8
+ - Check memory for stored commands
9
+ - Identify what needs to change
10
+
11
+ **While acting:**
12
+ - Read entire file before editing it
13
+ - Before editing: verify exact whitespace from View output
14
+ - Use exact text for find/replace (include whitespace)
15
+ - Make one logical change at a time
16
+ - After each change: run tests
17
+ - If tests fail: fix immediately
18
+ - Keep going until query is completely resolved
19
+
20
+ **Before finishing:**
21
+ - Verify ENTIRE query is resolved
22
+ - Run lint/typecheck if in memory
23
+ - Verify all changes work
24
+ - Keep response under 4 lines
25
+ </workflow>
26
+ `.trim();
27
+ //# sourceMappingURL=workflow-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-rules.js","sourceRoot":"","sources":["../../../src/prompt/rules/workflow-rules.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;CAyB7B,CAAC,IAAI,EAAE,CAAC"}
@@ -34,6 +34,14 @@ export interface RichSystemPromptContext {
34
34
  orchestratorSdk?: string;
35
35
  /** ai.agents.*.nickname(经 activeBinding 解析) */
36
36
  agentNickname?: string;
37
+ /** 单行 git 状态摘要(并入 §1 Runtime 信息行) */
38
+ gitStatus?: string;
39
+ /** 全局上下文文件段(默认路径 + config.contextPaths,置于 bootstrap 之前) */
40
+ globalContext?: string;
41
+ /** 当前模型 id(用于模型感知提示词策略) */
42
+ modelId?: string;
43
+ /** 模型上下文窗口大小 */
44
+ contextWindow?: number;
37
45
  }
38
46
  /** 单段字符数统计(日志 / Harness debug;与 buildRichSystemPrompt 分段一致) */
39
47
  export interface PromptSectionDebugInfo {
@@ -45,6 +53,14 @@ export interface PromptSectionDebugInfo {
45
53
  * 用于观测渐进披露与 token 压力,不改变线上 prompt 拼接逻辑。
46
54
  */
47
55
  export declare function describePromptSectionsForDebug(ctx: RichSystemPromptContext): PromptSectionDebugInfo[];
56
+ /**
57
+ * 系统提示词总量护栏:超预算时按牺牲顺序(数组靠前的可截断段先压缩)
58
+ * 尾部截断,仍超长再整段丢弃;truncatable=false 段(runtime/orchestration/security)不动。
59
+ */
60
+ export declare function enforcePromptBudget(sections: {
61
+ content: string | null;
62
+ truncatable: boolean;
63
+ }[], maxChars: number): string;
48
64
  export declare function buildRichSystemPrompt(ctx: RichSystemPromptContext): string;
49
65
  /**
50
66
  * 使用 PromptBuilder 构建系统提示词
@@ -1 +1 @@
1
- {"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/prompt/system-prompt.ts"],"names":[],"mapp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