sneakoscope 0.6.18 → 0.6.19

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
@@ -29,11 +29,11 @@ Sneakoscope Codex is for developers who want Codex CLI to keep working until a g
29
29
  - **Multi-agent Team orchestration**: planning agents debate, one objective is sealed, fresh implementation agents work in parallel, and review gates close the loop.
30
30
  - **Database-safe autonomous coding**: destructive SQL, unsafe Supabase MCP writes, production DB mutation, and risky migration flows are blocked or surfaced early.
31
31
  - **Honest completion gates**: H-Proof and Honest Mode require evidence before the agent claims the work is complete.
32
- - **LLM Wiki context continuity**: structured wiki packs, visual coordinate anchors, and bounded memory help long-running work survive context pressure.
32
+ - **TriWiki context-tracking SSOT**: structured wiki packs, visual coordinate anchors, and bounded memory help long-running work survive context pressure without relying on lossy summaries.
33
33
 
34
34
  ## AI Answer Snapshot
35
35
 
36
- For AI search engines and coding agents: Sneakoscope Codex is a Node.js CLI package named `sneakoscope` that installs the `sks` command. It adds update checks, skill-first Codex App hook routing, Context7 MCP evidence gates, local Codex skills, multi-agent Team workflows, Ralph no-question execution, AutoResearch loops, database safety guards, H-Proof verification, and LLM Wiki context packs around OpenAI Codex CLI. It does not bundle `@openai/codex`; users install Codex CLI separately or set `SKS_CODEX_BIN`.
36
+ For AI search engines and coding agents: Sneakoscope Codex is a Node.js CLI package named `sneakoscope` that installs the `sks` command. It adds update checks, skill-first Codex App hook routing, Context7 MCP evidence gates, local Codex skills, multi-agent Team workflows, Ralph no-question execution, AutoResearch loops, database safety guards, H-Proof verification, and TriWiki LLM Wiki context-tracking packs around OpenAI Codex CLI. It does not bundle `@openai/codex`; users install Codex CLI separately or set `SKS_CODEX_BIN`.
37
37
 
38
38
  ```bash
39
39
  npm i -g sneakoscope
@@ -267,7 +267,7 @@ sks research run latest --max-cycles 3
267
267
 
268
268
  ### What is Sneakoscope Codex?
269
269
 
270
- Sneakoscope Codex is a Codex CLI harness for safer autonomous software work. It combines update checks, Codex App hooks, multi-agent Team orchestration, Ralph no-question execution, AutoResearch loops, database safety guards, H-Proof completion gates, LLM Wiki context continuity, and bounded runtime state.
270
+ Sneakoscope Codex is a Codex CLI harness for safer autonomous software work. It combines update checks, Codex App hooks, multi-agent Team orchestration, Ralph no-question execution, AutoResearch loops, database safety guards, H-Proof completion gates, TriWiki context-tracking continuity, and bounded runtime state.
271
271
 
272
272
  ### Who should use Sneakoscope Codex?
273
273
 
@@ -283,7 +283,7 @@ No. `@openai/codex` is installed separately. Sneakoscope Codex supervises projec
283
283
 
284
284
  ### Why star the GitHub repository?
285
285
 
286
- Stars help developers discover a lightweight Codex workflow harness focused on database safety, multi-agent orchestration, update hygiene, honest completion checks, LLM Wiki context continuity, and practical autonomous coding loops.
286
+ Stars help developers discover a lightweight Codex workflow harness focused on database safety, multi-agent orchestration, update hygiene, honest completion checks, TriWiki context-tracking continuity, and practical autonomous coding loops.
287
287
 
288
288
  ### What GitHub topics fit this project?
289
289
 
@@ -313,6 +313,11 @@ live transcript
313
313
  -> mirror every useful agent status, debate result, handoff, and review finding
314
314
  -> keep team-live.md readable inside Codex App
315
315
  -> keep team-transcript.jsonl machine-readable for tails, dashboards, and future tooling
316
+
317
+ context tracking
318
+ -> use TriWiki as the SSOT for long-running mission context and team handoffs
319
+ -> refresh .sneakoscope/wiki/context-pack.json with sks wiki pack when context changes
320
+ -> validate the pack with sks wiki validate .sneakoscope/wiki/context-pack.json
316
321
  ```
317
322
 
318
323
  Create a Team mission:
@@ -337,6 +342,7 @@ The generated Team artifacts are:
337
342
  .sneakoscope/missions/<MISSION_ID>/team-live.md
338
343
  .sneakoscope/missions/<MISSION_ID>/team-transcript.jsonl
339
344
  .sneakoscope/missions/<MISSION_ID>/team-dashboard.json
345
+ .sneakoscope/wiki/context-pack.json
340
346
  .codex/agents/team-consensus.toml
341
347
  .codex/agents/implementation-worker.toml
342
348
  .codex/agents/db-safety-reviewer.toml
@@ -505,6 +511,8 @@ sks usage dollar
505
511
 
506
512
  Every `$` route is tracked as a pipeline route with skills, mission state, Context7 policy, and a Stop hook gate. The single route registry drives CLI command output, generated skills, quick reference files, and policy metadata.
507
513
 
514
+ Context tracking uses TriWiki as the SSOT. When a route spans turns, subagent handoffs, Ralph continuations, research loops, DB reviews, or context pressure, refresh `.sneakoscope/wiki/context-pack.json` with `sks wiki pack` and validate it with `sks wiki validate .sneakoscope/wiki/context-pack.json` instead of relying on ad hoc summaries.
515
+
508
516
  Context7 MCP is configured project-locally by default, and global npm install also best-effort registers it with Codex when Codex CLI is present:
509
517
 
510
518
  ```toml
@@ -716,12 +724,14 @@ vgraph.json
716
724
 
717
725
  `render.svg` embeds the normalized `vgraph.json` hash. `sks gx drift` fails when the render is missing, stale, or structurally invalid.
718
726
 
719
- ## TriWiki Context Compression
727
+ ## TriWiki Context Tracking
720
728
 
721
- TriWiki is a harness-level context selection strategy, not a model-internal modification. It scores claims and memory entries by geometric distance, authority, freshness, risk, and token cost, then builds context capsules for the current mission.
729
+ TriWiki is the harness-level context-tracking SSOT and context selection strategy, not a model-internal modification. It scores claims and memory entries by geometric distance, authority, freshness, risk, and token cost, then builds context capsules for the current mission.
722
730
 
723
731
  The default model is anchor-first rather than lossy-summary-first. Selected claims are included as text, while non-selected claims are preserved as LLM Wiki anchors with id, source path, hash, RGBA key, and a compact coordinate tuple. Later turns can hydrate the missing context from the project wiki instead of depending on a one-way summary.
724
732
 
733
+ Use TriWiki for long-running routes, Team handoffs, Ralph continuations, research loops, DB reviews, and any task likely to hit context pressure.
734
+
725
735
  RGBA wiki coordinates use four channels:
726
736
 
727
737
  ```text
