@orion-agents/orion-code 0.4.7 → 0.4.8

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 (36) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/README.md +8 -9
  3. package/README.zh-CN.md +8 -8
  4. package/dist/acp/session-updates.js +1 -0
  5. package/dist/framework/query.d.ts +3 -7
  6. package/dist/framework/query.js +22 -74
  7. package/dist/framework/verification-command.d.ts +21 -0
  8. package/dist/framework/verification-command.js +53 -4
  9. package/dist/harness/context-harness.d.ts +3 -9
  10. package/dist/harness/context-harness.js +43 -163
  11. package/dist/harness/state.d.ts +3 -0
  12. package/dist/harness/state.js +37 -4
  13. package/dist/harness/task-checklist.d.ts +1 -1
  14. package/dist/harness/task-checklist.js +1 -1
  15. package/dist/harness/types.d.ts +1 -0
  16. package/dist/harness/verification.js +5 -4
  17. package/dist/runtime/agent-loop.js +6 -33
  18. package/dist/runtime/goal-lifecycle-v2.js +5 -0
  19. package/dist/runtime/goal-runtime-coordinator.js +6 -2
  20. package/dist/runtime/orion-runtime-v1.js +33 -6
  21. package/dist/runtime/product-orion-runtime.js +6 -2
  22. package/dist/runtime/step-snapshot.js +57 -10
  23. package/dist/runtime/task-context-recovery.js +7 -3
  24. package/dist/runtime/task-context-service.d.ts +2 -6
  25. package/dist/runtime/task-context-service.js +3 -12
  26. package/dist/runtime/thread-ui-adapter.js +13 -1
  27. package/dist/runtime/ui-events.d.ts +3 -0
  28. package/dist/runtime/verification-feedback.d.ts +4 -0
  29. package/dist/runtime/verification-feedback.js +61 -0
  30. package/dist/tools/bash_security.d.ts +1 -24
  31. package/dist/tools/bash_security.js +7 -124
  32. package/dist/tools/todo.js +9 -13
  33. package/dist/utils/shell-command.d.ts +29 -0
  34. package/dist/utils/shell-command.js +185 -0
  35. package/npm-shrinkwrap.json +2 -2
  36. package/package.json +1 -1
@@ -21,15 +21,13 @@ const TODO_PROMPT = `Use this tool to create and manage a structured task list f
21
21
 
22
22
  ## When to Use This Tool
23
23
 
24
- If the task context requires a checklist, create it before changing the workspace. Name the exact target paths in the implementation steps and include verification.
24
+ For multi-step work, a checklist can track implementation paths and planned checks.
25
25
 
26
26
  1. Complex multi-step tasks - When a task requires 3 or more distinct steps
27
27
  2. Non-trivial tasks - Tasks that require careful planning or multiple operations
28
28
  3. User explicitly requests todo list
29
29
  4. User provides multiple tasks (numbered or comma-separated)
30
30
  5. After receiving new instructions - Immediately capture user requirements
31
- 6. When you start working on a task - Mark it as in_progress BEFORE beginning
32
- 7. After completing a task - Mark it completed immediately
33
31
 
34
32
  ## When NOT to Use
35
33
 
@@ -41,7 +39,7 @@ If the task context requires a checklist, create it before changing the workspac
41
39
 
42
40
  - pending: Task not yet started
43
41
  - in_progress: Currently working on (limit to ONE task at a time)
44
- - completed: Task finished successfully
42
+ - completed: You consider this step finished. Verification evidence is tracked separately.
45
43
 
46
44
  ## Task Format
47
45
 
@@ -50,16 +48,14 @@ Each todo must have:
50
48
  - activeForm: Present continuous form ("Running tests")
51
49
  - status: pending | in_progress | completed
52
50
 
53
- For verification steps, also include verification with the required check kinds (${verification_command_1.LOCAL_VERIFICATION_KINDS.join(', ')}).
51
+ For verification steps, you can include expected check kinds (${verification_command_1.LOCAL_VERIFICATION_KINDS.join(', ')}).
54
52
 
55
53
  ## Rules
56
54
 
57
55
  - Keep at most ONE task in_progress at a time
58
- - Mark tasks complete IMMEDIATELY after finishing
59
- - Keep descriptions stable. To clarify an unfinished step, replace its bare filename with the exact workspace-relative path.
60
- - Only mark a step completed after running its work and checks while it is in progress.
61
- - An implementation step with verification requires both a file change and a passing check.
62
- - Run each verification command directly with exec_command and use its cwd argument for the project directory. If a check fails, retry that check successfully before completing the step.`;
56
+ - Keep descriptions stable when possible so evidence can stay linked to the same step.
57
+ - An update can succeed while verification is missing. Report any unverified work in your answer.
58
+ - Use tool results and the user's instructions to decide whether to verify, change approach, ask, or finish. Repeating an unchanged checklist update does not add evidence.`;
63
59
  exports.MAX_TODOS = 8;
