Commit graph

3001 commits

Author SHA1 Message Date
Mikael Hugo
3017663a69 fix(sf): inline extractBodyAfterFrontmatter — it is not exported from commands-prefs-wizard
extractBodyAfterFrontmatter is a private function in commands-prefs-wizard.js.
Inline a local copy in experimental.js and handleThemeCommand (core.js) rather
than importing a non-existent export.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-09 05:37:26 +02:00
Mikael Hugo
b34f5997eb feat(sf): Tier 3 — /rubber-duck, /delegate, /share, /ask, /resume, /sidekicks
handlers/core.js:
- /ask <question> — ephemeral side question via ctx.fork (graceful
  fallback if fork unavailable)
- /resume [id] — session listing via ctx.listSessions; falls back to
  ~/.sf/sessions/ file listing with upgrade hint for BACKGROUND_SESSIONS

handlers/ops.js:
- /rubber-duck [topic] — constructive review subagent gated on
  RUBBER_DUCK experimental flag; routes via ctx.sendMessage
- /delegate [title] — GitHub PR creation via gh pr create --web;
  shows recent commits for context
- /share [md] — export session transcript to ~/sf-session-<ts>.md;
  copies path to clipboard (pbcopy / xclip / xsel)

catalog.js:
- Add /rubber-duck, /delegate, /share, /ask, /resume to TOP_LEVEL_SUBCOMMANDS

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-09 05:35:54 +02:00
Mikael Hugo
c1c3195f75 feat(sf): Tier 2 — SHOW_FILE tool, STATUS_LINE runner, /keep-alive, /sidekicks, Ctrl+G/T/X keybindings
sf-tui/index.js:
- Import getExperimentalFlag / setExperimentalFlag from experimental.js
- Ctrl+G — open project root in $EDITOR
- Ctrl+T — toggle show_reasoning experimental flag
- Ctrl+Alt+B — open /tasks background surface
- Ctrl+Alt+O — open last URL from agent output in browser
- STATUS_LINE runner: setInterval 5s, execFile user script, pipe stdout to ctx.ui.setStatus
- SHOW_FILE tool: pi.registerTool({name:'show_file',...}) gated on show_file flag; reads file slice, renders as fenced code block

handlers/ops.js:
- /keep-alive [off] — spawns caffeinate (macOS) or systemd-inhibit (Linux) as detached process; /keep-alive off kills it

handlers/core.js:
- /sidekicks — reads .sf/parallel/ subdirs, shows STATUS per worker

catalog.js:
- Add /sidekicks and /keep-alive to TOP_LEVEL_SUBCOMMANDS

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-09 05:33:24 +02:00
Mikael Hugo
eaf7165893 feat(sf): Copilot CLI feature parity — /experimental, /diff, /theme, /rename, /streamer-mode, /statusline, /search, /chronicle, /rewind, /instructions
Add experimental feature flag system and 10 new slash commands matching
Copilot CLI's experimental surface.

experimental.js:
- EXPERIMENTAL_FLAGS map (status_line, show_file, ask_elicitation,
  multi_turn_agents, extensions, configure_agent, background_sessions,
  rubber_duck, prompt_frame, streamer_mode)
- getExperimentalFlag / setExperimentalFlag / setAllExperimentalFlags
- Reads/writes project .sf/PREFERENCES.md via prefs frontmatter helpers

handlers/core.js:
- /experimental show|on|off|on <flag>|off <flag>
- /diff [--staged] — git diff HEAD or staged changes
- /theme [dark|light|dim|auto] — get/set UI theme in prefs
- /rename <name> — session name + OSC 2 terminal title
- /streamer-mode [on|off] — mask model names for screen sharing
- /statusline script <path>|off — configure footer status line script
- /search /find <query> — search session timeline entries
- /chronicle — git log + session events overview
- /rewind — revert last turn (ctx.rewind() with graceful fallback)
- /instructions — list all instruction files and their load status