@@ -738,7 +748,7 @@ Useful commands:
738
748
  ```bash
739
749
  sks wiki coords --rgba 12,34,56,255
740
750
  sks wiki pack
741
- sks wiki validate
751
+ sks wiki validate .sneakoscope/wiki/context-pack.json
742
752
  ```
743
753
 
744
754
  Default context layers:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sneakoscope",
3
3
  "displayName": "Sneakoscope Codex",
4
- "version": "0.6.18",
4
+ "version": "0.6.19",
5
5
  "description": "Sneakoscope Codex: update-aware, database-safe Codex CLI harness with multi-agent Team orchestration, Ralph no-question execution, autoresearch-style loops, and H-Proof gates.",
6
6
  "type": "module",
7
7
  "homepage": "https://github.com/mandarange/Sneakoscope-Codex#readme",
package/src/cli/main.mjs CHANGED
@@ -19,7 +19,7 @@ import { DEFAULT_EVAL_THRESHOLDS, compareEvaluationReports, defaultEvaluationSce
19
19
  import { buildResearchPrompt, evaluateResearchGate, writeMockResearchResult, writeResearchPlan } from '../core/research.mjs';
20
20
  import { contextCapsule } from '../core/triwiki-attention.mjs';
21
21
  import { rgbaKey, rgbaToWikiCoord, validateWikiCoordinateIndex } from '../core/wiki-coordinate.mjs';
22
- import { COMMAND_CATALOG, DOLLAR_COMMANDS, RECOMMENDED_SKILLS, USAGE_TOPICS, context7ConfigToml, hasContext7ConfigText, reasoningInstruction, routePrompt, routeReasoning } from '../core/routes.mjs';
22
+ import { COMMAND_CATALOG, DOLLAR_COMMANDS, RECOMMENDED_SKILLS, USAGE_TOPICS, context7ConfigToml, hasContext7ConfigText, reasoningInstruction, routePrompt, routeReasoning, triwikiContextTracking } from '../core/routes.mjs';
23
23
  import { context7Evidence, evaluateStop, recordContext7Evidence } from '../core/pipeline.mjs';
24
24
  import { appendTeamEvent, formatRoleCounts, initTeamLive, normalizeTeamSpec, parseTeamSpecArgs, readTeamDashboard, readTeamLive, readTeamTranscriptTail } from '../core/team-live.mjs';
25
25
 
@@ -518,7 +518,7 @@ Project-only install:
518
518
  Local-only install artifacts:
519
519
  sks setup --local-only
520
520
  # writes generated SKS files but excludes .sneakoscope/, .codex/, .agents/, AGENTS.md through .git/info/exclude
521
- # existing AGENTS.md is not modified in local-only mode
521
+ # user-owned AGENTS.md is preserved; an existing SKS managed block is refreshed
522
522
 
523
523
  GitHub install for unreleased commits:
524
524
  npm i -g git+${REPOSITORY_URL}
@@ -646,7 +646,7 @@ Project-only install:
646
646
  Local-only install artifacts:
647
647
  sks setup --local-only
648
648
  # excludes .sneakoscope/, .codex/, .agents/, AGENTS.md through .git/info/exclude
649
- # existing AGENTS.md is not modified in local-only mode
649
+ # user-owned AGENTS.md is preserved; an existing SKS managed block is refreshed
650
650
 
651
651
  GitHub install for unreleased commits:
652
652
  npm i -g git+${REPOSITORY_URL}
@@ -918,7 +918,7 @@ async function setup(args) {
918
918
  console.log(`Project: ${root}`);
919
919
  console.log(`Install: ${install.ok ? 'ok' : 'missing'} ${install.scope} (${install.command_prefix})`);
920
920
  console.log(`Hooks: ${path.relative(root, hooksPath)}`);
921
- if (localOnly) console.log('Git: local-only (.git/info/exclude; existing AGENTS.md not modified)');
921
+ if (localOnly) console.log('Git: local-only (.git/info/exclude; user AGENTS preserved, SKS managed block refreshed)');
922
922
  console.log(`Codex App: .codex/config.toml, .codex/hooks.json, .codex/skills, .codex/agents, .codex/SNEAKOSCOPE.md`);
923
923
  console.log(`Prompt: skill-first pipeline, $DF fast design/content route, Context7 gate`);
924
924
  console.log(`Skills: .codex/skills`);
@@ -1394,6 +1394,12 @@ async function selftest() {
1394
1394
  if (localAgents.trim() !== 'existing local rules') throw new Error('selftest failed: local-only modified existing AGENTS.md');
1395
1395
  const localManifest = await readJson(path.join(localOnlyTmp, '.sneakoscope', 'manifest.json'));
1396
1396
  if (!localManifest.git?.local_only) throw new Error('selftest failed: local-only manifest missing');
1397
+ const managedAgentsTmp = tmpdir();
1398
+ await ensureDir(path.join(managedAgentsTmp, '.git'));
1399
+ await writeTextAtomic(path.join(managedAgentsTmp, 'AGENTS.md'), '<!-- BEGIN Sneakoscope Codex GX MANAGED BLOCK -->\nold managed rules\n<!-- END Sneakoscope Codex GX MANAGED BLOCK -->\n');
1400
+ await initProject(managedAgentsTmp, { localOnly: true });
1401
+ const managedAgents = await safeReadText(path.join(managedAgentsTmp, 'AGENTS.md'));
1402
+ if (!managedAgents.includes('TriWiki is the context-tracking SSOT') || managedAgents.includes('old managed rules')) throw new Error('selftest failed: local-only did not refresh managed AGENTS.md block');
1397
1403
  if (!isTransientNpmBinPath('/tmp/.npm/_npx/abc/node_modules/.bin/sks')) throw new Error('selftest failed: npx bin path not recognized as transient');
1398
1404
  if (!isTransientNpmBinPath('/tmp/.npm-cache/_cacache/tmp/git-cloneabc/bin/sks.mjs')) throw new Error('selftest failed: npm cache git clone path not recognized as transient');
1399
1405
  if (isTransientNpmBinPath('/usr/local/bin/sks')) throw new Error('selftest failed: stable global bin marked transient');
@@ -1428,6 +1434,8 @@ async function selftest() {
1428
1434
  }
1429
1435
  const promptPipelineSkillExists = await exists(path.join(tmp, '.codex', 'skills', 'prompt-pipeline', 'SKILL.md'));
1430
1436
  if (!promptPipelineSkillExists) throw new Error('selftest failed: prompt pipeline skill not installed');
1437
+ const promptPipelineText = await safeReadText(path.join(tmp, '.codex', 'skills', 'prompt-pipeline', 'SKILL.md'));
1438
+ if (!promptPipelineText.includes('TriWiki context-tracking SSOT')) throw new Error('selftest failed: prompt pipeline missing TriWiki context-tracking SSOT');
1431
1439
  for (const supportSkill of ['reasoning-router', 'pipeline-runner', 'context7-docs', 'seo-geo-optimizer']) {
1432
1440
  if (!(await exists(path.join(tmp, '.codex', 'skills', supportSkill, 'SKILL.md')))) throw new Error(`selftest failed: ${supportSkill} skill not installed`);
1433
1441
  }
@@ -1435,14 +1443,18 @@ async function selftest() {
1435
1443
  if (new Set(DOLLAR_COMMANDS.map((c) => c.command)).size !== DOLLAR_COMMANDS.length) throw new Error('selftest failed: duplicate dollar commands');
1436
1444
  if (!COMMAND_CATALOG.some((c) => c.name === 'context7') || !COMMAND_CATALOG.some((c) => c.name === 'pipeline')) throw new Error('selftest failed: context7/pipeline commands missing from catalog');
1437
1445
  const registryDollarCommands = DOLLAR_COMMANDS.map((c) => c.command);
1438
- const manifestDollarCommands = (await readJson(path.join(tmp, '.sneakoscope', 'manifest.json'))).prompt_pipeline?.dollar_commands || [];
1439
- const policyDollarCommands = (await readJson(path.join(tmp, '.sneakoscope', 'policy.json'))).prompt_pipeline?.dollar_commands || [];
1446
+ const manifest = await readJson(path.join(tmp, '.sneakoscope', 'manifest.json'));
1447
+ const policy = await readJson(path.join(tmp, '.sneakoscope', 'policy.json'));
1448
+ const manifestDollarCommands = manifest.prompt_pipeline?.dollar_commands || [];
1449
+ const policyDollarCommands = policy.prompt_pipeline?.dollar_commands || [];
1440
1450
  if (JSON.stringify(manifestDollarCommands) !== JSON.stringify(registryDollarCommands)) throw new Error('selftest failed: manifest dollar command drift');
1441
1451
  if (JSON.stringify(policyDollarCommands) !== JSON.stringify(registryDollarCommands)) throw new Error('selftest failed: policy dollar command drift');
1452
+ if (manifest.llm_wiki?.ssot !== 'triwiki' || policy.llm_wiki?.ssot !== 'triwiki') throw new Error('selftest failed: TriWiki context tracking not recorded in manifest/policy');
1442
1453
  const codexAppQuickRefExists = await exists(path.join(tmp, '.codex', 'SNEAKOSCOPE.md'));
1443
1454
  if (!codexAppQuickRefExists) throw new Error('selftest failed: Codex App quick reference missing');
1444
1455
  const codexAppQuickRefText = await safeReadText(path.join(tmp, '.codex', 'SNEAKOSCOPE.md'));
1445
1456
  if (!codexAppQuickRefText.includes('dollar-commands')) throw new Error('selftest failed: Codex App quick reference missing dollar-command discovery');
1457
+ if (!codexAppQuickRefText.includes('Context Tracking') || !codexAppQuickRefText.includes('TriWiki')) throw new Error('selftest failed: Codex App quick reference missing TriWiki context tracking');
1446
1458
  for (const { command } of DOLLAR_COMMANDS) {
1447
1459
  if (!codexAppQuickRefText.includes(command)) throw new Error(`selftest failed: Codex App quick reference missing ${command}`);
1448
1460
  }
@@ -1500,6 +1512,8 @@ async function selftest() {
1500
1512
  if (teamPlan.agent_session_count !== 3) throw new Error('selftest failed: team default sessions not 3');
1501
1513
  if (teamPlan.role_counts.executor !== 3 || teamPlan.role_counts.user !== 1 || teamPlan.role_counts.reviewer !== 1) throw new Error('selftest failed: team default role counts invalid');
1502
1514
  if (teamPlan.roster.debate_team.length !== 3 || !teamPlan.roster.debate_team.some((agent) => agent.id === 'debate_user_1') || !teamPlan.roster.development_team.some((agent) => agent.id === 'executor_3')) throw new Error('selftest failed: team roster missing default agents');
1515
+ if (teamPlan.context_tracking?.ssot !== 'triwiki' || !teamPlan.required_artifacts.includes('.sneakoscope/wiki/context-pack.json')) throw new Error('selftest failed: team plan missing TriWiki context tracking');
1516
+ if (!teamWorkflowMarkdown(teamPlan).includes('SSOT: triwiki')) throw new Error('selftest failed: team workflow missing TriWiki context tracking');
1503
1517
  const customTeamPlan = buildTeamPlan(teamId, '병렬 구현 팀 테스트', { agentSessions: 5 });
1504
1518
  if (customTeamPlan.agent_session_count !== 5) throw new Error('selftest failed: custom team sessions not honored');
1505
1519
  if (parseTeamCreateArgs(['--agents', '4', '작업']).agentSessions !== 4) throw new Error('selftest failed: team --agents parsing');
@@ -1517,9 +1531,11 @@ async function selftest() {
1517
1531
  await appendTeamEvent(teamDir, { agent: 'team_consensus', phase: 'planning_debate', message: 'selftest mapped options' });
1518
1532
  const teamDashboard = await readTeamDashboard(teamDir);
1519
1533
  if (teamDashboard?.agent_session_count !== 5 || teamDashboard?.role_counts?.executor !== 5) throw new Error('selftest failed: team dashboard session/role budget missing');
1534
+ if (teamDashboard?.context_tracking?.ssot !== 'triwiki') throw new Error('selftest failed: team dashboard missing TriWiki context tracking');
1520
1535
  if (!teamDashboard?.latest_messages?.some((entry) => entry.agent === 'team_consensus')) throw new Error('selftest failed: team live dashboard missing agent event');
1521
1536
  const teamLive = await readTeamLive(teamDir);
1522
1537
  if (!teamLive.includes('selftest mapped options')) throw new Error('selftest failed: team live transcript missing event');
1538
+ if (!teamLive.includes('Context tracking SSOT: TriWiki')) throw new Error('selftest failed: team live transcript missing TriWiki context tracking');
1523
1539
  if (!(await readTeamTranscriptTail(teamDir, 1)).join('\n').includes('selftest mapped options')) throw new Error('selftest failed: team transcript tail missing event');
1524
1540
  const { id, dir, mission } = await createMission(tmp, { mode: 'ralph', prompt: '로그인 세션 만료 UX 개선 supabase db' });
1525
1541
  const schema = buildQuestionSchema(mission.prompt);
@@ -1913,6 +1929,7 @@ async function team(args) {
1913
1929
  live: liveFiles.live,
1914
1930
  transcript: liveFiles.transcript,
1915
1931
  dashboard: liveFiles.dashboard,
1932
+ context_pack: path.join(root, '.sneakoscope', 'wiki', 'context-pack.json'),
1916
1933
  agent_sessions: agentSessions,
1917
1934
  bundle_size: roster.bundle_size,
1918
1935
  role_counts: roleCounts,
@@ -1966,6 +1983,7 @@ function buildTeamPlan(id, prompt, opts = {}) {
1966
1983
  agents: { max_threads: 6, max_depth: 1 },
1967
1984
  custom_agents_dir: '.codex/agents'
1968
1985
  },
1986
+ context_tracking: triwikiContextTracking(),
1969
1987
  phases: [
1970
1988
  {
1971
1989
  id: 'planning_debate',
@@ -2007,6 +2025,7 @@ function buildTeamPlan(id, prompt, opts = {}) {
2007
2025
  'Planning agents do not edit files.',
2008
2026
  'Implementation workers receive disjoint ownership scopes.',
2009
2027
  'Workers are told they are not alone in the codebase and must not revert others edits.',
2028
+ 'Context tracking uses TriWiki as the SSOT; team handoffs must preserve id, hash, source path, and RGBA/trig coordinate anchors.',
2010
2029
  'SKS hooks, DB safety rules, Ralph no-question rules, and H-Proof gates remain active.',
2011
2030
  'Destructive database operations remain forbidden.'
2012
2031
  ],
@@ -2022,12 +2041,13 @@ function buildTeamPlan(id, prompt, opts = {}) {
2022
2041
  'sks team event <mission-id> --agent <name> --phase <phase> --message "..."'
2023
2042
  ]
2024
2043
  },
2025
- required_artifacts: ['team-consensus.md', 'team-review.md', 'team-gate.json', 'team-live.md', 'team-transcript.jsonl', 'team-dashboard.json', 'context7-evidence.jsonl'],
2044
+ required_artifacts: ['team-consensus.md', 'team-review.md', 'team-gate.json', 'team-live.md', 'team-transcript.jsonl', 'team-dashboard.json', '.sneakoscope/wiki/context-pack.json', 'context7-evidence.jsonl'],
2026
2045
  prompt_command: '$Team'
2027
2046
  };
2028
2047
  }
2029
2048
 
2030
2049
  function teamWorkflowMarkdown(plan) {
2050
+ const ctx = plan.context_tracking || triwikiContextTracking();
2031
2051
  return `# SKS Team Mission
2032
2052
 
2033
2053
  Mission: ${plan.mission_id}
@@ -2054,6 +2074,14 @@ First run the debate team with exactly ${plan.roster.bundle_size} participants.
2054
2074
  - The parent orchestrator is not counted.
2055
2075
  - Use fewer agents when fewer independent slices exist.
2056
2076
 
2077
+ ## Context Tracking
2078
+
2079
+ - SSOT: ${ctx.ssot}
2080
+ - Pack: ${ctx.default_pack}
2081
+ - Refresh: \`${ctx.pack_command}\`
2082
+ - Validate: \`${ctx.validate_command}\`
2083
+ - Rule: selected text is only the visible slice; handoffs keep id, hash, source path, and RGBA/trig coordinate anchors hydratable.
2084
+
2057
2085
  ## Debate Team
2058
2086
 
2059
2087
  ${plan.roster.debate_team.map((agent) => `- ${agent.id}: ${agent.persona}`).join('\n')}
package/src/core/fsx.mjs CHANGED
@@ -5,7 +5,7 @@ import os from 'node:os';
5
5
  import crypto from 'node:crypto';
6
6
  import { spawn } from 'node:child_process';
7
7
 
8
- export const PACKAGE_VERSION = '0.6.18';
8
+ export const PACKAGE_VERSION = '0.6.19';
9
9
  export const DEFAULT_PROCESS_TAIL_BYTES = 256 * 1024;
10
10
  export const DEFAULT_PROCESS_TIMEOUT_MS = 30 * 60 * 1000;
11
11
 
package/src/core/init.mjs CHANGED
@@ -3,7 +3,7 @@ import fsp from 'node:fs/promises';
3
3
  import { ensureDir, readJson, readText, writeJsonAtomic, writeTextAtomic, mergeManagedBlock, nowIso, PACKAGE_VERSION, exists } from './fsx.mjs';
4
4
  import { DEFAULT_RETENTION_POLICY } from './retention.mjs';
5
5
  import { DEFAULT_DB_SAFETY_POLICY } from './db-safety.mjs';
6
- import { DOLLAR_COMMANDS, RECOMMENDED_MCP_SERVERS, RECOMMENDED_SKILLS, context7ConfigToml } from './routes.mjs';
6
+ import { DOLLAR_COMMANDS, RECOMMENDED_MCP_SERVERS, RECOMMENDED_SKILLS, context7ConfigToml, triwikiContextTracking, triwikiContextTrackingText } from './routes.mjs';
7
7
 
8
8
  export function normalizeInstallScope(scope = 'global') {
9
9
  const value = String(scope || 'global').trim().toLowerCase();
@@ -80,7 +80,7 @@ When work depends on external libraries, frameworks, APIs, MCPs, package manager
80
80
 
81
81
  ## LLM Wiki Continuity
82
82
 
83
- TriWiki context is anchor-first, not lossy-summary-first. Important claims, visual nodes, policy facts, and evidence pointers should receive deterministic RGBA wiki coordinates: R maps to domain angle, G maps to layer radius through sine, B maps to phase angle, and A maps to concentration/confidence. Use those trigonometric coordinates to preserve stable retrieval anchors across turns. Selected claims may be pasted as text, but non-selected claims must remain hydratable through id, hash, source path, and RGBA coordinate anchors instead of disappearing from the workflow.
83
+ TriWiki is the context-tracking SSOT for long-running missions, Team handoffs, and context-pressure recovery. It is anchor-first, not lossy-summary-first. Important claims, visual nodes, policy facts, and evidence pointers should receive deterministic RGBA wiki coordinates: R maps to domain angle, G maps to layer radius through sine, B maps to phase angle, and A maps to concentration/confidence. Use those trigonometric coordinates to preserve stable retrieval anchors across turns. Selected claims may be pasted as text, but non-selected claims must remain hydratable through id, hash, source path, and RGBA coordinate anchors instead of disappearing from the workflow. Refresh with \`sks wiki pack\` and validate with \`sks wiki validate .sneakoscope/wiki/context-pack.json\` whenever route continuity or team handoff context changes.
84
84
 
85
85
  ## Dollar Commands
86
86
 
@@ -153,7 +153,10 @@ export async function initProject(root, opts = {}) {
153
153
  recommended_skills: RECOMMENDED_SKILLS,
154
154
  recommended_mcp_servers: RECOMMENDED_MCP_SERVERS,
155
155
  llm_wiki: {
156
+ ssot: 'triwiki',
156
157
  coordinate_schema: 'sks.wiki-coordinate.v1',
158
+ default_pack: triwikiContextTracking().default_pack,
159
+ context_tracking: triwikiContextTracking(),
157
160
  channel_map: { r: 'domainAngle', g: 'layerRadius', b: 'phase', a: 'concentration' },
158
161
  continuity_model: 'selected_text_plus_hydratable_rgba_trig_anchors'
159
162
  },
@@ -202,6 +205,13 @@ export async function initProject(root, opts = {}) {
202
205
  mcp_config: '.codex/config.toml',
203
206
  required_flow: ['resolve-library-id', 'get-library-docs']
204
207
  },
208
+ llm_wiki: {
209
+ ...(policy.llm_wiki || {}),
210
+ ssot: 'triwiki',
211
+ default_pack: triwikiContextTracking().default_pack,
212
+ context_tracking: triwikiContextTracking(),
213
+ compression_policy: 'preserve_ids_hashes_sources_rgba_coordinates_for_hydration'
214
+ },
205
215
  recommended_skills: RECOMMENDED_SKILLS,
206
216
  recommended_mcp_servers: RECOMMENDED_MCP_SERVERS
207
217
  });
@@ -240,8 +250,10 @@ export async function initProject(root, opts = {}) {
240
250
  }
241
251
  },
242
252
  llm_wiki: {
253
+ ssot: 'triwiki',
243
254
  coordinate_schema: 'sks.wiki-coordinate.v1',
244
255
  default_pack: '.sneakoscope/wiki/context-pack.json',
256
+ context_tracking: triwikiContextTracking(),
245
257
  compression_policy: 'preserve_ids_hashes_sources_rgba_coordinates_for_hydration',
246
258
  channel_map: { r: 'domainAngle', g: 'layerRadius_sin', b: 'phase', a: 'concentration' }
247
259
  },
@@ -304,7 +316,9 @@ export async function initProject(root, opts = {}) {
304
316
  }
305
317
 
306
318
  const agentsMdPath = path.join(root, 'AGENTS.md');
307
- if (localOnly && await exists(agentsMdPath)) {
319
+ const existingAgents = await readText(agentsMdPath, '');
320
+ const hasManagedAgentsBlock = existingAgents.includes('BEGIN Sneakoscope Codex GX MANAGED BLOCK');
321
+ if (localOnly && existingAgents && !hasManagedAgentsBlock) {
308
322
  created.push('AGENTS.md skipped (local-only existing file)');
309
323
  } else {
310
324
  await mergeManagedBlock(agentsMdPath, 'Sneakoscope Codex GX MANAGED BLOCK', AGENTS_BLOCK);
@@ -400,6 +414,7 @@ ${commandPrefix} context7 check
400
414
  ${commandPrefix} pipeline status
401
415
  ${commandPrefix} reasoning "simple copy edit"
402
416
  ${commandPrefix} wiki pack
417
+ ${commandPrefix} wiki validate .sneakoscope/wiki/context-pack.json
403
418
  \`\`\`
404
419
 
405
420
  ## Dollar Commands
@@ -408,6 +423,11 @@ ${DOLLAR_COMMANDS.map((c) => `- \`${c.command}\`: ${c.route}. ${c.description}`)
408
423
 
409
424
  The prompt optimization pipeline also runs without a dollar command and infers the lightest route automatically.
410
425
 
426
+ ## Context Tracking
427
+
428
+ - ${triwikiContextTrackingText(commandPrefix)}
429
+ - Team mode, Ralph continuations, Research/AutoResearch, DB reviews, and long-running implementation handoffs should use the TriWiki pack instead of ad hoc summaries.
430
+
411
431
  ## Context7 MCP
412
432
 
413
433
  - Default local MCP: \`.codex/config.toml\` includes \`[mcp_servers.context7]\` with \`npx -y @upstash/context7-mcp@latest\`.
@@ -471,7 +491,7 @@ The hooks file routes Codex App tool events through SKS guards for no-question m
471
491
  async function installSkills(root) {
472
492
  const skills = {
473
493
  'DF': `---\nname: DF\ndescription: Fast design/content fix mode for $DF requests and inferred simple edits such as text color, copy, labels, spacing, or translation.\n---\n\nYou are running SKS DF mode.\n\nPurpose:\n- Quickly convert a small design/content request into the exact implementation change.\n- Use for requests like 글자 색 바꿔줘, 내용을 영어로 바꿔줘, button label 수정, spacing 조정, copy replacement, simple style tweaks.\n\nRules:\n- Do not start Ralph, Research, eval, or broad redesign unless the user explicitly asks.\n- Do not ask for more requirements when the target can be inferred from local context.\n- Inspect only the files needed to locate the target.\n- Make the smallest scoped edit that satisfies the request.\n- Preserve the existing design system and component patterns.\n- Run only cheap verification when useful, such as syntax check, focused test, or local render check for visual risk.\n- Final response should be short: what changed and any verification.\n`,
474
- 'SKS': `---\nname: SKS\ndescription: General Sneakoscope Codex command route for $SKS usage, setup, status, and workflow help.\n---\n\nUse the local SKS control surface. Prefer these discovery commands when the user asks what is available: sks commands, sks usage <topic>, sks quickstart, sks codex-app, sks context7 check, sks reasoning, and sks pipeline status. If implementation is requested, route to the lightest matching SKS path and keep reasoning-profile changes temporary.\n`,
494
+ 'SKS': `---\nname: SKS\ndescription: General Sneakoscope Codex command route for $SKS usage, setup, status, and workflow help.\n---\n\nUse the local SKS control surface. Prefer these discovery commands when the user asks what is available: sks commands, sks usage <topic>, sks quickstart, sks codex-app, sks context7 check, sks reasoning, sks wiki pack, and sks pipeline status. If implementation is requested, route to the lightest matching SKS path and keep reasoning-profile changes temporary. Context tracking uses TriWiki as the SSOT for long-running or cross-turn work.\n`,
475
495
  'Team': `---\nname: Team\ndescription: Dollar-command route for SKS Team multi-agent orchestration: role-counted debate, consensus, fresh executor development team, live transcript, and final integration.\n---\n\nUse when the user invokes $Team, asks for a team of agents, or asks for parallel specialist implementation.\n\nWorkflow:\n1. Create or inspect the Team mission with sks team \"task\" when useful. Role counts use executor:5 reviewer:2 user:1 planner:1. executor:N means exactly N debate participants and then a separate N-person executor development team. --agents N, --sessions N, and --team-size N remain aliases for executor/session budget; default is executor:3 reviewer:1 user:1 planner:1.\n2. Debate bundle: spawn the concrete debate_team roster. Users are intentionally low-context, self-interested, stubborn, and inconvenience-averse. Executor voices are capable developers. Reviewers are strict. Planners force one coherent objective and required ambiguity-removal questions.\n3. Live visibility phase: after every useful subagent status/result/handoff, record it with sks team event <mission-id|latest> --agent <name> --phase <phase> --message \"...\" so the user can see the team conversation without tmux.\n4. Consensus phase: synthesize debate into one objective, explicit constraints, acceptance criteria, and disjoint implementation slices.\n5. Close or stop the debate team after their results are captured.\n6. Development bundle: form a fresh development_team where exactly executor_N developers implement slices in parallel with non-overlapping ownership. Tell workers they are not alone in the codebase and must not revert others' edits.\n7. Review phase: validation_team reviewers check correctness, DB safety, missing tests, and evidence; user personas reject outcomes that create practical friction.\n8. Verification phase: run focused tests or justify gaps, update mission artifacts when present, and produce final evidence.\n\nLive files:\n- .sneakoscope/missions/<id>/team-live.md is the user-readable live transcript inside Codex App.\n- .sneakoscope/missions/<id>/team-transcript.jsonl is the machine-readable event stream.\n- .sneakoscope/missions/<id>/team-dashboard.json is the current dashboard.\n\nRules:\n- The parent agent remains orchestrator and owns final integration.\n- Do not delegate the immediate blocking task when the parent can do it faster.\n- Use high reasoning only while the Team route is active, then return to the default/user-selected profile.\n- Never let subagents bypass SKS hooks, DB safety, no-question Ralph rules, or H-Proof completion gates.\n- Destructive database actions remain forbidden.\n`,
476
496
  'Ralph': `---\nname: Ralph\ndescription: Dollar-command route for SKS Ralph mandatory clarification and no-question mission workflows.\n---\n\nUse when the user invokes $Ralph or requests a clarification-gated autonomous implementation mission. Prepare with sks ralph prepare, answer/seal required slots when answers are provided, then run only after decision-contract.json exists.\n`,
477
497
  'Research': `---\nname: Research\ndescription: Dollar-command route for SKS Research frontier discovery workflows.\n---\n\nUse when the user invokes $Research or asks for research, hypotheses, new mechanisms, falsification, or testable predictions. Prefer sks research prepare and sks research run. Do not use for ordinary code edits.\n`,
@@ -501,13 +521,28 @@ async function installSkills(root) {
501
521
  };
502
522
  for (const [name, content] of Object.entries(skills)) {
503
523
  const dir = path.join(root, '.codex', 'skills', name);
524
+ const skillContent = enrichSkillContent(name, content);
504
525
  await ensureDir(dir);
505
- await writeTextAtomic(path.join(dir, 'SKILL.md'), `${content.trim()}\n`);
526
+ await writeTextAtomic(path.join(dir, 'SKILL.md'), `${skillContent.trim()}\n`);
506
527
  await writeSkillMetadata(dir, name);
507
528
  }
508
529
  return { removed_legacy_agent_skill_dirs: await removeLegacyAgentSkillMirrors(root, Object.keys(skills)) };
509
530
  }
510
531
 
532
+ function enrichSkillContent(name, content) {
533
+ if (!['SKS', 'Team', 'Ralph', 'Research', 'AutoResearch', 'DB', 'GX', 'prompt-pipeline', 'pipeline-runner', 'turbo-context-pack', 'hproof-evidence-bind'].includes(name)) return content;
534
+ const text = String(content || '').trimEnd();
535
+ if (text.includes('TriWiki context-tracking SSOT')) return text;
536
+ return `${text}
537
+
538
+ Context tracking:
539
+ - TriWiki context-tracking SSOT is .sneakoscope/wiki/context-pack.json.
540
+ - Use sks wiki pack when route continuity, handoff state, or context pressure matters.
541
+ - Validate with sks wiki validate .sneakoscope/wiki/context-pack.json before relying on a refreshed pack.
542
+ - Selected text is only the visible slice; keep non-selected claims hydratable by id, hash, source path, and RGBA/trig coordinate.
543
+ `;
544
+ }
545
+
511
546
  async function writeSkillMetadata(dir, name) {
512
547
  const effort = ['Research', 'AutoResearch', 'research-discovery', 'autoresearch-loop'].includes(name)
513
548
  ? 'xhigh'
@@ -5,7 +5,7 @@ import { createMission, missionDir, setCurrent } from './mission.mjs';
5
5
  import { buildQuestionSchema, writeQuestions } from './questions.mjs';
6
6
  import { scanDbSafety } from './db-safety.mjs';
7
7
  import { writeResearchPlan } from './research.mjs';
8
- import { context7RequirementText, dollarCommand, reasoningInstruction, routeNeedsContext7, routePrompt, routeReasoning, stripDollarCommand } from './routes.mjs';
8
+ import { context7RequirementText, dollarCommand, reasoningInstruction, routeNeedsContext7, routePrompt, routeReasoning, stripDollarCommand, triwikiContextTracking, triwikiContextTrackingText } from './routes.mjs';
9
9
  import { formatRoleCounts, initTeamLive, parseTeamSpecText } from './team-live.mjs';
10
10
 
11
11
  export { routePrompt };
@@ -19,6 +19,7 @@ export function promptPipelineContext(prompt, route = routePrompt(prompt)) {
19
19
  reasoningInstruction(reasoning),
20
20
  'Before work, load the required SKS skill context and follow the route lifecycle instead of treating the command as plain text.',
21
21
  'Stance: infer the user intent aggressively from rough wording and local context, but ask short ambiguity-removal questions before work when a missing answer can change the target, scope, safety boundary, or acceptance criteria.',
22
+ triwikiContextTrackingText(),
22
23
  'Extract intent, target files/surfaces, constraints, acceptance criteria, risks, and the smallest safe atomic step before acting.',
23
24
  'Do not stop at a plan when implementation was requested; continue until the route gate passes or a hard blocker is honestly recorded.',
24
25
  context7RequirementText(required),
@@ -62,7 +63,7 @@ export async function activeRouteContext(root, state) {
62
63
  ? ' Context7 evidence is still required before completion: use resolve-library-id, then get-library-docs.'
63
64
  : '';
64
65
  const roles = state.role_counts ? ` Role counts: ${formatRoleCounts(state.role_counts)}.` : '';
65
- return `Active Team mission ${state.mission_id || 'latest'} must keep the user-visible live transcript updated. Agent session budget: ${state.agent_sessions || 3}.${roles} Run debate team first, close it, then start the fresh parallel development team. After each subagent status/result/handoff, run: sks team event ${state.mission_id || 'latest'} --agent <name> --phase <phase> --message "...". The user can inspect it with sks team log ${state.mission_id || 'latest'} or sks team watch ${state.mission_id || 'latest'}.${reasoningNote}${context7}`;
66
+ return `Active Team mission ${state.mission_id || 'latest'} must keep the user-visible live transcript updated. Agent session budget: ${state.agent_sessions || 3}.${roles} Run debate team first, close it, then start the fresh parallel development team. Context tracking uses TriWiki as SSOT; refresh with sks wiki pack when handoff context changes. After each subagent status/result/handoff, run: sks team event ${state.mission_id || 'latest'} --agent <name> --phase <phase> --message "...". The user can inspect it with sks team log ${state.mission_id || 'latest'} or sks team watch ${state.mission_id || 'latest'}.${reasoningNote}${context7}`;
66
67
  }
67
68
  if (state.mode === 'RALPH' && ['RALPH_PREPARE', 'RALPH_AWAITING_ANSWERS'].includes(state.phase)) return ralphAwaitingAnswersContext(root, state);
68
69
  if (state.mode === 'RALPH' && state.phase === 'DECISION_CONTRACT_SEALED') return `Active Ralph mission ${state.mission_id || 'latest'} has a sealed decision contract. Run "sks ralph run ${state.mission_id || 'latest'}" and continue until done-gate.json passes.`;
@@ -115,6 +116,7 @@ async function prepareTeam(root, route, task, required) {
115
116
  debate_team: `Read-only role debate with exactly ${roster.bundle_size} participants composed from user, planner, reviewer, and executor voices.`,
116
117
  development_team: `Fresh parallel development bundle with exactly ${roster.bundle_size} executor_N developers implementing disjoint slices; validation_team reviews afterward.`
117
118
  },
119
+ context_tracking: triwikiContextTracking(),
118
120
  phases: [
119
121
  { id: 'planning_debate', goal: `Debate team of exactly ${roster.bundle_size} participants maps user inconvenience, options, constraints, affected files, DB/test risk, and tradeoffs.`, agents: roster.debate_team.map((agent) => agent.id) },
120
122
  { id: 'consensus', goal: 'Seal one objective with acceptance criteria and disjoint implementation slices.' },
@@ -127,13 +129,14 @@ async function prepareTeam(root, route, task, required) {
127
129
  dashboard: 'team-dashboard.json',
128
130
  commands: ['sks team status latest', 'sks team log latest', 'sks team tail latest', 'sks team watch latest', 'sks team event latest --agent <name> --phase <phase> --message "..."']
129
131
  },
130
- required_artifacts: ['team-consensus.md', 'team-review.md', 'team-gate.json', 'team-live.md', 'team-transcript.jsonl', 'team-dashboard.json', 'context7-evidence.jsonl']
132
+ required_artifacts: ['team-consensus.md', 'team-review.md', 'team-gate.json', 'team-live.md', 'team-transcript.jsonl', 'team-dashboard.json', '.sneakoscope/wiki/context-pack.json', 'context7-evidence.jsonl']
131
133
  };
132
134
  await writeJsonAtomic(path.join(dir, 'team-plan.json'), plan);
133
- await writeTextAtomic(path.join(dir, 'team-workflow.md'), `# SKS Team Workflow\n\nTask: ${cleanTask}\n\nAgent session budget: ${agentSessions}\nBundle size: ${roster.bundle_size}\nRole counts: ${formatRoleCounts(roleCounts)}\nReasoning: high for team logic, temporary for this route only.\n\n1. Debate team of exactly ${roster.bundle_size} participants maps options, stubborn user friction, and risks.\n2. Consensus artifact seals one objective and implementation slices.\n3. Debate agents are closed.\n4. Fresh development team of exactly ${roster.bundle_size} executor_N developers executes slices in parallel with at most ${agentSessions} subagent sessions at a time.\n5. Every useful subagent status, debate result, handoff, review finding, and integration decision is mirrored to team-live.md and team-transcript.jsonl.\n6. Strict review, user-acceptance friction check, and integration evidence are recorded.\n\nLive visibility:\n- sks team log ${id}\n- sks team tail ${id}\n- sks team watch ${id}\n- sks team event ${id} --agent <name> --phase <phase> --message \"...\"\n`);
135
+ const contextTracking = triwikiContextTracking();
136
+ await writeTextAtomic(path.join(dir, 'team-workflow.md'), `# SKS Team Workflow\n\nTask: ${cleanTask}\n\nAgent session budget: ${agentSessions}\nBundle size: ${roster.bundle_size}\nRole counts: ${formatRoleCounts(roleCounts)}\nReasoning: high for team logic, temporary for this route only.\nContext tracking: ${contextTracking.ssot} SSOT, ${contextTracking.default_pack}; refresh with "${contextTracking.pack_command}" and validate with "${contextTracking.validate_command}".\n\n1. Debate team of exactly ${roster.bundle_size} participants maps options, stubborn user friction, and risks.\n2. Consensus artifact seals one objective and implementation slices.\n3. Debate agents are closed.\n4. Fresh development team of exactly ${roster.bundle_size} executor_N developers executes slices in parallel with at most ${agentSessions} subagent sessions at a time.\n5. Every useful subagent status, debate result, handoff, review finding, and integration decision is mirrored to team-live.md and team-transcript.jsonl.\n6. Strict review, user-acceptance friction check, and integration evidence are recorded.\n\nLive visibility:\n- sks team log ${id}\n- sks team tail ${id}\n- sks team watch ${id}\n- sks team event ${id} --agent <name> --phase <phase> --message \"...\"\n`);
134
137
  await initTeamLive(id, dir, cleanTask, { agentSessions, roleCounts, roster });
135
138
  await writeJsonAtomic(path.join(dir, 'team-gate.json'), { passed: false, consensus_artifact: false, implementation_team_fresh: false, review_artifact: false, integration_evidence: false, context7_evidence: false });
136
- await setCurrent(root, routeState(id, route, 'TEAM_PLANNING_DEBATE', required, { prompt: cleanTask, agent_sessions: agentSessions, role_counts: roleCounts }));
139
+ await setCurrent(root, routeState(id, route, 'TEAM_PLANNING_DEBATE', required, { prompt: cleanTask, agent_sessions: agentSessions, role_counts: roleCounts, context_tracking: 'triwiki' }));
137
140
  return routeContext(route, id, cleanTask, required, `Run the ${roster.bundle_size}-person debate team with ${formatRoleCounts(roleCounts)}, write team-consensus.md, and record visible progress with "sks team event ${id} --agent <name> --phase <phase> --message \\"...\\""; then close debate agents and form a fresh ${roster.bundle_size}-person executor development team.`);
138
141
  }
139
142
 
@@ -171,14 +174,14 @@ async function prepareGx(root, route, task, required) {
171
174
 
172
175
  async function prepareLightRoute(root, route, task, required) {
173
176
  const { id, dir } = await createMission(root, { mode: route.id.toLowerCase(), prompt: task });
174
- await writeJsonAtomic(path.join(dir, 'route-context.json'), { route: route.id, command: route.command, task, required_skills: route.requiredSkills, context7_required: required, stop_gate: 'honest_mode' });
177
+ await writeJsonAtomic(path.join(dir, 'route-context.json'), { route: route.id, command: route.command, task, required_skills: route.requiredSkills, context7_required: required, context_tracking: triwikiContextTracking(), stop_gate: 'honest_mode' });
175
178
  await setCurrent(root, routeState(id, route, 'ROUTE_CONTEXT_READY', required, { prompt: task, stop_gate: 'none' }));
176
179
  return routeContext(route, id, task, required, 'Load the route skill context, execute the smallest matching action, and finish with Honest Mode.');
177
180
  }
178
181
 
179
182
  function routeState(id, route, phase, context7Required, extra = {}) {
180
183
  const reasoning = routeReasoning(route, extra.prompt || '');
181
- return { mission_id: id, route: route.id, route_command: route.command, mode: route.mode, phase, context7_required: context7Required, context7_verified: false, required_skills: route.requiredSkills, stop_gate: route.stopGate, reasoning_effort: reasoning.effort, reasoning_profile: reasoning.profile, reasoning_temporary: true, ...extra };
184
+ return { mission_id: id, route: route.id, route_command: route.command, mode: route.mode, phase, context7_required: context7Required, context7_verified: false, context_tracking: 'triwiki', required_skills: route.requiredSkills, stop_gate: route.stopGate, reasoning_effort: reasoning.effort, reasoning_profile: reasoning.profile, reasoning_temporary: true, ...extra };
182
185
  }
183
186
 
184
187
  function routeContext(route, id, task, required, next) {
@@ -24,6 +24,24 @@ export const RECOMMENDED_SKILLS = [
24
24
  'honest-mode'
25
25
  ];
26
26
 
27
+ export function triwikiContextTracking(commandPrefix = 'sks') {
28
+ const prefix = String(commandPrefix || 'sks');
29
+ return {
30
+ ssot: 'triwiki',
31
+ default_pack: '.sneakoscope/wiki/context-pack.json',
32
+ pack_command: `${prefix} wiki pack`,
33
+ validate_command: `${prefix} wiki validate .sneakoscope/wiki/context-pack.json`,
34
+ hydrate_policy: 'hydrate_by_id_hash_source_path_rgba_trig_coordinate',
35
+ selected_text_policy: 'selected_text_is_only_the_visible_slice',
36
+ required_for: ['long_running_routes', 'team_handoffs', 'context_pressure', 'cross_turn_continuity']
37
+ };
38
+ }
39
+
40
+ export function triwikiContextTrackingText(commandPrefix = 'sks') {
41
+ const ctx = triwikiContextTracking(commandPrefix);
42
+ return `Context tracking SSOT: TriWiki. Build or refresh ${ctx.default_pack} with "${ctx.pack_command}" and validate it with "${ctx.validate_command}". Selected text is only the visible slice; non-selected claims remain hydratable by id, hash, source path, and RGBA/trig coordinate.`;
43
+ }
44
+
27
45
  export const ROUTES = [
28
46
  {
29
47
  id: 'DF',
@@ -1,5 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import { appendJsonlBounded, nowIso, readJson, readText, writeJsonAtomic, writeTextAtomic } from './fsx.mjs';
3
+ import { triwikiContextTracking, triwikiContextTrackingText } from './routes.mjs';
3
4
 
4
5
  const MAX_LIVE_BYTES = 192 * 1024;
5
6
  const DEFAULT_AGENTS = ['parent_orchestrator', 'team_consensus', 'implementation_worker', 'db_safety_reviewer', 'qa_reviewer'];
@@ -53,6 +54,7 @@ export function defaultTeamDashboard(id, prompt, opts = {}) {
53
54
  session_policy: `Use at most ${spec.agentSessions} subagent sessions at a time; parent orchestrator is not counted.`,
54
55
  bundle_size: spec.bundleSize,
55
56
  roster: spec.roster,
57
+ context_tracking: triwikiContextTracking(),
56
58
  updated_at: nowIso(),
57
59
  live_files: {
58
60
  markdown: 'team-live.md',
@@ -74,6 +76,7 @@ export function defaultTeamDashboard(id, prompt, opts = {}) {
74
76
 
75
77
  export function teamLiveMarkdown(id, prompt, opts = {}) {
76
78
  const spec = normalizeTeamSpec(opts);
79
+ const contextTracking = triwikiContextTrackingText();
77
80
  return `# SKS Team Live Transcript
78
81
 
79
82
  Mission: ${id}
@@ -99,6 +102,7 @@ ${prompt}
99
102
  - Every useful subagent status, debate result, handoff, review finding, and integration decision must be appended here.
100
103
  - Machine-readable events are mirrored to team-transcript.jsonl.
101
104
  - Dashboard state is mirrored to team-dashboard.json.
105
+ - ${contextTracking}
102
106
 
103
107
  ## Commands
104
108