64
60
  exports.MAX_TODO_TEXT = 120;
65
61
  function createTodoWriteTool(save) {
@@ -73,7 +69,7 @@ ${TODO_PROMPT}`,
73
69
  properties: {
74
70
  blockedReason: {
75
71
  type: 'string',
76
- description: 'Report a concrete blocker and finish the current turn with the active step open.',
72
+ description: 'Record a concrete blocker on the active step.',
77
73
  },
78
74
  todos: {
79
75
  type: 'array',
@@ -87,7 +83,7 @@ ${TODO_PROMPT}`,
87
83
  activeForm: { type: 'string', description: 'Step in present continuous form.' },
88
84
  verification: {
89
85
  type: 'array',
90
- description: 'Check kinds that must pass before completing this step.',
86
+ description: 'Expected verification kinds for this step.',
91
87
  minItems: 1,
92
88
  maxItems: verification_command_1.LOCAL_VERIFICATION_KINDS.length,
93
89
  items: { type: 'string', enum: [...verification_command_1.LOCAL_VERIFICATION_KINDS] },
@@ -177,7 +173,7 @@ ${TODO_PROMPT}`,
177
173
  return {
178
174
  success: true,
179
175
  output,
180
- summary: `${completed}/${applied.length} complete${current ? ` · ${current.activeForm}` : ''}`,
176
+ summary: `${completed}/${applied.length} marked complete${current ? ` · ${current.activeForm}` : ''}`,
181
177
  metadata: { taskTodos: applied },
182
178
  };
183
179
  },
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Result of a quote-aware scan over a whole command line.
3
+ */
4
+ export interface ShellCommandScan {
5
+ /** The individual commands on the line, split on unquoted separators. */
6
+ segments: string[];
7
+ /**
8
+ * False when the line uses a construct this scanner cannot reason about --
9
+ * command substitution, process substitution or an unbalanced quote. Such a
10
+ * line can hide an arbitrary command and must never be auto-approved.
11
+ */
12
+ supported: boolean;
13
+ /** True when the line redirects output somewhere other than /dev/null. */
14
+ writesFile: boolean;
15
+ }
16
+ /**
17
+ * Split a command line into the individual commands it will actually run.
18
+ *
19
+ * The classifier below hands out "run without confirmation" verdicts, so it has
20
+ * to see every command on the line rather than just the leading token. Quote
21
+ * state is tracked so `echo "a && b"` stays one segment, and substitutions are
22
+ * reported as unsupported instead of being silently skipped over.
23
+ */
24
+ type ShellCommandOperator = ';' | '\n' | '&' | '|' | '&&' | '||';
25
+ export declare function scanShellCommand(cmd: string, onOperator?: (operator: ShellCommandOperator) => void): ShellCommandScan;
26
+ /** Read literal arguments of an already scanned single command. */
27
+ export declare function literalShellWords(command: string): string[] | undefined;
28
+ export {};
29
+ //# sourceMappingURL=shell-command.d.ts.map
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scanShellCommand = scanShellCommand;
4
+ exports.literalShellWords = literalShellWords;
5
+ /** The one redirect target that does not count as writing to the filesystem. */
6
+ const DISCARD_REDIRECT_TARGET = '/dev/null';
7
+ function scanShellCommand(cmd, onOperator) {
8
+ const segments = [];
9
+ let current = '';
10
+ let supported = true;
11
+ let writesFile = false;
12
+ let inSingleQuote = false;
13
+ let inDoubleQuote = false;
14
+ let wordStarted = false;
15
+ const pushSegment = () => {
16
+ const segment = current.trim();
17
+ if (segment.length > 0) {
18
+ segments.push(segment);
19
+ }
20
+ current = '';
21
+ wordStarted = false;
22
+ };
23
+ for (let i = 0; i < cmd.length; i++) {
24
+ const ch = cmd[i];
25
+ const next = cmd[i + 1];
26
+ if (ch === '\\' && !inSingleQuote && next !== undefined) {
27
+ current += ch + next;
28
+ if (next !== '\n')
29
+ wordStarted = true;
30
+ i++;
31
+ continue;
32
+ }
33
+ if (ch === "'" && !inDoubleQuote) {
34
+ inSingleQuote = !inSingleQuote;
35
+ current += ch;
36
+ wordStarted = true;
37
+ continue;
38
+ }
39
+ if (ch === '"' && !inSingleQuote) {
40
+ inDoubleQuote = !inDoubleQuote;
41
+ current += ch;
42
+ wordStarted = true;
43
+ continue;
44
+ }
45
+ if (inSingleQuote) {
46
+ // Single quotes disable every expansion, so the contents stay inert.
47
+ current += ch;
48
+ continue;
49
+ }
50
+ if (inDoubleQuote) {
51
+ // Double quotes only suppress globbing and word splitting -- bash still
52
+ // expands `$(...)` and backticks inside them. Skipping the substitution
53
+ // check here made `echo "$(rm -rf $HOME)"` classify as safe/read-only and
54
+ // auto-approve, i.e. a straight command-execution bypass.
55
+ if (ch === '`' || (ch === '$' && next === '(')) {
56
+ supported = false;
57
+ }
58
+ current += ch;
59
+ continue;
60
+ }
61
+ if (ch === '#' && !wordStarted) {
62
+ while (i + 1 < cmd.length && cmd[i + 1] !== '\n')
63
+ i++;
64
+ continue;
65
+ }
66
+ // Command and process substitution can hide an arbitrary command inside an
67
+ // otherwise innocent-looking line, and neither is worth modelling here.
68
+ if (ch === '`' ||
69
+ (ch === '$' && next === '(') ||
70
+ ((ch === '<' || ch === '>') && next === '(')) {
71
+ supported = false;
72
+ current += ch;
73
+ continue;
74
+ }
75
+ if (ch === ';' || ch === '\n') {
76
+ pushSegment();
77
+ onOperator?.(ch);
78
+ continue;
79
+ }
80
+ if ((ch === '&' && next === '&') || (ch === '|' && next === '|')) {
81
+ pushSegment();
82
+ onOperator?.(ch === '&' ? '&&' : '||');
83
+ i++;
84
+ continue;
85
+ }
86
+ if (ch === '&' || ch === '|') {
87
+ pushSegment();
88
+ onOperator?.(ch);
89
+ continue;
90
+ }
91
+ if (ch === '>') {
92
+ let cursor = i + 1;
93
+ if (cmd[cursor] === '>') {
94
+ cursor++;
95
+ }
96
+ if (cmd[cursor] === '&') {
97
+ // `>&1` / `2>&1` duplicate a descriptor and `>&-` closes one; nothing
98
+ // reaches the filesystem. Consume the whole reference so its `&` is not
99
+ // mistaken for a background-job separator.
100
+ let end = cursor + 1;
101
+ while (end < cmd.length && cmd[end] >= '0' && cmd[end] <= '9') {
102
+ end++;
103
+ }
104
+ if (cmd[end] === '-') {
105
+ end++;
106
+ }
107
+ current += cmd.slice(i, end);
108
+ wordStarted = false;
109
+ i = end - 1;
110
+ continue;
111
+ }
112
+ while (cursor < cmd.length && (cmd[cursor] === ' ' || cmd[cursor] === '\t')) {
113
+ cursor++;
114
+ }
115
+ const target = cmd.slice(cursor).split(/[\s;&|<>]/)[0];
116
+ if (target !== DISCARD_REDIRECT_TARGET) {
117
+ writesFile = true;
118
+ }
119
+ current += ch;
120
+ wordStarted = false;
121
+ continue;
122
+ }
123
+ current += ch;
124
+ wordStarted = !/[\s<]/u.test(ch);
125
+ }
126
+ pushSegment();
127
+ return {
128
+ segments,
129
+ supported: supported && !inSingleQuote && !inDoubleQuote,
130
+ writesFile,
131
+ };
132
+ }
133
+ /** Read literal arguments of an already scanned single command. */
134
+ function literalShellWords(command) {
135
+ const words = [];
136
+ let word = '';
137
+ let quote;
138
+ let started = false;
139
+ const flush = () => {
140
+ if (started)
141
+ words.push(word);
142
+ word = '';
143
+ started = false;
144
+ };
145
+ for (let index = 0; index < command.length; index++) {
146
+ const char = command[index];
147
+ const next = command[index + 1];
148
+ if (char === '\\' && quote !== "'") {
149
+ if (next === undefined)
150
+ return;
151
+ if (quote === '"' && !['\\', '"', '$', '`', '\n'].includes(next)) {
152
+ word += char;
153
+ }
154
+ else {
155
+ index++;
156
+ if (next !== '\n') {
157
+ word += next;
158
+ started = true;
159
+ }
160
+ }
161
+ continue;
162
+ }
163
+ if (char === quote || (!quote && (char === "'" || char === '"'))) {
164
+ quote = quote ? undefined : char;
165
+ started = true;
166
+ continue;
167
+ }
168
+ if (quote !== "'" && (char === '$' || char === '`'))
169
+ return;
170
+ if (!quote && char === '#' && !started)
171
+ break;
172
+ if (!quote && /[\s<>]/u.test(char)) {
173
+ flush();
174
+ }
175
+ else {
176
+ word += char;
177
+ started = true;
178
+ }
179
+ }
180
+ if (quote)
181
+ return;
182
+ flush();
183
+ return words;
184
+ }
185
+ //# sourceMappingURL=shell-command.js.map
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@orion-agents/orion-code",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@orion-agents/orion-code",
9
- "version": "0.4.7",
9
+ "version": "0.4.8",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@agentclientprotocol/sdk": "2.12.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-agents/orion-code",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "description": "Orion Code - local-first goal-driven coding agent for the terminal.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",