@aragon-agent/cli 0.6.70 → 0.6.72

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 (64) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +33 -14
  3. package/dist/account/config.d.ts +61 -0
  4. package/dist/account/config.js +83 -0
  5. package/dist/account/device-client.d.ts +113 -0
  6. package/dist/account/device-client.js +425 -0
  7. package/dist/account/format.d.ts +51 -0
  8. package/dist/account/format.js +102 -0
  9. package/dist/account/login-flow.d.ts +68 -0
  10. package/dist/account/login-flow.js +305 -0
  11. package/dist/account/session.d.ts +62 -0
  12. package/dist/account/session.js +63 -0
  13. package/dist/account/store.d.ts +86 -0
  14. package/dist/account/store.js +231 -0
  15. package/dist/agent/controller.d.ts +25 -1
  16. package/dist/agent/controller.js +78 -3
  17. package/dist/agent/project-guidance-prompt.js +97 -97
  18. package/dist/app/App.d.ts +12 -3
  19. package/dist/app/App.js +216 -3
  20. package/dist/cli.js +2 -2
  21. package/dist/commands/account-command.d.ts +86 -0
  22. package/dist/commands/account-command.js +165 -0
  23. package/dist/commands/builtins.js +15 -0
  24. package/dist/commands/catalog.js +17 -1
  25. package/dist/config/app-paths.d.ts +15 -0
  26. package/dist/config/app-paths.js +17 -0
  27. package/dist/config/cli-commands.d.ts +1 -1
  28. package/dist/config/cli-commands.js +4 -0
  29. package/dist/config/env.js +6 -0
  30. package/dist/config/load.js +36 -1
  31. package/dist/governance/engine/lifecycle.js +1 -1
  32. package/dist/governance/prompts/orchestrator-block.js +3 -3
  33. package/dist/host/controller-factory.d.ts +15 -0
  34. package/dist/host/controller-factory.js +10 -2
  35. package/dist/host/memory.d.ts +5 -1
  36. package/dist/host/memory.js +13 -0
  37. package/dist/memory/block.d.ts +38 -4
  38. package/dist/memory/block.js +52 -5
  39. package/dist/memory/command.js +56 -2
  40. package/dist/memory/journal.d.ts +58 -0
  41. package/dist/memory/journal.js +202 -0
  42. package/dist/memory/ledger.d.ts +54 -0
  43. package/dist/memory/ledger.js +105 -0
  44. package/dist/memory/paths.d.ts +10 -0
  45. package/dist/memory/paths.js +31 -0
  46. package/dist/memory/service.d.ts +54 -1
  47. package/dist/memory/service.js +156 -1
  48. package/dist/memory/store.d.ts +21 -3
  49. package/dist/memory/store.js +66 -6
  50. package/dist/memory/tools-batch.d.ts +27 -0
  51. package/dist/memory/tools-batch.js +462 -0
  52. package/dist/memory/tools-shared.d.ts +176 -0
  53. package/dist/memory/tools-shared.js +305 -0
  54. package/dist/memory/tools.d.ts +19 -28
  55. package/dist/memory/tools.js +148 -228
  56. package/dist/memory/undo.d.ts +53 -0
  57. package/dist/memory/undo.js +173 -0
  58. package/dist/redteam/prompt-template.js +16 -16
  59. package/dist/tools/index.d.ts +2 -2
  60. package/dist/tools/index.js +16 -1
  61. package/package.json +3 -3
  62. package/runtime/insecure-tls-warning.cjs +62 -62
  63. package/runtime/insecure-tls-warning.d.cts +5 -5
  64. package/skills/project-indexer/templates/artifact-hygiene-template.md +14 -14
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Undoing one batch of agent writes (memory-agent-autonomy spec 8.2 / D-15).
3
+ *
4
+ * ASCII ONLY - `src/memory/**` is inside `glyphs.test.ts::inScope`.
5
+ *
6
+ * THE USER'S HAND, NEVER THE MODEL'S (D-6). There is no `memory_undo` tool: the entity being
7
+ * audited must not be able to edit the audit trail. `/memory undo`, the activity page's `u` and the
8
+ * desktop button all reach this module; nothing else does.
9
+ *
10
+ * AN UNDO IS A PREDICTABLE INVERSE, NOT A REWRITE. `create` goes to the trash, `update` writes the
11
+ * previous version back, `delete` returns from the trash. Rows are undone NEWEST FIRST so an
12
+ * `update` followed by a `delete` of the same note unwinds in the order that leaves a note behind.
13
+ *
14
+ * PARTIAL SUCCESS IS NORMAL. "Failed and stopped" is the right rule for the agent's own batches
15
+ * (D-13), but this is a recovery action: one row blocked by a policy or a missing version backup
16
+ * must not strand the other five. Blocked rows are reported as `skipped` with their reason.
17
+ *
18
+ * THE UNDO ITSELF IS WRITTEN DOWN (`actor: 'user'`, `op: 'undo'`, `of: <batch>`), so a history that
19
+ * was undone does not look like a history that never happened (T12).
20
+ */
21
+ import { getLogger } from '../logging/logger.js';
22
+ import { mintBatchId } from '@aragon-agent/tui/model/memory/activity';
23
+ import { MEMORY_LIMITS } from '@aragon-agent/tui/model/memory/limits';
24
+ import { readJournal } from './journal.js';
25
+ import { readNote, restoreNote, restoreVersion, trashNote, } from './store.js';
26
+ function log(event, fields) {
27
+ try {
28
+ getLogger().info('memory', event, fields);
29
+ }
30
+ catch {
31
+ // Logging must never fail an undo.
32
+ }
33
+ }
34
+ /** Every row this scope can see, newest first, bounded by the seed scan cap. */
35
+ function visibleRows(service) {
36
+ const rows = [];
37
+ for (const target of service.targets()) {
38
+ rows.push(...readJournal(target, MEMORY_LIMITS.journalSeedScanMax).entries);
39
+ }
40
+ return rows.sort((a, b) => b.at - a.at);
41
+ }
42
+ /** The newest batch the agent applied, or `null` when there is nothing to undo. */
43
+ export function latestBatch(service) {
44
+ const found = visibleRows(service).find((row) => row.actor === 'agent' && row.op !== 'undo');
45
+ return found?.batch ?? null;
46
+ }
47
+ /** One batch's still-applied rows, NEWEST first - the order an undo has to walk in (D-15). */
48
+ export function batchRows(service, batch) {
49
+ // Descending, and the reader's own tie order is kept. Rows of one batch routinely share a
50
+ // millisecond, and sorting ASCENDING then reversing put those ties back in newest-first order -
51
+ // undoing a note's two edits the wrong way round. Walking a newest-first list as it stands is the
52
+ // same rule with no reversal left to get wrong.
53
+ return visibleRows(service)
54
+ .filter((row) => row.batch === batch && row.op !== 'undo')
55
+ .sort((a, b) => b.at - a.at);
56
+ }
57
+ /**
58
+ * Undo one batch.
59
+ *
60
+ * `batchId` defaults to the newest agent batch. Nothing is written when the batch is empty or when
61
+ * every row is skipped, and `noteChanged()` runs once for the whole undo rather than per row - the
62
+ * prompt is rebuilt from a snapshot, and six rebuild triggers would be six needless invalidations.
63
+ */
64
+ export function undoBatch(service, args = {}) {
65
+ const batch = args.batchId ?? latestBatch(service) ?? '';
66
+ if (batch === '') {
67
+ return { ok: false, code: 'not_found', undone: 0, skipped: [], batch: '' };
68
+ }
69
+ const rows = batchRows(service, batch);
70
+ if (rows.length === 0) {
71
+ return { ok: false, code: 'not_found', undone: 0, skipped: [], batch };
72
+ }
73
+ const undoBatchId = mintBatchId();
74
+ const skipped = [];
75
+ const restored = [];
76
+ let undone = 0;
77
+ for (const row of rows) {
78
+ const outcome = undoRow(service, row);
79
+ if (!outcome.ok) {
80
+ skipped.push({ id: row.id, code: outcome.code });
81
+ continue;
82
+ }
83
+ undone += 1;
84
+ // A RESTORED NOTE THAT CAME BACK UNDER A NEW ID IS REPORTED (spec 8.2). The store renames the id
85
+ // when the old one is taken, and without this the user would be told "restored" while the note
86
+ // they were looking for is still missing under the name they know.
87
+ if (outcome.restoredId !== undefined && outcome.restoredId !== row.id) {
88
+ restored.push({ from: row.id, to: outcome.restoredId });
89
+ }
90
+ service.journalAppend({
91
+ actor: 'user',
92
+ batch: undoBatchId,
93
+ op: 'undo',
94
+ id: row.id,
95
+ scope: row.scope,
96
+ title: row.title,
97
+ delta: row.delta === null ? null : -row.delta,
98
+ rev: outcome.rev,
99
+ prev: null,
100
+ trash: null,
101
+ of: batch,
102
+ });
103
+ }
104
+ if (undone > 0)
105
+ service.noteChanged();
106
+ log('batch_undone', { batch, undone, skipped: skipped.length, by: args.reason ?? 'user' });
107
+ const allBlocked = undone === 0;
108
+ // WHICH CODE, WHEN NOTHING WAS UNDONE (spec 8.2). "Every row was already gone" and "every row's
109
+ // earlier version has been pruned" and "someone else changed these notes" are three different
110
+ // answers, and telling a user `conflict` when nothing ever conflicted sends them looking for an edit
111
+ // that did not happen. `not_found` was in the declared union and was never produced.
112
+ const only = (code) => skipped.every((row) => row.code === code);
113
+ const code = !allBlocked
114
+ ? undefined
115
+ : only('not_found')
116
+ ? 'not_found'
117
+ : only('undo_unavailable')
118
+ ? 'undo_unavailable'
119
+ : 'conflict';
120
+ return {
121
+ ok: undone > 0,
122
+ ...(code !== undefined ? { code } : {}),
123
+ undone,
124
+ skipped,
125
+ // Absent, not empty: an outcome with nothing to report must compare equal to the shape callers
126
+ // knew before this field existed (a restored-under-a-new-id row is the exception, not the rule).
127
+ ...(restored.length > 0 ? { restored } : {}),
128
+ batch,
129
+ };
130
+ }
131
+ /** One row's inverse. Every branch is a `MemoryResult` check; nothing here throws. */
132
+ function undoRow(service, row) {
133
+ const target = service.targetOf(row.scope);
134
+ const current = readNote(target, row.id);
135
+ const opts = service.writeOptions('user');
136
+ if (row.op === 'create') {
137
+ // Gone already: nothing to undo, and saying so is better than reporting a failure.
138
+ if (!current.ok)
139
+ return { ok: false, code: 'not_found' };
140
+ if (current.value.rev !== row.rev)
141
+ return { ok: false, code: 'conflict' };
142
+ const trashed = trashNote(target, row.id, current.value.rev, opts.now ?? Date.now());
143
+ return trashed.ok ? { ok: true, rev: row.rev } : { ok: false, code: trashed.code };
144
+ }
145
+ if (row.op === 'update') {
146
+ if (row.prev === null)
147
+ return { ok: false, code: 'undo_unavailable' };
148
+ if (!current.ok)
149
+ return { ok: false, code: current.code };
150
+ const restored = restoreVersion(target, row.id, row.prev, current.value.rev, opts);
151
+ if (!restored.ok) {
152
+ const code = restored.code === 'not_found' ? 'undo_unavailable' : restored.code;
153
+ return { ok: false, code };
154
+ }
155
+ // `updateNote` refuses a write that would change nothing: identical content means this row is
156
+ // already back where it belongs, which is not a failure and not a change either.
157
+ if (restored.value.rev === current.value.rev)
158
+ return { ok: false, code: 'unchanged' };
159
+ return { ok: true, rev: restored.value.rev };
160
+ }
161
+ // delete
162
+ if (row.trash === null)
163
+ return { ok: false, code: 'undo_unavailable' };
164
+ const back = restoreNote(target, row.trash);
165
+ if (!back.ok)
166
+ return { ok: false, code: back.code };
167
+ // THE RESTORED NOTE'S OWN REV, not its id: the ledger row this produces records a CONTENT HASH
168
+ // in `rev`, and writing an id there would make the activity page (and any later reconciliation)
169
+ // read a hash that never existed. The id travels beside it, because a note that came back under a
170
+ // fresh id is something the user has to be told.
171
+ const restored = readNote(target, back.value.id);
172
+ return { ok: true, rev: restored.ok ? restored.value.rev : '', restoredId: back.value.id };
173
+ }
@@ -13,22 +13,22 @@
13
13
  * `HEADING_ALIASES` exists to bind (RV-P1-2).