catalog.js: add all 12 new commands to TOP_LEVEL_SUBCOMMANDS for autocomplete

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-09 05:30:25 +02:00
Mikael Hugo
9441022909 feat(tui): mode badge in normal footer + paused state indicator
- renderFooter: add mode badge (compact at <80 cols, full at ≥80 cols)
  to right side so active mode is always visible, not only during auto
- renderAutoFooter: refactor to use shared renderModeBadge instead of
  duplicating badge logic inline
- renderModeBadge: handle paused state — all badge parts dim, 'P!' prefix
  shown in compact form, 'paused ·' prefix shown in full form
- getMode(): surface session.paused as a field on the returned mode object
  so badge renderers can reflect paused state without inspecting session directly
- Export renderModeBadge from header.js; footer imports it via FOOTER_THEME adapter

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-09 04:41:00 +02:00
Mikael Hugo
848ac0dd99 feat(swarm): UOK-based swarm with PersistentAgent, AgentSwarm, and SwarmDispatchLayer
- PersistentAgent: stable identity across restarts, 3-tier memory (core
  blocks / recall / archival), durable SQLite inbox, sendAndWait request-
  reply, broadcast — all backed by UokCoordinationStore + MessageBus
- AgentSwarm: Letta-style group topology with ManagerType enum
  (round_robin, supervisor, dynamic, sleeptime), tag-based routing,
  shared agent_directory block, persist/load round-trip
- Role agents: CoordinatorAgent, WorkerAgent, ScoutAgent, ReviewerAgent
  extending PersistentAgent with preset tags + createDefaultSwarm factory
  (1 coordinator, 2 workers, 1 scout, 1 reviewer)
- SwarmDispatchLayer: routes UOK DispatchEnvelopes by workMode/unitType
  to the correct role agent, module-level cache, swarmDispatch() convenience fn
- 15 tests passing (identity persistence, messaging, registry, topology,
  dispatch routing) using real SQLite in tmp dirs
- Fix: tsconfig.resources.json — add types:[node] for TypeScript 6 compat

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-09 04:04:42 +02:00
Mikael Hugo
1c9b69b57e feat(skills): locked enforcement + workflow skill injection into agent context
Phase 1 — Skill Integrity:
- buildSkillRecord now maps locked: true frontmatter → record.locked
- discoverAllSkills builds locked name set (workflow always locked, bundled if
  frontmatter declares locked: true) and silently drops project/user skills
  that collide with a locked skill name (shadow protection)
- loader.js enforces locked=true unconditionally for workflow source skills
- getUserInvocableSkills now hides locked + workflow skills from /skills catalog
- loadSkills defaults includeWorkflow: true for production context

Phase 2 — Workflow Skill Wiring:
- buildWorkflowConstraintsBlock: loads workflow skills, filters by permission
  profile + work mode triggers, caps at 5, formats as ## Active Workflow
  Constraints block (behavioral guidelines, not invocable tools)
- buildSkillActivationBlock now appends workflow constraints block after the
  user skill_activation block — injected into every agent dispatch prompt
- getAutoSession provides workMode + permissionProfile; fallback to build/normal

Tests: 18 skills tests + 1 auto-prompts test pass (was 15)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-09 03:28:24 +02:00
Mikael Hugo
03e1f808bc feat: two-tier skill architecture with 8 workflow-internal skills
- Add src/resources/workflow-skills/ directory with 8 internal skills
  enforcing the 20 cross-cutting agent patterns from the styleguide:
  P0: observe-first, vertical-slice, context-lean
  P1: irreversible-ops, error-routing, assumption-log
  P2: handoff-readability, state-discipline
- Update skills/directory.js: WORKFLOW_SKILL_DIR constant, workflow
  source in discoverAllSkills, exported all constants inline
- Update skills/loader.js: workflow source forces userInvocable: false;
  loadSkills() defaults to includeWorkflow: true for production use;
  getUserInvocableSkills excludes workflow source
- Update skills/index.js barrel to export WORKFLOW_SKILL_DIR
- Update install-pi-global.js / uninstall-pi-global.js for workflow-skills
- Fix skills.test.mjs: pass includeWorkflow: false in 4 project-scope
  tests to isolate them from the 8 bundled workflow skills
