@bonesofspring/ai-rules 0.2.84 → 0.2.86

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 (28) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/docs/PRESET-CONTRIBUTION.md +19 -10
  3. package/docs/TEAM-DB.md +76 -3
  4. package/docs/openapi/team-db.v1.json +7069 -5895
  5. package/package.json +5 -2
  6. package/presets/_shared/ai-local/scripts/team-db-api.mjs +253 -15
  7. package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +310 -4
  8. package/presets/_shared/ai-local/scripts/team-db-project.mjs +733 -8
  9. package/presets/_shared/ai-local/scripts/team-db-schema.mjs +44 -0
  10. package/presets/_shared/ai-local/scripts/team-db.mjs +43 -3
  11. package/presets/claude/next/agents/build-verifier.md +2 -1
  12. package/presets/claude/next/agents/feature-developer.md +1 -1
  13. package/presets/cursor/next/agents/build-verifier.md +2 -1
  14. package/presets/cursor/next/agents/feature-developer.md +1 -1
  15. package/presets/mavis/next/adapter-map.json +1 -1
  16. package/presets/mavis/next/agents/build-verifier.md +2 -1
  17. package/presets/mavis/next/agents/feature-developer.md +1 -1
  18. package/presets/opencode/next/adapter-map.json +1 -1
  19. package/presets/opencode/next/agents/build-verifier.md +2 -1
  20. package/presets/opencode/next/agents/feature-developer.md +1 -1
  21. package/presets/opencode/plugins/task-status/README.md +1 -1
  22. package/presets/opencode/plugins/task-status/deepseek.ts +13 -3
  23. package/presets/opencode/plugins/task-status/task-view.ts +4 -1
  24. package/presets/opencode/plugins/task-status/tui.tsx +4 -6
  25. package/presets/opencode/plugins/task-status/types.ts +5 -1
  26. package/presets/zcode/next/adapter-map.json +1 -1
  27. package/presets/zcode/next/agents/build-verifier.md +2 -1
  28. package/presets/zcode/next/agents/feature-developer.md +1 -1
@@ -913,6 +913,44 @@ export const REPOSITORY_ATTRIBUTIONS_SQL = SQL`CREATE TABLE task_repository_attr
913
913
  ) STRICT;
914
914
  `;
915
915
 
916
+ /**
917
+ * Migration 11: the project registry projection. Two tables mirroring the
918
+ * repository registry set; both foreign keys cascade because both endpoints
919
+ * are reader-validated registry records (`project-registry.json` refuses an
920
+ * unknown endpoint), unlike `task_repositories.task_slug`, which deliberately
921
+ * names unprojected folders. `status` stays validated on write, never a
922
+ * `CHECK`: a hand-edited file must still project its row.
923
+ */
924
+ export const PROJECT_REGISTRY_SQL = SQL`CREATE TABLE projects (
925
+ id TEXT PRIMARY KEY,
926
+ name TEXT NOT NULL,
927
+ description TEXT,
928
+ status TEXT NOT NULL,
929
+ revision INTEGER NOT NULL CHECK (revision >= 1),
930
+ created_at TEXT NOT NULL,
931
+ updated_at TEXT NOT NULL,
932
+ content_hash TEXT NOT NULL,
933
+ parse_error TEXT,
934
+ projected_at TEXT NOT NULL,
935
+ first_seen_at TEXT NOT NULL,
936
+ last_seen_at TEXT NOT NULL,
937
+ absent_at TEXT
938
+ ) STRICT;
939
+
940
+ CREATE TABLE project_repositories (
941
+ project_id TEXT NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
942
+ repository_id TEXT NOT NULL REFERENCES repositories(id) ON DELETE CASCADE,
943
+ added_at TEXT NOT NULL,
944
+ content_hash TEXT NOT NULL,
945
+ projected_at TEXT NOT NULL,
946
+ PRIMARY KEY (project_id, repository_id)
947
+ ) STRICT;
948
+
949
+ CREATE INDEX idx_projects_absent ON projects(absent_at);
950
+ CREATE INDEX idx_projects_status_name ON projects(status, name COLLATE NOCASE);
951
+ CREATE INDEX idx_project_repositories_repository ON project_repositories(repository_id);
952
+ `;
953
+
916
954
  const sha256 = (value) => crypto.createHash('sha256').update(value).digest('hex');