14
14
  */
15
15
  import { REDTEAM_PROMPT_LIMITS } from '@aragon-agent/tui/model/redteam/limits';
16
- const PREAMBLE = `<!--
17
- One file, one profile. Rename nothing here unless you also change "name:" below.
18
-
19
- How this file is used
20
- - Every "## <heading>" section REPLACES the built-in text of that section.
21
- - A section you leave empty keeps the built-in text, so an untouched file behaves
22
- exactly like the default mode.
23
- - The sections Authorization, What this mode changes and the closing sentence are NOT
24
- editable: a profile cannot restate what this session is allowed to do. Writing one of
25
- those headings is ignored and reported.
26
- - "mode: replace" drops every SECTION YOU DO NOT WRITE. Leave it as "merge".
27
- - "extends: <slug>" starts from another profile instead of the built-in text.
28
-
29
- Validate before you rely on it: /redteam prompt validate <path>
30
- Switch this session to it: /redteam prompt <slug>
31
- Go back to the default: /redteam prompt builtin
16
+ const PREAMBLE = `<!--
17
+ One file, one profile. Rename nothing here unless you also change "name:" below.
18
+
19
+ How this file is used
20
+ - Every "## <heading>" section REPLACES the built-in text of that section.
21
+ - A section you leave empty keeps the built-in text, so an untouched file behaves
22
+ exactly like the default mode.
23
+ - The sections Authorization, What this mode changes and the closing sentence are NOT
24
+ editable: a profile cannot restate what this session is allowed to do. Writing one of
25
+ those headings is ignored and reported.
26
+ - "mode: replace" drops every SECTION YOU DO NOT WRITE. Leave it as "merge".
27
+ - "extends: <slug>" starts from another profile instead of the built-in text.
28
+
29
+ Validate before you rely on it: /redteam prompt validate <path>
30
+ Switch this session to it: /redteam prompt <slug>
31
+ Go back to the default: /redteam prompt builtin
32
32
  -->`;
33
33
  /** The section list, in the order a reader expects them (not the emission order). */
34
34
  const SECTIONS = [
@@ -496,7 +496,7 @@ export declare const PLAN_MODE_BLOCKED_TOOLS: ReadonlySet<string>;
496
496
  * declaration MEANS, and that reading must not change with how the CLI was
497
497
  * started.
498
498
  */
499
- export declare const HOST_TOOL_NAMES: readonly ["read_file", "write_file", "edit_file", "list_dir", "glob", "grep", "bash", "skill", "skill_find", "skill_install", "skill_create", "ask_user", "submit_plan", "todo_write", "bash_output", "bash_kill", "job_wait", "job_list", "memory_search", "memory_read", "memory_write", "gene_search", "gene_read", "gene_feedback", "gene_run", "submit_result", "task", "team_status", "team_message", "team_pause", "team_resume", "team_stop", "team_spawn", "team_collect"];
499
+ export declare const HOST_TOOL_NAMES: readonly ["read_file", "write_file", "edit_file", "list_dir", "glob", "grep", "bash", "skill", "skill_find", "skill_install", "skill_create", "ask_user", "submit_plan", "todo_write", "bash_output", "bash_kill", "job_wait", "job_list", "memory_search", "memory_read", "memory_write", "memory_batch", "gene_search", "gene_read", "gene_feedback", "gene_run", "submit_result", "task", "team_status", "team_message", "team_pause", "team_resume", "team_stop", "team_spawn", "team_collect"];
500
500
  /**
501
501
  * The three memory tools, as one constant (agent-memory 7.1).
502
502
  *
@@ -504,7 +504,7 @@ export declare const HOST_TOOL_NAMES: readonly ["read_file", "write_file", "edit
504
504
  * headless path never registers these tools, so reserving their names would only reject
505
505
  * caller tools that are perfectly legitimate (`memory_search` is a very common name).
506
506
  */
507
- export declare const MEMORY_TOOL_NAMES: readonly ["memory_search", "memory_read", "memory_write"];
507
+ export declare const MEMORY_TOOL_NAMES: readonly ["memory_search", "memory_read", "memory_write", "memory_batch"];
508
508
  /**
509
509
  * The four gene-library tools, as one constant (gene-bank 9.1 / RV-13).
510
510
  *
@@ -191,6 +191,9 @@ export const PLAN_MODE_BLOCKED_TOOLS = new Set([
191
191
  // still save with Ctrl+M / `/memory save` (a UI action, not a tool call), and the tool's
192
192
  // description tells the model to say so.
193
193
  'memory_write',
194
+ // `memory_batch` is the same write, N times, under one approval: blocking one and not the other
195
+ // would leave plan mode with a bulk back door (memory-agent-autonomy D-10 / I-7).
196
+ 'memory_batch',
194
197
  // `gene_run` EXECUTES A COMMAND (gene-bank I-15): it is `bash` with a validated argv, so it
195
198
  // is refused in plan mode exactly as `bash` is. The gate sits on the tool AND on the `bash`
196
199
  // it delegates to, so neither route reaches the shell.
@@ -251,6 +254,10 @@ export const HOST_TOOL_NAMES = [
251
254
  'memory_search',
252
255
  'memory_read',
253
256
  'memory_write',
257
+ // The bulk write joins the superset for the same reason the three above are here
258
+ // (memory-agent-autonomy D-10): a skill's `allowed-tools: [memory_batch]` has to be answerable
259
+ // by `skills doctor`, and `--allow-tool memory_batch` validates against THIS list.
260
+ 'memory_batch',
254
261
  'gene_search',
255
262
  'gene_read',
256
263
  'gene_feedback',
@@ -291,7 +298,15 @@ export const HOST_TOOL_NAMES = [
291
298
  * headless path never registers these tools, so reserving their names would only reject
292
299
  * caller tools that are perfectly legitimate (`memory_search` is a very common name).
293
300
  */
294
- export const MEMORY_TOOL_NAMES = ['memory_search', 'memory_read', 'memory_write'];
301
+ export const MEMORY_TOOL_NAMES = [
302
+ 'memory_search',
303
+ 'memory_read',
304
+ 'memory_write',
305
+ // The bulk entry point (memory-agent-autonomy D-10): one approval covers a whole plan, which is
306
+ // exactly what a plan-mode session must not be able to spend, and exactly the name `exec`'s
307
+ // reserved set has to subtract.
308
+ 'memory_batch',
309
+ ];
295
310
  /**
296
311
  * The four gene-library tools, as one constant (gene-bank 9.1 / RV-13).
297
312
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aragon-agent/cli",
3
- "version": "0.6.70",
3
+ "version": "0.6.72",
4
4
  "description": "AragonAgent CLI — a Claude-Code / Codex-style interactive terminal UI (TUI) on top of the @aragon-agent/core engine. Installable and runnable via npm / npx.",
5
5
  "license": "MIT",
6
6
  "author": "AragonAgent contributors",
@@ -58,8 +58,8 @@
58
58
  "prepublishOnly": "npm run build"
59
59
  },
60
60
  "dependencies": {
61
- "@aragon-agent/core": "^0.2.82",
62
- "@aragon-agent/tui": "0.0.23",
61
+ "@aragon-agent/core": "^0.2.84",
62
+ "@aragon-agent/tui": "0.0.25",
63
63
  "commander": "^12.1.0",
64
64
  "dotenv": "^16.6.1",
65
65
  "env-paths": "^3.0.0",
@@ -1,62 +1,62 @@
1
- 'use strict';
2
-
3
- const INSECURE_TLS_WARNING =
4
- "Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' " +
5
- 'makes TLS connections and HTTPS requests insecure by disabling ' +
6
- 'certificate verification.';
7
-
8
- const FILTER_STATE_KEY = Symbol.for('@aragon-agent/cli.insecure-tls-warning-filter');
9
-
10
- function installInsecureTlsWarningFilter(target = process) {
11
- const existingState = target[FILTER_STATE_KEY];
12
- if (existingState) return existingState.restore;
13
-
14
- const originalEmitWarning = target.emitWarning;
15
- let installedState;
16
-
17
- function wrappedEmitWarning(warning) {
18
- const message =
19
- typeof warning === 'string'
20
- ? warning
21
- : warning instanceof Error
22
- ? warning.message
23
- : undefined;
24
-
25
- if (
26
- target.env.NODE_TLS_REJECT_UNAUTHORIZED === '0' &&
27
- message === INSECURE_TLS_WARNING
28
- ) {
29
- return;
30
- }
31
-
32
- return Reflect.apply(originalEmitWarning, target, arguments);
33
- }
34
-
35
- function restore() {
36
- if (
37
- target[FILTER_STATE_KEY] !== installedState ||
38
- target.emitWarning !== wrappedEmitWarning
39
- ) {
40
- return;
41
- }
42
-
43
- target.emitWarning = originalEmitWarning;
44
- delete target[FILTER_STATE_KEY];
45
- }
46
-
47
- installedState = {
48
- originalEmitWarning,
49
- wrappedEmitWarning,
50
- restore,
51
- };
52
- target[FILTER_STATE_KEY] = installedState;
53
- target.emitWarning = wrappedEmitWarning;
54
- return restore;
55
- }
56
-
57
- module.exports = {
58
- INSECURE_TLS_WARNING,
59
- installInsecureTlsWarningFilter,
60
- };
61
-
62
- installInsecureTlsWarningFilter();
1
+ 'use strict';
2
+
3
+ const INSECURE_TLS_WARNING =
4
+ "Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' " +
5
+ 'makes TLS connections and HTTPS requests insecure by disabling ' +
6
+ 'certificate verification.';
7
+
8
+ const FILTER_STATE_KEY = Symbol.for('@aragon-agent/cli.insecure-tls-warning-filter');
9
+
10
+ function installInsecureTlsWarningFilter(target = process) {
11
+ const existingState = target[FILTER_STATE_KEY];
12
+ if (existingState) return existingState.restore;
13
+
14
+ const originalEmitWarning = target.emitWarning;
15
+ let installedState;
16
+
17
+ function wrappedEmitWarning(warning) {
18
+ const message =
19
+ typeof warning === 'string'
20
+ ? warning
21
+ : warning instanceof Error
22
+ ? warning.message
23
+ : undefined;
24
+
25
+ if (
26
+ target.env.NODE_TLS_REJECT_UNAUTHORIZED === '0' &&
27
+ message === INSECURE_TLS_WARNING
28
+ ) {
29
+ return;
30
+ }
31
+
32
+ return Reflect.apply(originalEmitWarning, target, arguments);
33
+ }
34
+
35
+ function restore() {
36
+ if (
37
+ target[FILTER_STATE_KEY] !== installedState ||
38
+ target.emitWarning !== wrappedEmitWarning
39
+ ) {
40
+ return;
41
+ }
42
+
43
+ target.emitWarning = originalEmitWarning;
44
+ delete target[FILTER_STATE_KEY];
45
+ }
46
+
47
+ installedState = {
48
+ originalEmitWarning,
49
+ wrappedEmitWarning,
50
+ restore,
51
+ };
52
+ target[FILTER_STATE_KEY] = installedState;
53
+ target.emitWarning = wrappedEmitWarning;
54
+ return restore;
55
+ }
56
+
57
+ module.exports = {
58
+ INSECURE_TLS_WARNING,
59
+ installInsecureTlsWarningFilter,
60
+ };
61
+
62
+ installInsecureTlsWarningFilter();
@@ -1,5 +1,5 @@
1
- export const INSECURE_TLS_WARNING: string;
2
-
3
- export function installInsecureTlsWarningFilter(
4
- target?: NodeJS.Process,
5
- ): () => void;
1
+ export const INSECURE_TLS_WARNING: string;
2
+
3
+ export function installInsecureTlsWarningFilter(
4
+ target?: NodeJS.Process,
5
+ ): () => void;
@@ -1,14 +1,14 @@
1
- ## Workspace Artifact Hygiene
2
-
3
- <!-- project-indexer:artifact-hygiene:begin v1.0.0 -->
4
-
5
- 1. **实验结果归档。** 运行调试、实验、性能比较、模型评估或复现任务产生的日志、指标、图表、截图、报告、导出数据和需要保留的模型输出,统一存放在当前工作区根目录的 `runs/<run-id>/`,不要散落在根目录或业务源码目录。此约定只针对新增任务产物,不修改原有框架配置;工具必须在指定位置运行时,在授权范围内将最终结果归档到 runs,不擅自搬动用户数据。
6
- 2. **按次隔离。** run-id 使用不含路径分隔符和冒号的时间戳加任务短名,例如 `20261105-153000-parser-debug`。目录已存在时追加 `-02`、`-03` 等序号,禁止覆盖已有实验。只在实际产生结果时创建目录,单纯构建索引不创建空的 runs 目录。
7
- 3. **临时文件隔离。** 同一任务的一次性脚本、探针、临时日志、下载中间文件和可重建中间产物放在 `runs/<run-id>/tmp/`。正式源码、测试和需长期维护的复现用例放在项目既有源码或测试目录,不作为临时文件清除。
8
- 4. **保留可复现证据。** 需要保留的结果附简短说明,记录目的、执行命令、必要环境/配置、结论与输出路径,不记录密钥。关闭临时进程、释放文件句柄后再收尾。保留有效结果和必要复现材料,不能为了工作区看起来干净而删除。
9
- 5. **任务结束前检查。** 每次修改或运行操作结束前,检查本轮涉及目录及本轮创建文件,区分交付内容、需要保留的结果和无用临时内容。有 Git 且允许执行时查看 `git status --short` 与相关 diff;同时检查本轮创建但被忽略的路径,因为 Git 状态不会列出它们。无 Git 时用目录检查和本轮创建清单核验。
10
- 6. **只清理属于本轮的垃圾。** 只删除已确认由本轮创建且不再需要的临时文件,保留用户原有文件、其他任务产物、未提交修改、正式测试和实验结果。删除前核对具体路径及归属;禁止根据 tmp、test、debug 名称批量删除,禁止无差别执行 `git clean -fdx` 或清空整个 runs 目录。
11
- 7. **权限边界。** 清理仅使用当前任务已允许的能力;没有删除能力时不要绕过工具限制,明确列出残留路径和原因。索引生成不授予清理任意历史文件的权限;无法确认归属的文件保留并报告。
12
- 8. **交付说明。** 完成回复简述本轮清理情况和保留结果的位置;未检查、无法清理或仍有不明残留时如实说明,不能声称工作区已干净。干净指本轮没有未说明的无用临时文件,不要求抹掉所有 Git 未提交变更。
13
-
14
- <!-- project-indexer:artifact-hygiene:end -->
1
+ ## Workspace Artifact Hygiene
2
+
3
+ <!-- project-indexer:artifact-hygiene:begin v1.0.0 -->
4
+
5
+ 1. **实验结果归档。** 运行调试、实验、性能比较、模型评估或复现任务产生的日志、指标、图表、截图、报告、导出数据和需要保留的模型输出,统一存放在当前工作区根目录的 `runs/<run-id>/`,不要散落在根目录或业务源码目录。此约定只针对新增任务产物,不修改原有框架配置;工具必须在指定位置运行时,在授权范围内将最终结果归档到 runs,不擅自搬动用户数据。
6
+ 2. **按次隔离。** run-id 使用不含路径分隔符和冒号的时间戳加任务短名,例如 `20261105-153000-parser-debug`。目录已存在时追加 `-02`、`-03` 等序号,禁止覆盖已有实验。只在实际产生结果时创建目录,单纯构建索引不创建空的 runs 目录。
7
+ 3. **临时文件隔离。** 同一任务的一次性脚本、探针、临时日志、下载中间文件和可重建中间产物放在 `runs/<run-id>/tmp/`。正式源码、测试和需长期维护的复现用例放在项目既有源码或测试目录,不作为临时文件清除。
8
+ 4. **保留可复现证据。** 需要保留的结果附简短说明,记录目的、执行命令、必要环境/配置、结论与输出路径,不记录密钥。关闭临时进程、释放文件句柄后再收尾。保留有效结果和必要复现材料,不能为了工作区看起来干净而删除。
9
+ 5. **任务结束前检查。** 每次修改或运行操作结束前,检查本轮涉及目录及本轮创建文件,区分交付内容、需要保留的结果和无用临时内容。有 Git 且允许执行时查看 `git status --short` 与相关 diff;同时检查本轮创建但被忽略的路径,因为 Git 状态不会列出它们。无 Git 时用目录检查和本轮创建清单核验。
10
+ 6. **只清理属于本轮的垃圾。** 只删除已确认由本轮创建且不再需要的临时文件,保留用户原有文件、其他任务产物、未提交修改、正式测试和实验结果。删除前核对具体路径及归属;禁止根据 tmp、test、debug 名称批量删除,禁止无差别执行 `git clean -fdx` 或清空整个 runs 目录。
11
+ 7. **权限边界。** 清理仅使用当前任务已允许的能力;没有删除能力时不要绕过工具限制,明确列出残留路径和原因。索引生成不授予清理任意历史文件的权限;无法确认归属的文件保留并报告。
12
+ 8. **交付说明。** 完成回复简述本轮清理情况和保留结果的位置;未检查、无法清理或仍有不明残留时如实说明,不能声称工作区已干净。干净指本轮没有未说明的无用临时文件,不要求抹掉所有 Git 未提交变更。
13
+
14
+ <!-- project-indexer:artifact-hygiene:end -->