- Remove genai-proxy extension (unused, replaced by direct provider integration)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-09 02:55:16 +02:00
Mikael Hugo
9875812c1b sf snapshot: uncommitted changes after 131m inactivity 2026-05-09 02:53:47 +02:00
Mikael Hugo
5188b93ddc feat: Shift+Tab cycles work modes, Ctrl+T cycles thinking level
- Shift+Tab: cycles work mode (chat→plan→build→review→repair→research)
  when idle; opens steerable panel during autonomous execution
- Ctrl+T: cycles thinking level (replaces shift+tab binding)
- Removed toggleThinking from default Ctrl+T (superseded by cycleThinkingLevel)
- Drop hint for toggleThinking from interactive mode help text

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-09 00:42:41 +02:00
Mikael Hugo
22cbd83675 fix: update test snapshots for queryInstruction and complete /sf prefix Phase 2 deprecation
- Fix memory-embeddings-llm-gateway tests: add queryInstruction field to
  expected config objects after loadGatewayConfigFromEnv was updated to
  return it
- Add STYLEGUIDE.md: SF code standards adapted from ace-coder patterns
  (purpose doctrine, principles, anti-patterns STY001-012, thresholds,
  naming, patterns, documentation sections)
- Phase 2 /sf prefix removal: update all web components, browser dispatch,
  and tests to use direct commands (/autonomous, /stop, /next, /discuss,
  /init, /new-milestone) instead of /sf-prefixed forms
  - workflow-actions.ts: all command strings updated
  - chat-mode.tsx: SF_ACTIONS array updated
  - project-welcome.tsx: primaryCommand values updated
  - command-surface.tsx: fallback display updated
  - remaining-command-panels.tsx: usage examples updated
  - browser-slash-command-dispatch.ts: add stop/new-milestone/init to
    SF_PASSTHROUGH_COMMANDS so they route correctly to the extension
  - recovery-diagnostics-service.ts: suggestion commands updated
  - welcome-screen.ts: hint text updated
  - All affected tests updated to match new command strings

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-09 00:17:47 +02:00
Mikael Hugo
e4c951ff0c feat: improve sf runtime self-reload and safeguards 2026-05-08 23:52:35 +02:00
Mikael Hugo
c5e9e4f9c8 fix: guard completeValidationRun and drop dead superseded_by column
- completeValidationRun now checks status='running' in WHERE clause and
  throws if no row was updated (catches double-complete and invalid runId)
- Remove unused superseded_by column from v46 CREATE TABLE DDL
- Add migration v47 to DROP COLUMN superseded_by from existing DBs
- Bump SCHEMA_VERSION to 47

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-05-08 21:45:58 +02:00
Mikael Hugo
6e6363da0d feat: migrate src/ core TS files to LogTape structured logging
Migrate 5 non-test TS files in src/ from console.* to LogTape:
- src/env.ts → getLogger('sf.core.env')
- src/resource-loader.ts → getLogger('sf.core.resource-loader')
- src/web/undo-service.ts → getLogger('sf.web.undo-service')
- src/web/cleanup-service.ts → getLogger('sf.web.cleanup-service')
- src/web/auto-dashboard-service.ts → getLogger('sf.web.auto-dashboard-service')

console.error(err) → log.error(msg, {error: err})
console.warn(msg) → log.warn(msg)

