Skip to content

Commit 5521507

Browse files
authored
Post-refactor cleanup: security fixes, skill restructure, stale reference removal (#28)
* fix: security hardening, code quality, and freshness review fixes Security (3 medium-severity): - Block find -exec/-execdir/-delete/-ok in ExecTool (injection risk) - Add "--" before grep pattern to prevent flag injection - Replace ad-hoc path validation in MCP handlers with safepath.SafeJoin - Use safepath.SafeJoin in policy builtins resolvePath (traversal risk) - Change crash log permissions from 0644 to 0600 Code quality: - Add rows.Err() checks after all 8 rows.Next() loops in codeintel/repository.go - Replace err == io.EOF with errors.Is(err, io.EOF) in 3 files - Fix out.Close() error handling in memory_export.go (named return) Freshness review fixes (Greptile PR #26 feedback): - Fix decay discontinuity: unified formula (1.0 - ratio * 0.8) replaces hardcoded 0.2 all-missing + 0.4 formula partial-missing - Add cache eviction (purge entries >2x TTL when cache exceeds 1000) - Convert global cache to struct-based statCache (testable, bounded) - Add TODO(freshness-level2) comments for dead code paths - Mark freshness plan doc as "implemented with deviations" - Add TestDecaySmoothCurve test verifying no discontinuities * Refactor migration tests and enhance TUI error handling - Updated migration tests to clarify directory structure and improve comments for better understanding. - Enhanced error handling in the TUI by treating agent completion warnings as non-fatal, allowing for smoother user experience. - Improved list view rendering by adding workspace checks and refactoring header rendering for better clarity. - Introduced new skills for TaskWing, including detailed SKILL.md files for various commands to enhance project knowledge and workflow. - Added functionality to simplify code while preserving behavior, ensuring that optimization does not bypass necessary gates. - Implemented status command to provide current task progress and acceptance criteria, improving user awareness of task status. * refactor(plan): remove CLI commands, keep MCP-only planning - Remove cmd/plan.go, cmd/goal.go, and plan TUI (1,982 lines deleted) - MCP plan tool (clarify/generate/decompose/expand/finalize/audit) unchanged - Planning prompt now scales task count dynamically to goal complexity - Tasks include self-contained context (files, patterns, constraints, tech stack) - Task enricher always provides baseline project context (constraints + decisions) - Fix stop hook reliability: sync TasksCompleted from DB on each invocation - Add session save retry logic to prevent stale state from failed writes - Clear stale CurrentTaskID when DB lookup fails * fix: address PR review comments (security + cache + path handling) - policy/builtins.go: use safepath.ValidateAbsPath for absolute paths, fixes prefix collision bypass (e.g. /project-evil matching /project) - freshness/freshness.go: add evictOldest fallback when all cache entries are fresh but cache exceeds max size during burst scenarios - mcp/handlers.go: restore absolute path support in validateAndResolvePath via safepath.ValidateAbsPath, fixing regression for MCP clients - agents/impl/analysis_deps.go: use filepath.Join instead of string concat - bootstrap/factory.go: use safepath.SafeJoin for dependency file checks * feat: unified context API, bootstrap UX polish, model updates, skill improvements - Unified GetProjectContext replaces 3 separate retrieval paths (ContextRetriever, TaskEnricher, buildTaskContext) - Bootstrap: fix duplicate "Bootstrap complete!" in multi-repo, batch link warnings into single summary, clean verification output - Bootstrap: per-service project context in workspace mode, progress callbacks, repo count accuracy - Models: add gpt-5.4/5.4-mini/5.4-nano, claude-opus-4-6/sonnet-4-6, gemini-3.1, remove deprecated models - Models: newest-first ordering in selection UI - UI: grouped knowledge output, freshness indicators, consistent header boxes across all commands - UI: markdown rendering in ask --answer output, adaptive width - Skills: add /taskwing:context, remove /taskwing:debug and /taskwing:simplify, fix stale file pruning - Skills: clarify questions presented to user (not auto-answered), auto-start first task after plan creation - Hooks: stop hook syncs TasksCompleted from DB, session save retry, verbose logs gated behind --debug - MCP: behavioral CLAUDE.md instructions tell AI tools when to use TaskWing - Prompts: generic and directive (no hardcoded tech stack examples), dynamic task count scaling - Fix: read_file tool returns helpful message for directories instead of crashing ReAct agent - Fix: auto-regenerate slash commands on MCP server start after brew upgrade - Fix: truncateString consolidated to utils.Truncate, nil guards in context.go, brief.go pluralization - Remove: CLI plan/goal/slash commands, docs/_partials, sync-docs scripts, stale doc references * fix: remove stale references to removed slash commands Update CLI output, hints, comments, and docs to reflect the 8->4 skill restructure. Replace references to /taskwing:ask, /taskwing:status, /taskwing:explain, and /taskwing:remember with their current equivalents (MCP tools or /taskwing:context). * docs: update marketing materials for post-refactor state Replace removed taskwing goal references, rewrite CHANGELOG unreleased section to reflect consolidated slash commands and MCP-first planning. * fix: address remaining PR review comments - Save task ID before clearing so debug log prints actual value - Use safepath.SafeJoin for tw-* directory cleanup to prevent traversal - Log wave 1 agent errors instead of silently discarding them - Remove dead legacy marker check (duplicate of primary path) - Fix plan_id -> clarify_session_id reference in plan skill * fix: address second round of PR review comments - Propagate critical error from GetProjectContext when constraint DB fetch fails - Resolve ARCHITECTURE.md from basePath directly instead of raw .. traversal - Add TOCTOU re-check in stat cache to prevent stale overwrites under concurrency - Use filepath.Join instead of hardcoded "/" for monorepo subdirectory paths - Replace legacy log.Printf with slog.Debug in doc analysis agent
1 parent 661d172 commit 5521507

89 files changed

Lines changed: 3173 additions & 4401 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@ on:
99
branches: [main]
1010

1111
jobs:
12-
docs-consistency:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- uses: actions/checkout@v4
16-
17-
- name: Check docs consistency
18-
run: ./scripts/check-doc-consistency.sh
19-
2012
lint:
2113
runs-on: ubuntu-latest
2214
steps:

AGENTS.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
- `make test-quick`: fast local checks during iteration.
1717
- `make lint`: runs formatting and static analysis (`go fmt`, `go vet`, `staticcheck`, optional `golangci-lint`).
1818
- `go test ./...`: baseline CI-style test run.
19-
- `./scripts/check-doc-consistency.sh`: validates Markdown/doc sync rules used by CI.
19+
2020

2121
## Coding Style & Naming Conventions
2222

@@ -94,11 +94,8 @@ Brand names and logos are trademarks of their respective owners; usage here indi
9494
<!-- TASKWING_COMMANDS_START -->
9595

9696
- taskwing bootstrap
97-
- taskwing goal "<goal>"
9897
- taskwing ask "<query>"
9998
- taskwing task
100-
- taskwing plan status
101-
- taskwing slash
10299
- taskwing mcp
103100
- taskwing doctor
104101
- taskwing config

CHANGELOG.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12-
- Focused `taskwing goal "<goal>"` command for one-shot clarify -> generate -> activate flow.
13-
- Hard-break CLI surface reduction to core execution workflow commands.
14-
- Local-only default server bind and strict CORS allowlist behavior.
15-
- Workflow contract documentation (`docs/WORKFLOW_CONTRACT_V1.md`) with hard-gate refusal language and KPIs.
16-
- Workflow operations docs for activation and feedback loops (`docs/WORKFLOW_PACK.md`, `docs/PROMPT_FAILURES_LOG.md`).
17-
- Prompt reliability tests for slash command contracts and cross-assistant command description parity.
12+
- `/taskwing:context` slash command for full project knowledge dump.
13+
- Security hardening: freshness validation, stricter input sanitization.
14+
- Prompt reliability tests for slash command contracts.
15+
- Kill tables and operating principles in skill prompts.
16+
- Workflow contract injection via SessionStart hook.
1817

1918
### Changed
2019

21-
- Updated product messaging to the focused motto:
22-
- "TaskWing helps turn a goal into executed tasks with persistent context across AI sessions."
23-
- Updated slash and MCP prompt contracts to unified `task` and `plan` action-based interfaces.
24-
- Purged stale/outdated architecture documentation that no longer matches shipped behavior.
25-
- Reworked `/taskwing:plan`, `/taskwing:next`, `/taskwing:done`, and `/taskwing:debug` prompts as explicit process contracts with hard gates and refusal fallbacks.
26-
- Updated slash command descriptions to trigger-focused "Use when ..." phrasing across assistant command generation.
27-
- Session initialization output now injects TaskWing Workflow Contract v1 for hook-enabled assistants.
20+
- Consolidated slash commands from 8 to 4: `plan`, `next`, `done`, `context`.
21+
- Planning is now MCP-tool-only (removed `taskwing plan` and `taskwing goal` CLI commands).
22+
- Unified context API replaces separate status/ask workflows.
23+
- Updated slash command and MCP prompt contracts to match reduced surface.
24+
- Product messaging focused: "TaskWing helps turn a goal into executed tasks with persistent context across AI sessions."
25+
26+
### Removed
27+
28+
- `taskwing goal` and `taskwing plan` CLI commands (use `/taskwing:plan` or `plan` MCP tool).
29+
- Slash commands: `/taskwing:ask`, `/taskwing:remember`, `/taskwing:status`, `/taskwing:debug`, `/taskwing:explain`, `/taskwing:simplify`.
30+
- Interactive plan TUI (`internal/ui/plan_tui.go`).
31+
- Net reduction of ~1,100 lines.
2832

2933
### Fixed
3034

31-
- **RootPath resolution**: Reject `MarkerNone` contexts in `GetMemoryBasePath` to prevent accidental writes to `~/.taskwing/memory.db`. Also reject `.taskwing` markers above multi-repo workspaces during detection walk-up. (`TestRootPathResolution`, `TestBootstrapRepro_RootPathResolvesToHome`)
32-
- **FK constraint failures**: `LinkNodes` now pre-checks node existence before INSERT to avoid SQLite error 787. Duplicate edges handled gracefully. (`TestKnowledgeLinking_NoFK`)
33-
- **IsMonorepo misclassification**: `Detect()` now checks `hasNestedProjects()` in the `MarkerNone` fallback, so multi-repo workspaces are correctly classified. Resolves disagreement between `Detect()` and `DetectWorkspace()`. (`TestIsMonorepoDetection`, `TestBootstrapRepro_IsMonorepoMisclassification`)
34-
- **Zero docs loaded**: Added `LoadForServices` to `DocLoader` for multi-repo workspaces. Wired into `RunDeterministicBootstrap` via workspace auto-detection. (`TestDocIngestion`, `TestSubrepoMetadataExtraction`)
35-
- **Sub-repo metadata**: Verified per-repo workspace context in node storage with proper isolation and cross-workspace linking. (`TestSubrepoMetadataPresent`)
36-
- **Claude MCP drift**: Added filesystem-based drift detection tests with evidence traceability and Gate 3 consent enforcement for global mutations. (`TestClaudeDriftDetection`)
37-
- **Hallucinated findings**: Gate 3 enforcement in `NewFindingWithEvidence` — findings without evidence start as "skipped". Added `HasEvidence()` and `NeedsHumanVerification()` to `Finding`. (`TestGate3_Enforcement`, `TestParseJSONResponse_Hallucination`)
38-
- Priority scheduling semantics corrected (lower numeric priority executes first).
39-
- Unknown slash subcommands now fail explicitly instead of silently falling back.
40-
- MCP plan action descriptions aligned with implemented behavior.
35+
- RootPath resolution: reject `MarkerNone` contexts to prevent writes to `~/.taskwing/memory.db`.
36+
- FK constraint failures: `LinkNodes` pre-checks node existence before INSERT.
37+
- IsMonorepo misclassification in `MarkerNone` fallback.
38+
- Zero docs loaded for multi-repo workspaces.
39+
- Claude MCP drift detection with evidence traceability.
40+
- Hallucinated findings: Gate 3 enforcement requires evidence.
41+
- Priority scheduling semantics (lower numeric = execute first).
42+
- Unknown slash subcommands fail explicitly instead of silent fallback.
4143

4244
## [0.9.2] - 2025-08-30
4345

CLAUDE.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,11 @@ TaskWing is a local-first AI knowledge layer. It extracts architectural decision
8383
cmd/ # Cobra CLI commands
8484
├── root.go # Base command, global flags (--json, --verbose, --preview, --quiet)
8585
├── bootstrap.go # Auto-generate knowledge from repo
86-
├── goal.go # Goal-first flow: clarify -> generate -> activate
8786
├── knowledge.go # View stored project knowledge nodes
88-
├── plan.go # Plan lifecycle management
8987
├── task.go # Task lifecycle management
90-
├── slash.go # Slash command content for assistants
9188
├── mcp_server.go # MCP server for AI tool integration
9289
├── doctor.go # Diagnostics and integration repair
9390
├── config.go # Provider and runtime configuration
94-
├── start.go # Local API/dashboard runtime
9591
├── hook.go # Hook handlers used by assistant integrations
9692
└── version.go # Version output
9793
@@ -235,7 +231,7 @@ Increment when:
235231

236232
**NOT MINOR**: Internal refactors, new internal modules, code reorganization
237233

238-
Examples: new `taskwing goal` command, new `--format` flag, adding Gemini provider
234+
Examples: new `taskwing config` subcommand, new `--format` flag, adding Gemini provider
239235

240236
### MAJOR (X.0.0) - Breaking changes only
241237

@@ -353,11 +349,8 @@ Brand names and logos are trademarks of their respective owners; usage here indi
353349

354350
<!-- TASKWING_COMMANDS_START -->
355351
- `taskwing bootstrap`
356-
- `taskwing goal "<goal>"`
357352
- `taskwing ask "<query>"`
358353
- `taskwing task`
359-
- `taskwing plan status`
360-
- `taskwing slash`
361354
- `taskwing mcp`
362355
- `taskwing doctor`
363356
- `taskwing config`

GEMINI.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,9 @@ The system is composed of a CLI tool with an embedded MCP server and a web dashb
7777
| Command | Description |
7878
| :------------------- | :---------------------------------------- |
7979
| `taskwing bootstrap` | Initialize project memory |
80-
| `taskwing goal` | Create and activate a plan |
8180
| `taskwing plan` | Manage development plans |
8281
| `taskwing task` | Manage execution tasks |
8382
| `taskwing start` | Start API/watch/dashboard services |
84-
| `taskwing slash` | Output slash command prompts for AI tools |
8583

8684
### Frontend (`dashboard/`)
8785

@@ -232,11 +230,8 @@ Brand names and logos are trademarks of their respective owners; usage here indi
232230

233231
<!-- TASKWING_COMMANDS_START -->
234232
- `taskwing bootstrap`
235-
- `taskwing goal "<goal>"`
236233
- `taskwing ask "<query>"`
237234
- `taskwing task`
238-
- `taskwing plan status`
239-
- `taskwing slash`
240235
- `taskwing mcp`
241236
- `taskwing doctor`
242237
- `taskwing config`

README.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,8 @@ taskwing bootstrap
6666
# 2. Connect to your AI tool
6767
taskwing mcp install claude # or: cursor, gemini, codex, copilot, opencode
6868

69-
# 3. Set a goal and go
70-
taskwing goal "Add Stripe billing"
71-
# -> Plan decomposed into 5 executable tasks
72-
73-
# 4. Execute with your AI assistant
69+
# 3. Plan and execute with your AI assistant
70+
/taskwing:plan # Create a plan via MCP
7471
/taskwing:next # Get next task with full context
7572
# ...work...
7673
/taskwing:done # Mark complete, advance to next
@@ -156,7 +153,7 @@ Brand names and logos are trademarks of their respective owners; usage here indi
156153
| Capability | Description |
157154
|:-----------|:------------|
158155
| **Local knowledge** | Extracts decisions, patterns, and constraints into local SQLite |
159-
| **Goal to tasks** | Turns a goal into an executable plan with decomposed tasks |
156+
| **Plan to tasks** | Turns a plan into decomposed tasks with architecture context |
160157
| **AI-driven lifecycle** | Task execution -- next, start, complete, verify |
161158
| **Code analysis** | Symbol search, call graphs, impact analysis, simplification |
162159
| **Root cause first** | AI-powered diagnosis before proposing fixes |
@@ -168,15 +165,10 @@ Use these from your AI assistant once connected:
168165

169166
| Command | When to use |
170167
|:--------|:------------|
171-
| `/taskwing:ask` | Search project knowledge (decisions, patterns, constraints) |
172-
| `/taskwing:remember` | Persist a decision, pattern, or insight to project memory |
168+
| `/taskwing:plan` | Clarify a goal and build an approved execution plan |
173169
| `/taskwing:next` | Start the next approved task with full context |
174170
| `/taskwing:done` | Complete the current task after verification |
175-
| `/taskwing:status` | Check current task progress and acceptance criteria |
176-
| `/taskwing:plan` | Clarify a goal and build an approved execution plan |
177-
| `/taskwing:debug` | Root-cause-first debugging before proposing fixes |
178-
| `/taskwing:explain` | Deep explanation of a code symbol and its call graph |
179-
| `/taskwing:simplify` | Simplify code while preserving behavior |
171+
| `/taskwing:context` | Get full project knowledge dump for complete architectural context |
180172

181173
<details>
182174
<summary>MCP setup (manual)</summary>
@@ -252,11 +244,8 @@ Or configure interactively: `taskwing config`
252244

253245
<!-- TASKWING_COMMANDS_START -->
254246
- `taskwing bootstrap`
255-
- `taskwing goal "<goal>"`
256247
- `taskwing ask "<query>"`
257248
- `taskwing task`
258-
- `taskwing plan status`
259-
- `taskwing slash`
260249
- `taskwing mcp`
261250
- `taskwing doctor`
262251
- `taskwing config`

0 commit comments

Comments
 (0)