917
955
  /**
918
956
  * Ordered, immutable migrations. The literal checksum is verified before any
@@ -979,6 +1017,12 @@ export const MIGRATIONS = [
979
1017
  sql: REPOSITORY_ATTRIBUTIONS_SQL,
980
1018
  checksum: '4677b2b62b5b9c8cb571f5706abac97487175c8251facdab6b42bf2371f2720e',
981
1019
  },
1020
+ {
1021
+ version: 11,
1022
+ name: '0011-project-registry',
1023
+ sql: PROJECT_REGISTRY_SQL,
1024
+ checksum: '46ff23b832f6d4b7891e90c119173b5f5f533ffa4b47dc43ebf6a605de812779',
1025
+ },
982
1026
  ];
983
1027
 
984
1028
  /** Highest migration version shipped by this module. */
@@ -77,6 +77,7 @@ import {
77
77
  LEDGER_HEADER_ROW,
78
78
  listTaskDirectories,
79
79
  parseReviewLedgerMarkdown,
80
+ runProjectsCommand,
80
81
  runRepositoriesCommand,
81
82
  searchProjection,
82
83
  syncProjection,
@@ -116,6 +117,10 @@ const USAGE = `usage:
116
117
  team-db.mjs repositories apply --file <path|-> [--dry-run] [--root <team-dir>] [--json]
117
118
  team-db.mjs repositories put --file <path|-> [--dry-run] [--root <team-dir>] [--json]
118
119
  team-db.mjs repositories delete <id> [--force] [--revision <n>] [--root <team-dir>] [--json]
120
+ team-db.mjs projects put --file <path|-> [--dry-run] [--root <team-dir>] [--json]
121
+ team-db.mjs projects delete <id> [--force] [--revision <n>] [--root <team-dir>] [--json]
122
+ team-db.mjs projects link|unlink <projectId> <repositoryId> [--root <team-dir>] [--json]
123
+ team-db.mjs projects list|project [--root <team-dir>] [--json] [--quiet]
119
124
  team-db.mjs schedule [--root <team-dir>] [--once] [--interval-ms <n>]
120
125
  [--grace-ms <n>] [--drain-ms <n>] [--json] [--quiet]
121
126
  team-db.mjs tracker add --file <path|-> [--root <team-dir>] [--json] [--quiet]
@@ -171,7 +176,7 @@ const BOOLEAN_FLAGS = new Set([
171
176
  'claim',
172
177
  'force',
173
178
  ]);
174
- const COMMANDS = new Set(['init', 'check', 'search', 'sync', 'delete', 'migrate-tasks', 'ledger-check', 'serve', 'jobs', 'schedule', 'tracker', 'task-run', 'repositories']);
179
+ const COMMANDS = new Set(['init', 'check', 'search', 'sync', 'delete', 'migrate-tasks', 'ledger-check', 'serve', 'jobs', 'schedule', 'tracker', 'task-run', 'repositories', 'projects']);
175
180
  const ALLOWED_FLAGS = {
176
181
  init: new Set(['root', 'rebuild']),
177
182
  check: new Set(['root']),
@@ -186,6 +191,7 @@ const ALLOWED_FLAGS = {
186
191
  tracker: new Set(['root', 'json', 'quiet', 'file', 'dry-run', 'older-than', 'status', 'ready', 'claim']),
187
192
  'task-run': new Set(['root', 'json', 'task', 'item', 'link', 'run']),
188
193
  repositories: new Set(['root', 'json', 'quiet', 'file', 'dry-run', 'force', 'revision']),
194
+ projects: new Set(['root', 'json', 'quiet', 'file', 'dry-run', 'force', 'revision']),
189
195
  };
190
196
 
191
197
  const JOBS_POSITIONALS = new Set([
@@ -222,11 +228,14 @@ const TASK_RUN_POSITIONALS = new Set(['start', 'stop', 'supervise', 'list', 'sho
222
228
 
223
229
  const REPOSITORIES_POSITIONALS = new Set(['list', 'project', 'apply', 'put', 'delete']);
224
230
 
231
+ const PROJECTS_POSITIONALS = new Set(['list', 'project', 'put', 'delete', 'link', 'unlink']);
232
+
225
233
  const POSITIONAL_VERBS = {
226
234
  jobs: JOBS_POSITIONALS,
227
235
  tracker: TRACKER_POSITIONALS,
228
236
  'task-run': TASK_RUN_POSITIONALS,
229
237
  repositories: REPOSITORIES_POSITIONALS,
238
+ projects: PROJECTS_POSITIONALS,
230
239
  };
231
240
 
232
241
  const parseArgs = (argv) => {
@@ -248,9 +257,11 @@ const parseArgs = (argv) => {
248
257
  continue;
249
258
  }
250
259
  // `jobs <verb> [id]`, `tracker <verb> [id|entryId]` and `task-run <verb>`
251
- // are the only commands with positional arguments.
260
+ // are the only commands with positional arguments; `projects link|unlink
261
+ // <projectId> <repositoryId>` is the one family that carries two.
252
262
  const verbs = POSITIONAL_VERBS[command];
253
- if (verbs && positionals.length < 2) {
263
+ const positionalCap = command === 'projects' ? 3 : 2;
264
+ if (verbs && positionals.length < positionalCap) {
254
265
  if (positionals.length === 0 && !verbs.has(token)) {
255
266
  teamDbFail('E_USAGE', `unknown ${command} subcommand "${token}"`, 3);
256
267
  }
@@ -618,6 +629,34 @@ const runRepositories = (flags, positionals) => {
618
629
  }
619
630
  };
620
631
 
632
+ const runProjects = (flags, positionals) => {
633
+ const [subcommand = 'list', firstId, secondId] = positionals;
634
+ try {
635
+ const result = runProjectsCommand(subcommand, [firstId, secondId].filter((entry) => entry !== undefined), {
636
+ root: flags.root,
637
+ json: Boolean(flags.json),
638
+ quiet: Boolean(flags.quiet),
639
+ file: flags.file,
640
+ dryRun: Boolean(flags['dry-run']),
641
+ force: Boolean(flags.force),
642
+ revision: flags.revision === undefined ? undefined : Number(flags.revision),
643
+ });
644
+ if (result.output) process.stdout.write(result.output);
645
+ return result.exitCode;
646
+ } catch (error) {
647
+ const code = error instanceof TeamDbError ? error.code : 'E_INTERNAL';
648
+ const exitCode = error instanceof TeamDbError ? error.exitCode : 2;
649
+ const failure = { ok: false, code, message: error.message };
650
+ if (error instanceof TeamDbError && typeof error.parameter === 'string') failure.parameter = error.parameter;
651
+ // The delete guard names the member count; the API lifts it into
652
+ // `details.memberRepositories` without parsing prose.
653
+ if (error && Number.isInteger(error.memberRepositories)) failure.memberRepositories = error.memberRepositories;
654
+ if (flags.json) process.stdout.write(`${JSON.stringify(failure)}\n`);
655
+ process.stderr.write(`${error.message}\n`);
656
+ return exitCode;
657
+ }
658
+ };
659
+
621
660
  const runTaskRunner = async (flags, positionals) => {
622
661
  const [subcommand = 'status'] = positionals;
623
662
  try {
@@ -784,6 +823,7 @@ export async function runCli(argv) {
784
823
  if (command === 'serve') return runServe(flags);
785
824
  if (command === 'jobs') return runJobs(flags, positionals);
786
825
  if (command === 'repositories') return runRepositories(flags, positionals);
826
+ if (command === 'projects') return runProjects(flags, positionals);
787
827
  if (command === 'tracker') return runTracker(flags, positionals);
788
828
  if (command === 'task-run') return runTaskRunner(flags, positionals);
789
829
  if (command === 'schedule') return runSchedule(flags);
@@ -54,7 +54,8 @@ Use **`package-manager.md`** for the repo package manager.
54
54
 
55
55
  Prefer **`lint`** (= js + css + type-check) before handoff on large changes. Do not re-run a green command with unchanged inputs; record the skipped row and its base.
56
56
 
57
- - **Preset twin/golden DoD (preset source repo only).** When the change-set edits Cursor next agents and/or `presets/_shared/hooks/**` (or other generated twin surfaces), require `node scripts/fix-generated.mjs` then `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names from `packages/ai-rules` with exit 0 before validation PASS. The full `yarn release:gate` is release-only.
57
+ - **Preset twin/golden DoD (preset source repo only).** When the change-set edits preset source, require `node scripts/fix-generated.mjs`, then run `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names, exit 0, before validation PASS. This step is the only owner of those exit rows. `yarn release:gate` is release-only.
58
+ - **AC evidence.** `validation-report.md` includes `## AC evidence`. One bullet per AC sentence: the `AC-n` id when the brief has one, the sentence, and either a test path in backticks or `gap:` plus why no test exists. `check-task-receipt.mjs` fails a report that omits the section, a row, or a brief id.
58
59
 
59
60
  ## Delta gate policy (retry / carry-forward)
60
61
 
@@ -78,7 +78,7 @@ Load `dev-process-lifecycle` before starting, reusing, or stopping a dev server,
78
78
  - L0, docs-only, research, and preset-only tasks do not take the rail. `build-verifier` and `code-reviewer` stay.
79
79
  - Mark completed tasks in `decomposition.md`.
80
80
  - Validation: **`post-change-lint.md`** is the closure gate. Do **not** run project lint/type-check/test/build in this step; hand off with the diff and authored specs. `build-verifier` owns the full run.
81
- - **Preset twin/golden DoD (preset source repo only).** When the change-set edits Cursor next agents and/or `presets/_shared/hooks/**` (or other surfaces that require generated twins), from `packages/ai-rules` run `node scripts/fix-generated.mjs` then `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names (exit 0) before implementation handoff. The full `yarn release:gate` is release-only.
81
+ - **Preset twin/golden DoD (preset source repo only).** When the change-set edits preset source, regenerate twins with `node scripts/fix-generated.mjs`. Do not run the classifier set in this step. `build-verifier` runs `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names, and owns the exit rows. `yarn release:gate` is release-only.
82
82
 
83
83
  ## Zero improvisation
84
84
 
@@ -34,7 +34,8 @@ Use **`package-manager.mdc`** for the repo package manager.
34
34
 
35
35
  Prefer **`lint`** (= js + css + type-check) before handoff on large changes. Do not re-run a green command with unchanged inputs; record the skipped row and its base.
36
36
 
37
- - **Preset twin/golden DoD (preset source repo only).** When the change-set edits Cursor next agents and/or `presets/_shared/hooks/**` (or other generated twin surfaces), require `node scripts/fix-generated.mjs` then `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names from `packages/ai-rules` with exit 0 before validation PASS. The full `yarn release:gate` is release-only.
37
+ - **Preset twin/golden DoD (preset source repo only).** When the change-set edits preset source, require `node scripts/fix-generated.mjs`, then run `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names, exit 0, before validation PASS. This step is the only owner of those exit rows. `yarn release:gate` is release-only.
38
+ - **AC evidence.** `validation-report.md` includes `## AC evidence`. One bullet per AC sentence: the `AC-n` id when the brief has one, the sentence, and either a test path in backticks or `gap:` plus why no test exists. `check-task-receipt.mjs` fails a report that omits the section, a row, or a brief id.
38
39
 
39
40
  ## Delta gate policy (retry / carry-forward)
40
41
 
@@ -41,7 +41,7 @@ Load `dev-process-lifecycle` before starting, reusing, or stopping a dev server,
41
41
  - L0, docs-only, research, and preset-only tasks do not take the rail. `build-verifier` and `code-reviewer` stay.
42
42
  - Mark completed tasks in `decomposition.md`.
43
43
  - Validation: **`post-change-lint.mdc`** is the closure gate. Do **not** run project lint/type-check/test/build in this step; hand off with the diff and authored specs. `build-verifier` owns the full run.
44
- - **Preset twin/golden DoD (preset source repo only).** When the change-set edits Cursor next agents and/or `presets/_shared/hooks/**` (or other surfaces that require generated twins), from `packages/ai-rules` run `node scripts/fix-generated.mjs` then `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names (exit 0) before implementation handoff. The full `yarn release:gate` is release-only.
44
+ - **Preset twin/golden DoD (preset source repo only).** When the change-set edits preset source, regenerate twins with `node scripts/fix-generated.mjs`. Do not run the classifier set in this step. `build-verifier` runs `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names, and owns the exit rows. `yarn release:gate` is release-only.
45
45
 
46
46
  ## Zero improvisation
47
47
 
@@ -3,7 +3,7 @@
3
3
  "platform": "mavis",
4
4
  "stack": "next",
5
5
  "semanticSource": "cursor/next",
6
- "sourceRevision": "e31430798b81e4b9e5ad1d6cc30a2e62354f7b8d4b0aa457f12b723fe37b5f5d",
6
+ "sourceRevision": "0cfd6b267fbe49043eab08c427db9288e1546842429581db3d2e69d088428f6b",
7
7
  "entries": [
8
8
  {
9
9
  "source": "AGENTS.md",
@@ -48,7 +48,8 @@ Use **`package-manager.md`** for the repo package manager.
48
48
 
49
49
  Prefer **`lint`** (= js + css + type-check) before handoff on large changes. Do not re-run a green command with unchanged inputs; record the skipped row and its base.
50
50
 
51
- - **Preset twin/golden DoD (preset source repo only).** When the change-set edits Cursor next agents and/or `presets/_shared/hooks/**` (or other generated twin surfaces), require `node scripts/fix-generated.mjs` then `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names from `packages/ai-rules` with exit 0 before validation PASS. The full `yarn release:gate` is release-only.
51
+ - **Preset twin/golden DoD (preset source repo only).** When the change-set edits preset source, require `node scripts/fix-generated.mjs`, then run `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names, exit 0, before validation PASS. This step is the only owner of those exit rows. `yarn release:gate` is release-only.
52
+ - **AC evidence.** `validation-report.md` includes `## AC evidence`. One bullet per AC sentence: the `AC-n` id when the brief has one, the sentence, and either a test path in backticks or `gap:` plus why no test exists. `check-task-receipt.mjs` fails a report that omits the section, a row, or a brief id.
52
53
 
53
54
  ## Delta gate policy (retry / carry-forward)
54
55
 
@@ -73,7 +73,7 @@ Load `dev-process-lifecycle` before starting, reusing, or stopping a dev server,
73
73
  - L0, docs-only, research, and preset-only tasks do not take the rail. `build-verifier` and `code-reviewer` stay.
74
74
  - Mark completed tasks in `decomposition.md`.
75
75
  - Validation: **`post-change-lint.md`** is the closure gate. Do **not** run project lint/type-check/test/build in this step; hand off with the diff and authored specs. `build-verifier` owns the full run.
76
- - **Preset twin/golden DoD (preset source repo only).** When the change-set edits Cursor next agents and/or `presets/_shared/hooks/**` (or other surfaces that require generated twins), from `packages/ai-rules` run `node scripts/fix-generated.mjs` then `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names (exit 0) before implementation handoff. The full `yarn release:gate` is release-only.
76
+ - **Preset twin/golden DoD (preset source repo only).** When the change-set edits preset source, regenerate twins with `node scripts/fix-generated.mjs`. Do not run the classifier set in this step. `build-verifier` runs `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names, and owns the exit rows. `yarn release:gate` is release-only.
77
77
 
78
78
  ## Zero improvisation
79
79
 
@@ -3,7 +3,7 @@
3
3
  "platform": "opencode",
4
4
  "stack": "next",
5
5
  "semanticSource": "cursor/next",
6
- "sourceRevision": "e31430798b81e4b9e5ad1d6cc30a2e62354f7b8d4b0aa457f12b723fe37b5f5d",
6
+ "sourceRevision": "0cfd6b267fbe49043eab08c427db9288e1546842429581db3d2e69d088428f6b",
7
7
  "entries": [
8
8
  {
9
9
  "source": "AGENTS.md",
@@ -60,7 +60,8 @@ Use **`package-manager.md`** for the repo package manager.
60
60
 
61
61
  Prefer **`lint`** (= js + css + type-check) before handoff on large changes. Do not re-run a green command with unchanged inputs; record the skipped row and its base.
62
62
 
63
- - **Preset twin/golden DoD (preset source repo only).** When the change-set edits Cursor next agents and/or `presets/_shared/hooks/**` (or other generated twin surfaces), require `node scripts/fix-generated.mjs` then `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names from `packages/ai-rules` with exit 0 before validation PASS. The full `yarn release:gate` is release-only.
63
+ - **Preset twin/golden DoD (preset source repo only).** When the change-set edits preset source, require `node scripts/fix-generated.mjs`, then run `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names, exit 0, before validation PASS. This step is the only owner of those exit rows. `yarn release:gate` is release-only.
64
+ - **AC evidence.** `validation-report.md` includes `## AC evidence`. One bullet per AC sentence: the `AC-n` id when the brief has one, the sentence, and either a test path in backticks or `gap:` plus why no test exists. `check-task-receipt.mjs` fails a report that omits the section, a row, or a brief id.
64
65
 
65
66
  ## Delta gate policy (retry / carry-forward)
66
67
 
@@ -81,7 +81,7 @@ Load `dev-process-lifecycle` before starting, reusing, or stopping a dev server,
81
81
  - L0, docs-only, research, and preset-only tasks do not take the rail. `build-verifier` and `code-reviewer` stay.
82
82
  - Mark completed tasks in `decomposition.md`.
83
83
  - Validation: **`post-change-lint.md`** is the closure gate. Do **not** run project lint/type-check/test/build in this step; hand off with the diff and authored specs. `build-verifier` owns the full run.
84
- - **Preset twin/golden DoD (preset source repo only).** When the change-set edits Cursor next agents and/or `presets/_shared/hooks/**` (or other surfaces that require generated twins), from `packages/ai-rules` run `node scripts/fix-generated.mjs` then `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names (exit 0) before implementation handoff. The full `yarn release:gate` is release-only.
84
+ - **Preset twin/golden DoD (preset source repo only).** When the change-set edits preset source, regenerate twins with `node scripts/fix-generated.mjs`. Do not run the classifier set in this step. `build-verifier` runs `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names, and owns the exit rows. `yarn release:gate` is release-only.
85
85
 
86
86
  ## Zero improvisation
87
87
 
@@ -92,7 +92,7 @@ No build, no dependencies:
92
92
 
93
93
  Relative imports carry explicit `.ts` / `.tsx` extensions. A local plugin directory resolves files rather than the package `exports` map, and an extensionless import of a `.tsx` sibling is skipped by the loader without a message.
94
94
 
95
- Do not import `solid-js` here. A local plugin resolves its own copy, and signals created by that copy are not tracked by the host renderer, so the UI renders once and never updates. Reactive state goes through `context.storage.memory`, refreshed once per second.
95
+ Do not import `solid-js` here. A local plugin resolves its own copy, and signals created by that copy are not tracked by the host renderer, so the UI renders once and never updates. Reactive state goes through `context.storage.memory`, refreshed once per second. The billing rows read `taskStore.tick` inside `content()`, so they follow that same write.
96
96
 
97
97
  ## Update
98
98
 
@@ -144,17 +144,22 @@ const loadPeakWindows = (providerName: string, root: string): readonly PeakWindo
144
144
  return peak.length > 0 ? peak : null
145
145
  }
146
146
 
147
- let cache: { key: string; atMs: number; windows: readonly PeakWindow[] } | undefined
147
+ const cache = new Map<string, { atMs: number; windows: readonly PeakWindow[] }>()
148
+
149
+ export const clearPeakWindowCache = (): void => {
150
+ cache.clear()
151
+ }
148
152
 
149
153
  const peakWindows = (providerName: string, directory: string | undefined): readonly PeakWindow[] => {
150
154
  const fallback = DEFAULT_WINDOWS[providerName] ?? []
151
155
  const root = resolveModelsRoot(directory)
152
156
  if (root === undefined) return fallback
153
157
  const key = `${providerName}|${root}`
154
- if (cache?.key === key && Date.now() - cache.atMs < MODELS_TTL_MS) return cache.windows
158
+ const hit = cache.get(key)
159
+ if (hit !== undefined && Date.now() - hit.atMs < MODELS_TTL_MS) return hit.windows
155
160
 
156
161
  const windows = loadPeakWindows(providerName, root) ?? fallback
157
- cache = { key, atMs: Date.now(), windows }
162
+ cache.set(key, { atMs: Date.now(), windows })
158
163
  return windows
159
164
  }
160
165
 
@@ -215,3 +220,8 @@ export const deepseekRate = (now: Date, directory?: string): DeepseekRate =>
215
220
 
216
221
  export const zaiRate = (now: Date, directory?: string): DeepseekRate =>
217
222
  providerRate("Z.AI", now, directory)
223
+
224
+ export const billingRates = (at: Date, directory?: string) => [
225
+ { label: "DeepSeek" as const, rate: deepseekRate(at, directory) },
226
+ { label: "Z.AI" as const, rate: zaiRate(at, directory) },
227
+ ]
@@ -781,7 +781,7 @@ const economyForSession = (root: string, sessionID: string): SessionEconomy => {
781
781
  }
782
782
 
783
783
  export const createTaskWatcher = (storage: MemoryStorage, options: TaskWatcherOptions) => {
784
- const [state, update] = storage.memory<TaskStore>("view", { initial: { view: undefined } })
784
+ const [state, update] = storage.memory<TaskStore>("view", { initial: { view: undefined, tick: 0 } })
785
785
  let index: PromptEntry[] = []
786
786
  let indexAt = 0
787
787
  let etaStats: EtaStats | undefined
@@ -857,6 +857,7 @@ export const createTaskWatcher = (storage: MemoryStorage, options: TaskWatcherOp
857
857
  update((draft) => {
858
858
  draft.view = undefined
859
859
  draft.economy = undefined
860
+ draft.tick = now
860
861
  })
861
862
  return
862
863
  }
@@ -874,6 +875,7 @@ export const createTaskWatcher = (storage: MemoryStorage, options: TaskWatcherOp
874
875
  update((draft) => {
875
876
  draft.view = undefined
876
877
  draft.economy = undefined
878
+ draft.tick = now
877
879
  })
878
880
  return
879
881
  }
@@ -905,6 +907,7 @@ export const createTaskWatcher = (storage: MemoryStorage, options: TaskWatcherOp
905
907
  update((draft) => {
906
908
  draft.view = view
907
909
  draft.economy = economy
910
+ draft.tick = now
908
911
  })
909
912
  logTaskDebug(
910
913
  `session=${sessionID} messages=${current.texts.length} matched=${view.slug ?? "-"} view=${view.summary}`,
@@ -1,11 +1,11 @@
1
1
  import { Plugin, usePlugin } from "@opencode/plugin/tui"
2
- import { deepseekRate, zaiRate } from "./deepseek.ts"
2
+ import { billingRates } from "./deepseek.ts"
3
3
  import { sessionEconomy } from "./economy.ts"
4
4
  import { clearPause, createTaskWatcher, engagePause, logTaskDebug } from "./task-view.ts"
5
5
  import { TaskDetails } from "./details.tsx"
6
6
  import type { TaskStore, TaskTone } from "./task-view.ts"
7
7
 
8
- let taskStore: TaskStore = { view: undefined }
8
+ let taskStore: TaskStore = { view: undefined, tick: 0 }
9
9
  let slot: { readonly sessionID?: string } | undefined
10
10
  let lastSessionKey = ""
11
11
  // Rebound in setup(); the DeepSeek rate reads the catalog under the live project directory.
@@ -25,10 +25,6 @@ const TaskSidebar = () => {
25
25
 
26
26
  const rateColor = (rate: string) =>
27
27
  rate === "peak" ? theme.text.feedback.error.base : theme.text.feedback.success.base
28
- const billingRows = [
29
- { label: "DeepSeek", rate: deepseekRate(new Date(), projectDirectory()) },
30
- { label: "Z.AI", rate: zaiRate(new Date(), projectDirectory()) },
31
- ]
32
28
 
33
29
  const toggle = () => {
34
30
  void updatePanel((draft) => {
@@ -84,6 +80,8 @@ const TaskSidebar = () => {
84
80
 
85
81
  const content = () => {
86
82
  const view = taskStore.view
83
+ const at = new Date(taskStore.tick || Date.now())
84
+ const billingRows = billingRates(at, projectDirectory())
87
85
  if (view === undefined) return null
88
86
  const economy = taskStore.economy ?? sessionEconomy("", [])
89
87
  return (
@@ -18,7 +18,11 @@ export type TaskView = {
18
18
  offline?: boolean
19
19
  }
20
20
 
21
- export type TaskStore = { view: TaskView | null | undefined; economy?: SessionEconomy }
21
+ export type TaskStore = {
22
+ view: TaskView | null | undefined
23
+ economy?: SessionEconomy
24
+ tick: number
25
+ }
22
26
 
23
27
  export type Attempt = {
24
28
  agent?: string
@@ -3,7 +3,7 @@
3
3
  "platform": "zcode",
4
4
  "stack": "next",
5
5
  "semanticSource": "cursor/next",
6
- "sourceRevision": "e31430798b81e4b9e5ad1d6cc30a2e62354f7b8d4b0aa457f12b723fe37b5f5d",
6
+ "sourceRevision": "0cfd6b267fbe49043eab08c427db9288e1546842429581db3d2e69d088428f6b",
7
7
  "entries": [
8
8
  {
9
9
  "source": "AGENTS.md",
@@ -55,7 +55,8 @@ Use **`package-manager.md`** for the repo package manager.
55
55
 
56
56
  Prefer **`lint`** (= js + css + type-check) before handoff on large changes. Do not re-run a green command with unchanged inputs; record the skipped row and its base.
57
57
 
58
- - **Preset twin/golden DoD (preset source repo only).** When the change-set edits Cursor next agents and/or `presets/_shared/hooks/**` (or other generated twin surfaces), require `node scripts/fix-generated.mjs` then `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names from `packages/ai-rules` with exit 0 before validation PASS. The full `yarn release:gate` is release-only.
58
+ - **Preset twin/golden DoD (preset source repo only).** When the change-set edits preset source, require `node scripts/fix-generated.mjs`, then run `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names, exit 0, before validation PASS. This step is the only owner of those exit rows. `yarn release:gate` is release-only.
59
+ - **AC evidence.** `validation-report.md` includes `## AC evidence`. One bullet per AC sentence: the `AC-n` id when the brief has one, the sentence, and either a test path in backticks or `gap:` plus why no test exists. `check-task-receipt.mjs` fails a report that omits the section, a row, or a brief id.
59
60
 
60
61
  ## Delta gate policy (retry / carry-forward)
61
62
 
@@ -78,7 +78,7 @@ Load `dev-process-lifecycle` before starting, reusing, or stopping a dev server,
78
78
  - L0, docs-only, research, and preset-only tasks do not take the rail. `build-verifier` and `code-reviewer` stay.
79
79
  - Mark completed tasks in `decomposition.md`.
80
80
  - Validation: **`post-change-lint.md`** is the closure gate. Do **not** run project lint/type-check/test/build in this step; hand off with the diff and authored specs. `build-verifier` owns the full run.
81
- - **Preset twin/golden DoD (preset source repo only).** When the change-set edits Cursor next agents and/or `presets/_shared/hooks/**` (or other surfaces that require generated twins), from `packages/ai-rules` run `node scripts/fix-generated.mjs` then `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names (exit 0) before implementation handoff. The full `yarn release:gate` is release-only.
81
+ - **Preset twin/golden DoD (preset source repo only).** When the change-set edits preset source, regenerate twins with `node scripts/fix-generated.mjs`. Do not run the classifier set in this step. `build-verifier` runs `yarn check:task <slug>` (or `yarn check:changed` on a clean tree) and the gates it names, and owns the exit rows. `yarn release:gate` is release-only.
82
82
 
83
83
  ## Zero improvisation
84
84