All CLI-facing output preserved. typecheck, lint pass.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-05-08 21:01:08 +02:00
Mikael Hugo
a46cbcbe40 Add more untracked runtime extension files 2026-05-08 20:51:18 +02:00
Mikael Hugo
fd06629f06 feat: add centralized LogTape logger module with dev/autonomous modes, PII redaction, and per-session file rotation
- Install @logtape/logtape, @logtape/pretty, @logtape/file, @logtape/redaction
- Create src/logger.ts with configureLogger() and getLogger() exports
- Dev mode: pretty console output with debug level
- Autonomous mode: JSON console + rotating file sink in .sf/logs/{sessionId}/
- PII redaction for API keys (sk-*, key-*, Bearer *) and home directory paths
- Category hierarchy: sf.core, sf.uok, sf.autonomous, sf.extension, sf.web
- Comprehensive tests in src/tests/logger.test.ts (10 tests)
- Wire configureLogger() into src/cli.ts startup path

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-05-08 19:58:11 +02:00
Mikael Hugo
8f02524fd7 Add untracked runtime extension files to git 2026-05-08 19:55:39 +02:00
Mikael Hugo
c3b202dd4c fix: use IS for NULL-safe equality in validation run queries
Consistent with latest_validation_state view. The verbose
(slice_id = :param OR (slice_id IS NULL AND :param IS NULL))
pattern is functionally equivalent to slice_id IS :param in SQLite.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-05-08 19:15:31 +02:00
Mikael Hugo
3b4dbfbcf0 Fix extension manifest and database schema for metrics-central
- Add missing commands: cost, implement, research, trajectory
- Fix validation runs schema: remove DEFAULT on created_at, make explicit in INSERT
- Simplify latest_validation_state view using MAX(rowid) approach
- Add run_id DESC to validation query ORDER BY clauses for consistent ordering
2026-05-08 19:13:44 +02:00
Mikael Hugo
533d1ce83c sf snapshot: uncommitted changes after 32m inactivity 2026-05-08 18:51:07 +02:00
Mikael Hugo
7287490cfd fix: enhance missing-checkpoint repair with better low-confidence guidance
- Add explicit low-confidence reconstruction guidance for no-transcript cases
- Clarify when to use outcome='decide' when confidence < 0.98
- Fix typo in repair prompt ('what was was expected' -> 'what was expected')
- Strengthen final human-acceptance-gate guidance to prefer outcome='decide'
- Addresses solver-missing-checkpoint self-feedback entry acceptance criteria

Resolves: sf-mowykewh-3ehn5p
2026-05-08 15:47:00 +02:00
Mikael Hugo
4601a7d3fb fix(sf): implement features hinted by unused-import warnings
- ai-memory-tools.js: use options param for configurable limits in formatAllMemoriesForPrompt
- metrics-central.js: enforce MAX_HISTOGRAM_BUCKETS cap on histogram bucket count
- reasoning-assist.js: use REASONING_ASSIST_MAX_CHARS to cap prompt length with logWarning
- trajectory-recorder.js: add debugLog for failed step recordings

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-05-08 15:18:58 +02:00
Mikael Hugo
f440fbed9c autoresearch: checkpoint memory and runtime changes 2026-05-08 14:58:10 +02:00
Mikael Hugo
40a93f9c16 fix(autoresearch): remove all 11 remaining biome lint warnings
Result: {"status": "keep", "diagnostics": 0, "delta": "-100%"}

- Removed unused imports: injectReasoningGuidance, withQueryTimeout,
  getAutoSession, logWarning (x3), debugLog, readFileSync/unlinkSync/writeFileSync
- Prefixed intentionally unused vars with underscore: MAX_HISTOGRAM_BUCKETS,
  REASONING_ASSIST_MAX_CHARS, basePath parameter
- All vitest tests pass (1064 passed)
- Biome check: 0 errors, 0 warnings
2026-05-08 14:33:46 +02:00
Mikael Hugo
c6ee7701b2 autoresearch: auto-fix format + organizeImports
Result: {"status": "keep", "diagnostics": 11, "errors": 0, "warnings": 11}
2026-05-08 14:28:22 +02:00
Mikael Hugo
15269f4176 sf snapshot: uncommitted changes after 202m inactivity 2026-05-08 13:31:08 +02:00
Mikael Hugo
d548ea01c5 sf snapshot: uncommitted changes after 155m inactivity 2026-05-08 10:08:39 +02:00
Mikael Hugo
0cfe839f7a fix(sf): guard progress widget cleanup 2026-05-08 07:17:29 +02:00
Mikael Hugo
10694440e3 feat(sf): align uok task state and steering 2026-05-08 06:57:59 +02:00
Mikael Hugo
378ab702e1 feat(sf): streamline uok state and direct modes 2026-05-08 05:51:06 +02:00
Mikael Hugo
19bfc3d3f6 feat(sf): align node sqlite uok runtime 2026-05-08 03:01:20 +02:00
Mikael Hugo
d640aa0949 test(sf): align direct command web contracts 2026-05-08 01:48:50 +02:00
Mikael Hugo
b5893d1c28 Make SF direct command surface baseline 2026-05-08 01:34:07 +02:00
Mikael Hugo
6fc054e7c3 sf snapshot: uncommitted changes after 49m inactivity 2026-05-08 01:07:24 +02:00
Mikael Hugo
89677b7e9b sf snapshot: uncommitted changes after 110m inactivity 2026-05-08 00:17:47 +02:00
Mikael Hugo
d05e7164a9 feat: journal execution policy decisions 2026-05-07 22:27:29 +02:00
Mikael Hugo
e9df932234 feat: add execution policy profiles 2026-05-07 18:21:47 +02:00
Mikael Hugo
b0fce94f9e feat: record retrieval evidence across context tools 2026-05-07 18:17:41 +02:00
Mikael Hugo
b1a7749763 fix: harden widget and provider auth handling 2026-05-07 17:20:52 +02:00
Mikael Hugo
3c84bd2fed fix: stabilize headless bootstrap and prompt history 2026-05-07 16:46:44 +02:00
Mikael Hugo
deeb4dbd4e sf snapshot: uncommitted changes after 61m inactivity 2026-05-07 16:39:39 +02:00
Mikael Hugo
8088489e38 sf snapshot: uncommitted changes after 258m inactivity 2026-05-07 15:37:55 +02:00
Mikael Hugo
e154dad930 fix: clean workflow helper extraction lint 2026-05-07 11:19:26 +02:00
Mikael Hugo
343ee5c89e sf snapshot: uncommitted changes after 158m inactivity 2026-05-07 10:01:56 +02:00
Mikael Hugo
6e0273573c refactor: Extract workflow-helpers module from auto-prompts (D3)
- Extract buildResumeSection and buildCarryForwardSection for continue/carry-forward logic
- Extract checkNeedsReassessment and checkNeedsRunUat for adaptive replanning
- Consolidates workflow state checking and section building
- No behavior change; backward compatible via re-export pattern
- Reduces auto-prompts.js by ~260 LOC

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-07 07:23:43 +02:00
Mikael Hugo
e99d50fbc1 refactor: Extract summary-helpers module from auto-prompts (D2)
- Extract buildSliceSummaryExcerpt to format slice summaries as excerpts
- Extract getPriorTaskSummaryPaths and getDependencyTaskSummaryPaths
- Extract isSummaryCleanForSkip for replan decision logic
- Consolidates summary extraction logic for reuse and testability
- No behavior change; backward compatible via re-export pattern
- Reduces auto-prompts.js by ~120 LOC

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-07 07:16:56 +02:00
Mikael Hugo
d75ed12d89 refactor: Extract io-helpers module from auto-prompts (D1)
- Extract inlineFile, inlineFileOptional, inlineFileSmart to io-helpers.js
- Enables testable file I/O utilities reusable across prompt builders
- No behavior change; backward compatible via re-export pattern
- Reduces auto-prompts.js cognitive load by ~50 LOC

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-07 07:09:46 +02:00
Mikael Hugo
de3990093e style: Organize imports in memory-store.js per Biome
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-07 06:57:36 +02:00
Mikael Hugo
5e518dd7d4 feat: Add SM cross-project recall to memory ranking (Phase 3)
- Import querySmMemories from sm-client.js
- Merge cross-project memories into getRelevantMemoriesRanked
- Cap cross-project confidence at 0.8 with 0.9 reduction (conservative)
- Gracefully degrade: fail-open if SM unavailable
- Preserve cosine ranking with relation boost for merged pool
- Tests: 3821 passing, no regressions

Implements Tier 1.2 Phase 3: Cross-project memory recall via Singularity Memory.
Enables dispatch to leverage patterns from other projects while maintaining
local autonomy via fail-open semantics.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-07 06:56:15 +02:00
Mikael Hugo
bfb892eca3 fix: bind todo backlog triage to project db 2026-05-07 06:40:28 +02:00