knowns 0.8.2 → 0.8.4
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/dist/index.js +301 -135
- package/dist/mcp/server.js +88 -20
- package/dist/ui/assets/{index-D3_NArD-.js → index-NuqnrMx0.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -30454,7 +30454,7 @@ var require_view = __commonJS({
|
|
|
30454
30454
|
var dirname5 = path.dirname;
|
|
30455
30455
|
var basename3 = path.basename;
|
|
30456
30456
|
var extname = path.extname;
|
|
30457
|
-
var
|
|
30457
|
+
var join24 = path.join;
|
|
30458
30458
|
var resolve = path.resolve;
|
|
30459
30459
|
module2.exports = View;
|
|
30460
30460
|
function View(name, options2) {
|
|
@@ -30516,12 +30516,12 @@ var require_view = __commonJS({
|
|
|
30516
30516
|
};
|
|
30517
30517
|
View.prototype.resolve = function resolve2(dir, file3) {
|
|
30518
30518
|
var ext = this.ext;
|
|
30519
|
-
var path2 =
|
|
30519
|
+
var path2 = join24(dir, file3);
|
|
30520
30520
|
var stat3 = tryStat(path2);
|
|
30521
30521
|
if (stat3 && stat3.isFile()) {
|
|
30522
30522
|
return path2;
|
|
30523
30523
|
}
|
|
30524
|
-
path2 =
|
|
30524
|
+
path2 = join24(dir, basename3(file3, ext), "index" + ext);
|
|
30525
30525
|
stat3 = tryStat(path2);
|
|
30526
30526
|
if (stat3 && stat3.isFile()) {
|
|
30527
30527
|
return path2;
|
|
@@ -34166,7 +34166,7 @@ var require_send = __commonJS({
|
|
|
34166
34166
|
var Stream = __require("stream");
|
|
34167
34167
|
var util2 = __require("util");
|
|
34168
34168
|
var extname = path.extname;
|
|
34169
|
-
var
|
|
34169
|
+
var join24 = path.join;
|
|
34170
34170
|
var normalize = path.normalize;
|
|
34171
34171
|
var resolve = path.resolve;
|
|
34172
34172
|
var sep = path.sep;
|
|
@@ -34338,7 +34338,7 @@ var require_send = __commonJS({
|
|
|
34338
34338
|
return res;
|
|
34339
34339
|
}
|
|
34340
34340
|
parts = path2.split(sep);
|
|
34341
|
-
path2 = normalize(
|
|
34341
|
+
path2 = normalize(join24(root, path2));
|
|
34342
34342
|
} else {
|
|
34343
34343
|
if (UP_PATH_REGEXP.test(path2)) {
|
|
34344
34344
|
debug('malicious path "%s"', path2);
|
|
@@ -34471,7 +34471,7 @@ var require_send = __commonJS({
|
|
|
34471
34471
|
if (err) return self.onStatError(err);
|
|
34472
34472
|
return self.error(404);
|
|
34473
34473
|
}
|
|
34474
|
-
var p =
|
|
34474
|
+
var p = join24(path2, self._index[i]);
|
|
34475
34475
|
debug('stat "%s"', p);
|
|
34476
34476
|
fs.stat(p, function(err2, stat3) {
|
|
34477
34477
|
if (err2) return next(err2);
|
|
@@ -43475,20 +43475,114 @@ import { mkdir as mkdir3, readFile as readFile2, writeFile as writeFile2 } from
|
|
|
43475
43475
|
import { dirname, join as join3 } from "node:path";
|
|
43476
43476
|
var import_prompts = __toESM(require_prompts3(), 1);
|
|
43477
43477
|
|
|
43478
|
-
// src/templates/
|
|
43479
|
-
var
|
|
43480
|
-
|
|
43481
|
-
// src/templates/
|
|
43482
|
-
var
|
|
43478
|
+
// src/templates/guidelines/core-rules.md
|
|
43479
|
+
var core_rules_default = '# Core Rules\n\nYou MUST follow these rules. If you cannot follow any rule, stop and ask for guidance before proceeding.\n\n---\n\n## \u{1F3AF} The Golden Rule\n\n**If you want to change ANYTHING in a task or doc, use CLI commands or MCP tools. NEVER edit .md files directly.**\n\nWhy? Direct file editing breaks metadata synchronization, Git tracking, and relationships.\n\n---\n\n## \u26A0\uFE0F CRITICAL: The -a Flag Confusion\n\nThe `-a` flag means DIFFERENT things in different commands:\n\n| Command | `-a` Means | NOT This! |\n|---------|------------|-----------|\n| `task create` | `--assignee` (assign user) | ~~acceptance criteria~~ |\n| `task edit` | `--assignee` (assign user) | ~~acceptance criteria~~ |\n| `doc edit` | `--append` (append content) | ~~assignee~~ |\n\n### Acceptance Criteria: Use --ac\n\n```bash\n# \u274C WRONG: -a is assignee, NOT acceptance criteria!\nknowns task edit 35 -a "- [ ] Criterion" # Sets assignee to garbage!\nknowns task create "Title" -a "Criterion" # Sets assignee to garbage!\n\n# \u2705 CORRECT: Use --ac for acceptance criteria\nknowns task edit 35 --ac "Criterion one"\nknowns task edit 35 --ac "Criterion two"\nknowns task create "Title" --ac "Criterion one" --ac "Criterion two"\n```\n\n---\n\n## Core Principles\n\n| Rule | Description |\n|------|-------------|\n| **CLI/MCP Only** | Use commands for ALL operations. NEVER edit .md files directly |\n| **Docs First** | Read project docs BEFORE planning or coding |\n| **Time Tracking** | Always start timer when taking task, stop when done |\n| **Plan Approval** | Share plan with user, WAIT for approval before coding |\n| **Check AC After Work** | Only mark acceptance criteria done AFTER completing the work |\n\n---\n\n## The --plain Flag\n\n**ONLY for view/list/search commands (NOT create/edit):**\n\n```bash\n# \u2705 CORRECT\nknowns task <id> --plain\nknowns task list --plain\nknowns doc "path" --plain\nknowns doc list --plain\nknowns search "query" --plain\n\n# \u274C WRONG (create/edit don\'t support --plain)\nknowns task create "Title" --plain # ERROR!\nknowns task edit <id> -s done --plain # ERROR!\nknowns doc create "Title" --plain # ERROR!\nknowns doc edit "name" -c "..." --plain # ERROR!\n```\n\n---\n\n## Reference System\n\n| Context | Task Format | Doc Format |\n|---------|-------------|------------|\n| **Writing** (input) | `@task-<id>` | `@doc/<path>` |\n| **Reading** (output) | `@.knowns/tasks/task-<id>` | `@.knowns/docs/<path>.md` |\n\nFollow refs recursively until complete context gathered.\n\n---\n\n## Task IDs\n\n| Format | Example | Notes |\n|--------|---------|-------|\n| Sequential | `48`, `49` | Legacy numeric |\n| Hierarchical | `48.1`, `48.2` | Legacy subtasks |\n| Random | `qkh5ne` | Current (6-char) |\n\n**CRITICAL:** Use raw ID for `--parent`:\n```bash\n# \u2705 CORRECT\nknowns task create "Title" --parent 48\n\n# \u274C WRONG\nknowns task create "Title" --parent task-48\n```\n\n---\n\n## Status & Priority\n\n| Status | When |\n|--------|------|\n| `todo` | Not started (default) |\n| `in-progress` | Currently working |\n| `in-review` | PR submitted |\n| `blocked` | Waiting on dependency |\n| `done` | All criteria met |\n\n| Priority | Level |\n|----------|-------|\n| `low` | Nice-to-have |\n| `medium` | Normal (default) |\n| `high` | Urgent |\n';
|
|
43480
|
+
|
|
43481
|
+
// src/templates/guidelines/commands-reference.md
|
|
43482
|
+
var commands_reference_default = '# CLI Commands Reference\n\nComplete reference for all Knowns CLI commands.\n\n---\n\n## Task Commands\n\n### task create\n\n```\nknowns task create <title> [options]\n```\n\n| Flag | Short | Purpose | Example |\n|------|-------|---------|---------|\n| `--description` | `-d` | Task description | `-d "Fix the login bug"` |\n| `--ac` | | Acceptance criterion (repeatable) | `--ac "User can login"` |\n| `--labels` | `-l` | Comma-separated labels | `-l "bug,urgent"` |\n| `--assignee` | `-a` | Assign to user | `-a @username` |\n| `--priority` | | low/medium/high | `--priority high` |\n| `--status` | `-s` | Initial status | `-s todo` |\n| `--parent` | | Parent task ID (raw ID only!) | `--parent 48` |\n\n**Example:**\n```bash\nknowns task create "Fix login timeout" \\\n -d "Users experience timeout on slow networks" \\\n --ac "Login works on 3G connection" \\\n --ac "Timeout increased to 30s" \\\n -l "bug,auth" \\\n --priority high\n```\n\n---\n\n### task edit\n\n```\nknowns task edit <id> [options]\n```\n\n| Flag | Short | Purpose | Example |\n|------|-------|---------|---------|\n| `--title` | `-t` | Change title | `-t "New title"` |\n| `--description` | `-d` | Change description | `-d "New desc"` |\n| `--status` | `-s` | Change status | `-s in-progress` |\n| `--priority` | | Change priority | `--priority high` |\n| `--labels` | `-l` | Set labels | `-l "bug,urgent"` |\n| `--assignee` | `-a` | Assign user \u26A0\uFE0F | `-a @username` |\n| `--parent` | | Move to parent | `--parent 48` |\n| `--ac` | | Add acceptance criterion | `--ac "New criterion"` |\n| `--check-ac` | | Mark AC done (1-indexed) | `--check-ac 1` |\n| `--uncheck-ac` | | Unmark AC (1-indexed) | `--uncheck-ac 1` |\n| `--remove-ac` | | Delete AC (1-indexed) | `--remove-ac 3` |\n| `--plan` | | Set implementation plan | `--plan "1. Step one"` |\n| `--notes` | | Replace notes | `--notes "Summary"` |\n| `--append-notes` | | Add to notes | `--append-notes "\u2713 Done"` |\n\n**\u26A0\uFE0F WARNING:** `-a` is assignee, NOT acceptance criteria! Use `--ac` for AC.\n\n**Examples:**\n```bash\n# Take task\nknowns task edit abc123 -s in-progress -a @me\n\n# Add acceptance criteria (use --ac, NOT -a!)\nknowns task edit abc123 --ac "Feature works offline"\n\n# Check criteria as done (1-indexed)\nknowns task edit abc123 --check-ac 1 --check-ac 2\n\n# Add implementation plan\nknowns task edit abc123 --plan $\'1. Research\\n2. Implement\\n3. Test\'\n\n# Add progress notes\nknowns task edit abc123 --append-notes "\u2713 Completed research phase"\n\n# Complete task\nknowns task edit abc123 -s done\n```\n\n---\n\n### task view/list\n\n```bash\n# View single task (ALWAYS use --plain for AI)\nknowns task <id> --plain\nknowns task view <id> --plain\n\n# List tasks\nknowns task list --plain\nknowns task list --status in-progress --plain\nknowns task list --assignee @me --plain\nknowns task list --tree --plain\n```\n\n---\n\n## Doc Commands\n\n### doc create\n\n```\nknowns doc create <title> [options]\n```\n\n| Flag | Short | Purpose | Example |\n|------|-------|---------|---------|\n| `--description` | `-d` | Description | `-d "API reference"` |\n| `--tags` | `-t` | Comma-separated tags | `-t "api,reference"` |\n| `--folder` | `-f` | Folder path | `-f "guides"` |\n\n**Example:**\n```bash\nknowns doc create "API Reference" \\\n -d "REST API documentation" \\\n -t "api,docs" \\\n -f "api"\n```\n\n---\n\n### doc edit\n\n```\nknowns doc edit <name> [options]\n```\n\n| Flag | Short | Purpose | Example |\n|------|-------|---------|---------|\n| `--title` | `-t` | Change title | `-t "New Title"` |\n| `--description` | `-d` | Change description | `-d "New desc"` |\n| `--tags` | | Set tags | `--tags "new,tags"` |\n| `--content` | `-c` | Replace content | `-c "New content"` |\n| `--append` | `-a` | Append content \u26A0\uFE0F | `-a "Added section"` |\n| `--content-file` | | Content from file | `--content-file ./content.md` |\n| `--append-file` | | Append from file | `--append-file ./more.md` |\n\n**\u26A0\uFE0F NOTE:** In doc edit, `-a` means append content, NOT assignee!\n\n**Examples:**\n```bash\n# Replace content\nknowns doc edit "readme" -c "# New Content"\n\n# Append content\nknowns doc edit "readme" -a "## New Section"\n```\n\n---\n\n### doc view/list\n\n```bash\n# View doc (ALWAYS use --plain for AI)\nknowns doc <path> --plain\nknowns doc view "<path>" --plain\n\n# List docs\nknowns doc list --plain\nknowns doc list --tag api --plain\nknowns doc list "guides/" --plain\n```\n\n---\n\n## Time Commands\n\n```bash\n# Start timer (REQUIRED when taking task)\nknowns time start <taskId>\n\n# Stop timer (REQUIRED when completing task)\nknowns time stop\n\n# Pause/resume\nknowns time pause\nknowns time resume\n\n# Check status\nknowns time status\n\n# Manual entry\nknowns time add <taskId> <duration> -n "Note" -d "2025-01-01"\n# duration: "2h", "30m", "1h30m"\n\n# Report\nknowns time report --from "2025-01-01" --to "2025-12-31"\n```\n\n---\n\n## Search Commands\n\n```bash\n# Search everything\nknowns search "query" --plain\n\n# Search by type\nknowns search "auth" --type task --plain\nknowns search "api" --type doc --plain\n\n# Filter by status/priority\nknowns search "bug" --type task --status in-progress --priority high --plain\n```\n\n---\n\n## Multi-line Input\n\nDifferent shells handle multi-line strings differently:\n\n**Bash/Zsh (ANSI-C quoting):**\n```bash\nknowns task edit <id> --plan $\'1. Step one\\n2. Step two\\n3. Step three\'\n```\n\n**PowerShell:**\n```powershell\nknowns task edit <id> --plan "1. Step one`n2. Step two`n3. Step three"\n```\n\n**Cross-platform (heredoc):**\n```bash\nknowns task edit <id> --plan "$(cat <<EOF\n1. Step one\n2. Step two\n3. Step three\nEOF\n)"\n```\n\n---\n\n## MCP Tools (Alternative to CLI)\n\n| Action | MCP Tool |\n|--------|----------|\n| List tasks | `list_tasks({})` |\n| Get task | `get_task({ taskId })` |\n| Create task | `create_task({ title, description, priority, labels })` |\n| Update task | `update_task({ taskId, status, assignee, plan, notes })` |\n| Search tasks | `search_tasks({ query })` |\n| List docs | `list_docs({})` |\n| Get doc | `get_doc({ path })` |\n| Create doc | `create_doc({ title, description, tags, folder })` |\n| Update doc | `update_doc({ path, content, appendContent })` |\n| Start timer | `start_time({ taskId })` |\n| Stop timer | `stop_time({ taskId })` |\n\n**Note:** MCP does NOT support acceptance criteria operations. Use CLI:\n```bash\nknowns task edit <id> --ac "criterion"\nknowns task edit <id> --check-ac 1\n```\n';
|
|
43483
|
+
|
|
43484
|
+
// src/templates/guidelines/workflow-completion.md
|
|
43485
|
+
var workflow_completion_default = '# Task Completion Workflow\n\nGuide for properly completing tasks.\n\n---\n\n## Definition of Done\n\nA task is **Done** ONLY when **ALL** of the following are complete:\n\n### \u2705 Via CLI Commands\n\n| Requirement | Command | Status |\n|-------------|---------|--------|\n| All AC checked | `knowns task edit <id> --check-ac N` | Required |\n| Implementation notes added | `knowns task edit <id> --notes "..."` | Required |\n| Timer stopped | `knowns time stop` | Required |\n| Status set to done | `knowns task edit <id> -s done` | Required |\n\n### \u2705 Via Code/Testing\n\n| Requirement | Action | Status |\n|-------------|--------|--------|\n| Tests pass | Run test suite | Required |\n| No regressions | Verify existing functionality | Required |\n| Docs updated | Update relevant documentation | If applicable |\n| Code reviewed | Self-review changes | Required |\n\n---\n\n## Completion Steps\n\n### Step 1: Verify All Acceptance Criteria\n\n```bash\n# View the task to check AC status\nknowns task <id> --plain\n\n# Ensure ALL criteria are checked\n# If any are unchecked, complete the work first!\n```\n\n### Step 2: Add Implementation Notes\n\nWrite notes suitable for a PR description:\n\n```bash\nknowns task edit <id> --notes $\'## Summary\nImplemented JWT authentication using jsonwebtoken library.\n\n## Changes\n- Added auth middleware in src/middleware/auth.ts\n- Added /login and /refresh endpoints\n- Created JWT utility functions\n\n## Tests\n- Added 15 unit tests\n- Coverage: 94%\n\n## Notes\n- Chose HS256 algorithm for simplicity\n- Token expiry set to 1 hour as per requirements\'\n```\n\n**Good notes include:**\n- What was implemented\n- Key decisions and why\n- Files changed\n- Test coverage\n- Any follow-up needed\n\n### Step 3: Stop Timer\n\n```bash\nknowns time stop\n```\n\n**\u26A0\uFE0F CRITICAL:** Never forget to stop the timer!\n\nIf you forgot to stop earlier, add manual entry:\n```bash\nknowns time add <id> 2h -n "Forgot to stop timer"\n```\n\n### Step 4: Mark as Done\n\n```bash\nknowns task edit <id> -s done\n```\n\n---\n\n## Post-Completion Changes\n\nIf the user requests changes **AFTER** the task is marked done:\n\n```bash\n# 1. Reopen task\nknowns task edit <id> -s in-progress\n\n# 2. Restart timer\nknowns time start <id>\n\n# 3. Add AC for the changes\nknowns task edit <id> --ac "Post-completion fix: description"\n\n# 4. Document why reopened\nknowns task edit <id> --append-notes "\u{1F504} Reopened: User requested changes - reason"\n\n# 5. Complete the work, then follow completion steps again\n```\n\n---\n\n## Knowledge Extraction\n\nAfter completing a task, consider if any knowledge should be documented:\n\n```bash\n# Search if similar pattern already documented\nknowns search "pattern-name" --type doc --plain\n\n# If new reusable knowledge, create doc\nknowns doc create "Pattern: Name" \\\n -d "Reusable pattern from task implementation" \\\n -t "pattern" \\\n -f "patterns"\n\n# Reference source task\nknowns doc edit "patterns/name" -a "Source: @task-<id>"\n```\n\n**Extract knowledge when:**\n- New patterns/conventions discovered\n- Common error solutions found\n- Reusable code approaches identified\n- Integration patterns documented\n\n**Don\'t extract:**\n- Task-specific details (those belong in implementation notes)\n- One-off solutions\n\n---\n\n## Common Mistakes\n\n### \u274C Marking done without all AC checked\n\n```bash\n# \u274C Wrong: AC not all checked\nknowns task edit <id> -s done\n\n# \u2705 Right: Check all AC first\nknowns task edit <id> --check-ac 1 --check-ac 2 --check-ac 3\nknowns task edit <id> -s done\n```\n\n### \u274C Forgetting to stop timer\n\nTimer keeps running! Always stop when done:\n```bash\nknowns time stop\n```\n\n### \u274C No implementation notes\n\nNotes are required for PR description:\n```bash\n# \u274C Wrong: No notes\nknowns task edit <id> -s done\n\n# \u2705 Right: Add notes first\nknowns task edit <id> --notes "Summary of what was done"\nknowns task edit <id> -s done\n```\n\n### \u274C Autonomously creating follow-up tasks\n\nAfter completing work, **present** follow-up ideas to the user. Don\'t automatically create new tasks without permission.\n\n---\n\n## Completion Checklist\n\nBefore marking done, verify:\n\n- [ ] All acceptance criteria are checked (`--check-ac`)\n- [ ] Implementation notes are added (`--notes`)\n- [ ] Implementation plan reflects final approach\n- [ ] Tests pass without regressions\n- [ ] Documentation updated if needed\n- [ ] Timer stopped (`knowns time stop`)\n- [ ] Status set to done (`-s done`)\n';
|
|
43486
|
+
|
|
43487
|
+
// src/templates/guidelines/workflow-creation.md
|
|
43488
|
+
var workflow_creation_default = '# Task Creation Workflow\n\nGuide for creating well-structured tasks.\n\n---\n\n## Step 1: Search First\n\nBefore creating a new task, check if similar work already exists:\n\n```bash\n# Search for existing tasks\nknowns search "keyword" --type task --plain\n\n# List tasks by status\nknowns task list --status todo --plain\nknowns task list --status in-progress --plain\n```\n\n**Why?** Avoid duplicate work and understand existing context.\n\n---\n\n## Step 2: Assess Scope\n\nAsk yourself:\n- Does this work fit in one PR?\n- Does it span multiple systems?\n- Are there natural breaking points?\n\n**Single task:** Work is focused, affects one area\n**Multiple tasks:** Work spans different subsystems or has phases\n\n---\n\n## Step 3: Create with Proper Structure\n\n### Basic Task Creation\n\n```bash\nknowns task create "Clear title describing what needs to be done" \\\n -d "Description explaining WHY this is needed" \\\n --ac "First acceptance criterion" \\\n --ac "Second acceptance criterion" \\\n --priority medium \\\n -l "label1,label2"\n```\n\n### Creating Subtasks\n\n```bash\n# Create parent task first\nknowns task create "Parent feature"\n\n# Create subtasks (use raw ID, not task-XX)\nknowns task create "Subtask 1" --parent 48\nknowns task create "Subtask 2" --parent 48\n```\n\n---\n\n## Task Quality Guidelines\n\n### Title (The "what")\n\nClear, brief summary of the task.\n\n| \u274C Bad | \u2705 Good |\n|--------|---------|\n| Do auth stuff | Add JWT authentication |\n| Fix bug | Fix login timeout on slow networks |\n| Update docs | Document rate limiting in API.md |\n\n### Description (The "why")\n\nExplains context and purpose. Include doc references.\n\n```markdown\nWe need JWT authentication because sessions don\'t scale\nfor our microservices architecture.\n\nRelated: @doc/security-patterns, @doc/api-guidelines\n```\n\n### Acceptance Criteria (The "what" - outcomes)\n\n**Key Principles:**\n- **Outcome-oriented** - Focus on results, not implementation\n- **Testable** - Can be objectively verified\n- **User-focused** - Frame from end-user perspective\n\n| \u274C Bad (Implementation details) | \u2705 Good (Outcomes) |\n|--------------------------------|-------------------|\n| Add function handleLogin() in auth.ts | User can login and receive JWT token |\n| Use bcrypt for hashing | Passwords are securely hashed |\n| Add try-catch blocks | Errors return appropriate HTTP status codes |\n\n---\n\n## Anti-Patterns to Avoid\n\n### \u274C Don\'t create overly broad tasks\n\n```bash\n# \u274C Too broad - too many ACs\nknowns task create "Build entire auth system" \\\n --ac "Login" --ac "Logout" --ac "Register" \\\n --ac "Password reset" --ac "OAuth" --ac "2FA"\n\n# \u2705 Better - split into focused tasks\nknowns task create "Implement user login" --ac "User can login with email/password"\nknowns task create "Implement user registration" --ac "User can create account"\n```\n\n### \u274C Don\'t embed implementation steps in AC\n\n```bash\n# \u274C Implementation steps as AC\n--ac "Create auth.ts file"\n--ac "Add bcrypt dependency"\n--ac "Write handleLogin function"\n\n# \u2705 Outcome-focused AC\n--ac "User can login with valid credentials"\n--ac "Invalid credentials return 401 error"\n--ac "Successful login returns JWT token"\n```\n\n### \u274C Don\'t skip search\n\nAlways search for existing tasks first. You might find:\n- Duplicate task already exists\n- Related task with useful context\n- Completed task with reusable patterns\n\n---\n\n## Report Results\n\nAfter creating tasks, show the user:\n- Task ID\n- Title\n- Description summary\n- Acceptance criteria\n\nThis allows for feedback and corrections before work begins.\n';
|
|
43489
|
+
|
|
43490
|
+
// src/templates/guidelines/workflow-execution.md
|
|
43491
|
+
var workflow_execution_default = '# Task Execution Workflow\n\nGuide for implementing tasks effectively.\n\n---\n\n## Step 1: Take the Task\n\nThe **first things** you must do when taking a task:\n\n```bash\n# Set status to in-progress and assign to yourself\nknowns task edit <id> -s in-progress -a @me\n\n# Start time tracking (REQUIRED!)\nknowns time start <id>\n```\n\n---\n\n## Step 2: Research & Understand\n\nBefore planning, gather complete context:\n\n```bash\n# Read the task details\nknowns task <id> --plain\n\n# Follow ALL refs in the task\n# @.knowns/docs/xxx.md \u2192 knowns doc "xxx" --plain\n# @.knowns/tasks/task-YY \u2192 knowns task YY --plain\n\n# Search for related documentation\nknowns search "keyword" --type doc --plain\n\n# Check similar completed tasks for patterns\nknowns search "keyword" --type task --status done --plain\n```\n\n**Why?** Understanding existing patterns prevents reinventing the wheel.\n\n---\n\n## Step 3: Create Implementation Plan\n\nCapture your plan in the task **BEFORE writing any code**.\n\n```bash\nknowns task edit <id> --plan $\'1. Research existing patterns (see @doc/xxx)\n2. Design approach\n3. Implement core functionality\n4. Add tests\n5. Update documentation\'\n```\n\n### \u26A0\uFE0F CRITICAL: Wait for Approval\n\n**Share the plan with the user and WAIT for explicit approval before coding.**\n\nDo not begin implementation until:\n- User approves the plan, OR\n- User explicitly tells you to skip review\n\n---\n\n## Step 4: Implement\n\nWork through your plan step by step:\n\n### Document Progress\n\n```bash\n# After completing each significant piece of work\nknowns task edit <id> --append-notes "\u2713 Completed: research phase"\nknowns task edit <id> --append-notes "\u2713 Completed: core implementation"\n```\n\n### Check Acceptance Criteria\n\nOnly mark AC as done **AFTER** the work is actually complete:\n\n```bash\n# After completing work for AC #1\nknowns task edit <id> --check-ac 1\n\n# After completing work for AC #2\nknowns task edit <id> --check-ac 2\n```\n\n**\u26A0\uFE0F CRITICAL:** Never check AC before the work is done. ACs represent completed outcomes.\n\n---\n\n## Scope Management\n\n### When New Requirements Emerge\n\nIf you discover additional work needed during implementation:\n\n**Option 1: Add to current task (if small)**\n```bash\nknowns task edit <id> --ac "New requirement discovered"\nknowns task edit <id> --append-notes "\u26A0\uFE0F Scope updated: Added requirement for X"\n```\n\n**Option 2: Create follow-up task (if significant)**\n```bash\nknowns task create "Follow-up: Additional feature" -d "Discovered during task <id>"\nknowns task edit <id> --append-notes "\u{1F4DD} Created follow-up task for X"\n```\n\n**\u26A0\uFE0F CRITICAL:** Stop and ask the user which option to use. Don\'t silently expand scope.\n\n---\n\n## Plan Updates\n\nIf your approach changes during implementation, update the plan:\n\n```bash\nknowns task edit <id> --plan $\'1. [DONE] Research\n2. [DONE] Original approach\n3. [CHANGED] New approach due to X\n4. Remaining work\'\n```\n\nThe plan should remain the **single source of truth** for how the task was solved.\n\n---\n\n## Handling Subtasks\n\n### When Assigned "Parent and All Subtasks"\n\nProceed sequentially without asking permission between each subtask:\n\n1. Complete subtask 1\n2. Complete subtask 2\n3. Continue until all done\n\n### When Assigned Single Subtask\n\nPresent progress and request guidance before advancing to the next subtask.\n\n---\n\n## Key Principles\n\n1. **Plan before code** - Always capture approach before implementation\n2. **Document decisions** - Record why you chose certain approaches\n3. **Update on changes** - Keep plan current if approach shifts\n4. **Ask on scope** - Don\'t silently expand work\n5. **Check AC after work** - Only mark done when truly complete\n';
|
|
43492
|
+
|
|
43493
|
+
// src/templates/guidelines/common-mistakes.md
|
|
43494
|
+
var common_mistakes_default = '# Common Mistakes\n\nAnti-patterns and common errors to avoid.\n\n---\n\n## \u26A0\uFE0F CRITICAL: Flag Confusion\n\n### The -a Flag Means Different Things!\n\n| Command | `-a` Flag Means | NOT This! |\n|---------|-----------------|-----------|\n| `task create` | `--assignee` (assign user) | ~~acceptance criteria~~ |\n| `task edit` | `--assignee` (assign user) | ~~acceptance criteria~~ |\n| `doc edit` | `--append` (append content) | ~~assignee~~ |\n\n### \u274C WRONG: Using -a for Acceptance Criteria\n\n```bash\n# \u274C WRONG: -a is assignee, sets assignee to garbage text!\nknowns task edit 35 -a "- [ ] Criterion"\nknowns task edit 35 -a "User can login"\nknowns task create "Title" -a "Criterion text"\n```\n\n### \u2705 CORRECT: Using --ac for Acceptance Criteria\n\n```bash\n# \u2705 CORRECT: Use --ac for acceptance criteria\nknowns task edit 35 --ac "Criterion one"\nknowns task edit 35 --ac "Criterion two"\nknowns task create "Title" --ac "Criterion one" --ac "Criterion two"\n```\n\n---\n\n## Quick Reference: DO vs DON\'T\n\n### File Operations\n\n| \u274C DON\'T | \u2705 DO |\n|----------|-------|\n| Edit .md files directly | Use CLI commands |\n| Change `- [ ]` to `- [x]` in file | `--check-ac <index>` |\n| Add notes directly to file | `--notes` or `--append-notes` |\n| Edit frontmatter manually | Use CLI flags |\n\n### Task Operations\n\n| \u274C DON\'T | \u2705 DO |\n|----------|-------|\n| `-a "criterion"` (assignee!) | `--ac "criterion"` |\n| `--parent task-48` | `--parent 48` (raw ID) |\n| Skip time tracking | Always `time start`/`time stop` |\n| Check AC before work done | Check AC AFTER completing work |\n| Code before plan approval | Wait for user approval |\n| Code before reading docs | Read ALL related docs first |\n\n### Flag Usage\n\n| \u274C DON\'T | \u2705 DO |\n|----------|-------|\n| `--plain` with create | `--plain` only for view/list/search |\n| `--plain` with edit | `--plain` only for view/list/search |\n| `--criteria "text"` | `--ac "text"` |\n| `-ac "text"` | `--ac "text"` (two dashes!) |\n\n---\n\n## Detailed Mistakes\n\n### 1. Direct File Editing\n\n```markdown\n# \u274C DON\'T DO THIS:\n1. Open backlog/tasks/task-7.md in editor\n2. Change "- [ ]" to "- [x]" manually\n3. Add notes directly to the file\n4. Save the file\n\n# \u2705 DO THIS INSTEAD:\nknowns task edit 7 --check-ac 1\nknowns task edit 7 --notes "Implementation complete"\n```\n\n**Why?** Direct editing breaks:\n- Metadata synchronization\n- Git tracking\n- Task relationships\n\n### 2. Wrong Flag for Acceptance Criteria\n\n```bash\n# \u274C WRONG: All these set assignee, NOT acceptance criteria\nknowns task edit 35 -a "Criterion"\nknowns task create "Title" -a "AC text"\nknowns task edit 35 --assignee "Criterion" # Still wrong!\n\n# \u2705 CORRECT: Use --ac\nknowns task edit 35 --ac "Criterion"\nknowns task create "Title" --ac "AC text"\n```\n\n### 3. Wrong Task ID Format for Parent\n\n```bash\n# \u274C WRONG: Don\'t prefix with "task-"\nknowns task create "Title" --parent task-48\nknowns task edit 35 --parent task-48\n\n# \u2705 CORRECT: Use raw ID only\nknowns task create "Title" --parent 48\nknowns task edit 35 --parent qkh5ne\n```\n\n### 4. Using --plain with Create/Edit\n\n```bash\n# \u274C WRONG: create/edit don\'t support --plain\nknowns task create "Title" --plain # ERROR!\nknowns task edit 35 -s done --plain # ERROR!\nknowns doc create "Title" --plain # ERROR!\nknowns doc edit "name" -c "..." --plain # ERROR!\n\n# \u2705 CORRECT: --plain only for view/list/search\nknowns task 35 --plain # OK\nknowns task list --plain # OK\nknowns doc "readme" --plain # OK\nknowns search "query" --plain # OK\n```\n\n### 5. Skipping Time Tracking\n\n```bash\n# \u274C WRONG: No timer\nknowns task edit 35 -s in-progress\n# ... work ...\nknowns task edit 35 -s done\n\n# \u2705 CORRECT: Always track time\nknowns task edit 35 -s in-progress -a @me\nknowns time start 35\n# ... work ...\nknowns time stop\nknowns task edit 35 -s done\n```\n\n### 6. Checking AC Before Work is Done\n\n```bash\n# \u274C WRONG: Checking AC as a TODO list\nknowns task edit 35 --check-ac 1 # Haven\'t done the work yet!\n# ... then do the work ...\n\n# \u2705 CORRECT: Check AC AFTER completing work\n# ... do the work first ...\nknowns task edit 35 --check-ac 1 # Now it\'s actually done\n```\n\n### 7. Coding Before Plan Approval\n\n```bash\n# \u274C WRONG: Start coding immediately\nknowns task edit 35 -s in-progress\nknowns task edit 35 --plan "1. Do X\\n2. Do Y"\n# Immediately starts coding...\n\n# \u2705 CORRECT: Wait for approval\nknowns task edit 35 -s in-progress\nknowns task edit 35 --plan "1. Do X\\n2. Do Y"\n# STOP! Present plan to user\n# Wait for explicit approval\n# Then start coding\n```\n\n### 8. Ignoring Task References\n\n```bash\n# \u274C WRONG: Don\'t read refs\nknowns task 35 --plain\n# See "@.knowns/docs/api.md" but don\'t read it\n# Start implementing without context...\n\n# \u2705 CORRECT: Follow ALL refs\nknowns task 35 --plain\n# See "@.knowns/docs/api.md"\nknowns doc "api" --plain # Read it!\n# See "@.knowns/tasks/task-30"\nknowns task 30 --plain # Read it!\n# Now have full context\n```\n\n---\n\n## Error Recovery\n\n| Problem | Solution |\n|---------|----------|\n| Set assignee to AC text by mistake | `knowns task edit <id> -a @me` to fix |\n| Forgot to stop timer | `knowns time add <id> <duration> -n "Forgot to stop"` |\n| Checked AC too early | `knowns task edit <id> --uncheck-ac <index>` |\n| Task not found | `knowns task list --plain` to find correct ID |\n| AC index out of range | `knowns task <id> --plain` to see AC numbers |\n';
|
|
43495
|
+
|
|
43496
|
+
// src/templates/guidelines/index.ts
|
|
43497
|
+
var CORE_RULES = core_rules_default.trim();
|
|
43498
|
+
var COMMANDS_REFERENCE = commands_reference_default.trim();
|
|
43499
|
+
var WORKFLOW_CREATION = workflow_creation_default.trim();
|
|
43500
|
+
var WORKFLOW_EXECUTION = workflow_execution_default.trim();
|
|
43501
|
+
var WORKFLOW_COMPLETION = workflow_completion_default.trim();
|
|
43502
|
+
var COMMON_MISTAKES = common_mistakes_default.trim();
|
|
43503
|
+
var Guidelines = {
|
|
43504
|
+
// Core rules - always needed
|
|
43505
|
+
core: CORE_RULES,
|
|
43506
|
+
// Commands reference
|
|
43507
|
+
commands: COMMANDS_REFERENCE,
|
|
43508
|
+
// Workflow stages
|
|
43509
|
+
workflow: {
|
|
43510
|
+
creation: WORKFLOW_CREATION,
|
|
43511
|
+
execution: WORKFLOW_EXECUTION,
|
|
43512
|
+
completion: WORKFLOW_COMPLETION
|
|
43513
|
+
},
|
|
43514
|
+
// Common mistakes
|
|
43515
|
+
mistakes: COMMON_MISTAKES,
|
|
43516
|
+
/**
|
|
43517
|
+
* Get full guidelines (all sections combined)
|
|
43518
|
+
*/
|
|
43519
|
+
getFull(withMarkers2 = false) {
|
|
43520
|
+
const content = [
|
|
43521
|
+
CORE_RULES,
|
|
43522
|
+
"---",
|
|
43523
|
+
COMMANDS_REFERENCE,
|
|
43524
|
+
"---",
|
|
43525
|
+
WORKFLOW_CREATION,
|
|
43526
|
+
"---",
|
|
43527
|
+
WORKFLOW_EXECUTION,
|
|
43528
|
+
"---",
|
|
43529
|
+
WORKFLOW_COMPLETION,
|
|
43530
|
+
"---",
|
|
43531
|
+
COMMON_MISTAKES
|
|
43532
|
+
].join("\n\n");
|
|
43533
|
+
if (withMarkers2) {
|
|
43534
|
+
return `<!-- KNOWNS GUIDELINES START -->
|
|
43535
|
+
${content}
|
|
43536
|
+
<!-- KNOWNS GUIDELINES END -->`;
|
|
43537
|
+
}
|
|
43538
|
+
return content;
|
|
43539
|
+
},
|
|
43540
|
+
/**
|
|
43541
|
+
* Get compact guidelines (core + mistakes only)
|
|
43542
|
+
*/
|
|
43543
|
+
getCompact() {
|
|
43544
|
+
return [CORE_RULES, "---", COMMON_MISTAKES].join("\n\n");
|
|
43545
|
+
},
|
|
43546
|
+
/**
|
|
43547
|
+
* Get guidelines for specific workflow stage
|
|
43548
|
+
*/
|
|
43549
|
+
getForStage(stage) {
|
|
43550
|
+
const sections = [CORE_RULES, "---"];
|
|
43551
|
+
switch (stage) {
|
|
43552
|
+
case "creation":
|
|
43553
|
+
sections.push(WORKFLOW_CREATION);
|
|
43554
|
+
break;
|
|
43555
|
+
case "execution":
|
|
43556
|
+
sections.push(WORKFLOW_EXECUTION);
|
|
43557
|
+
sections.push("---", COMMANDS_REFERENCE);
|
|
43558
|
+
break;
|
|
43559
|
+
case "completion":
|
|
43560
|
+
sections.push(WORKFLOW_COMPLETION);
|
|
43561
|
+
break;
|
|
43562
|
+
}
|
|
43563
|
+
sections.push("---", COMMON_MISTAKES);
|
|
43564
|
+
return sections.join("\n\n");
|
|
43565
|
+
}
|
|
43566
|
+
};
|
|
43483
43567
|
|
|
43484
|
-
// src/templates/
|
|
43485
|
-
var
|
|
43568
|
+
// src/templates/instruction/cli.md
|
|
43569
|
+
var cli_default = '# Knowns Project\n\nThis project uses **Knowns CLI** for task and documentation management.\n\n## Before Starting\n\nRun this command to get usage guidelines:\n\n```bash\nknowns agents guideline\n```\n\nYou MUST call this at session start and follow every rule it outputs.\n\n## Context-Specific Guidelines\n\nGet guidelines for specific workflow stages:\n\n```bash\n# Full guidelines (all sections)\nknowns agents guideline --full\n\n# Compact (core rules + common mistakes)\nknowns agents guideline --compact\n\n# By workflow stage\nknowns agents guideline --stage creation # Creating tasks\nknowns agents guideline --stage execution # Implementing tasks\nknowns agents guideline --stage completion # Completing tasks\n\n# Individual sections\nknowns agents guideline --core # Core rules only\nknowns agents guideline --commands # Commands reference\nknowns agents guideline --mistakes # Common mistakes\n```\n\n## Quick Commands\n\n```bash\nknowns task list --plain # List tasks\nknowns task <id> --plain # View task\nknowns doc list --plain # List docs\nknowns doc "<path>" --plain # View doc\nknowns search "query" --plain # Search\n```\n\n**Important:** Always read the guidelines before working on tasks.\n';
|
|
43486
43570
|
|
|
43487
|
-
// src/templates/mcp
|
|
43488
|
-
var
|
|
43571
|
+
// src/templates/instruction/mcp.md
|
|
43572
|
+
var mcp_default = '# Knowns Project\n\nThis project uses **Knowns MCP** tools for task and documentation management.\n\n## Before Starting\n\nCall this MCP tool to get usage guidelines:\n\n```\nmcp__knowns__get_guideline({})\n```\n\nYou MUST call this at session start and follow every rule it returns.\n\n## Context-Specific Guidelines\n\nGet guidelines for specific contexts:\n\n```\n// Full guidelines\nmcp__knowns__get_guideline({ type: "unified" })\n\n// CLI-specific (fallback)\nmcp__knowns__get_guideline({ type: "cli" })\n\n// MCP-specific\nmcp__knowns__get_guideline({ type: "mcp" })\n```\n\n**CLI Fallback:** If MCP tools are unavailable, use CLI commands:\n\n```bash\nknowns agents guideline --full # All guidelines\nknowns agents guideline --stage creation # Task creation\nknowns agents guideline --stage execution # Task execution\nknowns agents guideline --stage completion # Task completion\n```\n\n## Quick Tools\n\n```\n// List tasks\nmcp__knowns__list_tasks({})\n\n// View task\nmcp__knowns__get_task({ taskId: "<id>" })\n\n// List docs\nmcp__knowns__list_docs({})\n\n// View doc\nmcp__knowns__get_doc({ path: "<path>" })\n\n// Search\nmcp__knowns__search_tasks({ query: "keyword" })\nmcp__knowns__search_docs({ query: "keyword" })\n```\n\n**Important:** Always read the guidelines before working on tasks.\n';
|
|
43489
43573
|
|
|
43490
|
-
// src/templates/
|
|
43491
|
-
var
|
|
43574
|
+
// src/templates/instruction/index.ts
|
|
43575
|
+
var START_MARKER = "<!-- KNOWNS GUIDELINES START -->";
|
|
43576
|
+
var END_MARKER = "<!-- KNOWNS GUIDELINES END -->";
|
|
43577
|
+
function withMarkers(template) {
|
|
43578
|
+
return `${START_MARKER}
|
|
43579
|
+
${template.trim()}
|
|
43580
|
+
${END_MARKER}`;
|
|
43581
|
+
}
|
|
43582
|
+
var CLI_TEMPLATE_RAW = cli_default.trim();
|
|
43583
|
+
var MCP_TEMPLATE_RAW = mcp_default.trim();
|
|
43584
|
+
var CLI_INSTRUCTION = withMarkers(cli_default);
|
|
43585
|
+
var MCP_INSTRUCTION = withMarkers(mcp_default);
|
|
43492
43586
|
|
|
43493
43587
|
// src/commands/agents.ts
|
|
43494
43588
|
var PROJECT_ROOT = process.cwd();
|
|
@@ -43499,10 +43593,10 @@ var INSTRUCTION_FILES = [
|
|
|
43499
43593
|
{ path: ".github/copilot-instructions.md", name: "GitHub Copilot", selected: false }
|
|
43500
43594
|
];
|
|
43501
43595
|
function getGuidelines(type, variant = "instruction") {
|
|
43502
|
-
if (
|
|
43503
|
-
return
|
|
43596
|
+
if (variant === "general") {
|
|
43597
|
+
return Guidelines.getFull(true);
|
|
43504
43598
|
}
|
|
43505
|
-
return
|
|
43599
|
+
return type === "mcp" ? MCP_INSTRUCTION : CLI_INSTRUCTION;
|
|
43506
43600
|
}
|
|
43507
43601
|
async function updateInstructionFile(filePath, guidelines) {
|
|
43508
43602
|
const fullPath = join3(PROJECT_ROOT, filePath);
|
|
@@ -43699,20 +43793,45 @@ Syncing agent instructions (${label})...
|
|
|
43699
43793
|
}
|
|
43700
43794
|
});
|
|
43701
43795
|
agentsCommand.addCommand(syncCommand);
|
|
43702
|
-
var guidelineCommand = new Command("guideline").description("Output guidelines for AI agents (use this at session start)").option("--cli", "Show CLI-specific guidelines").option("--mcp", "Show MCP-specific guidelines").
|
|
43703
|
-
|
|
43704
|
-
|
|
43705
|
-
|
|
43706
|
-
|
|
43707
|
-
|
|
43708
|
-
|
|
43709
|
-
|
|
43796
|
+
var guidelineCommand = new Command("guideline").description("Output guidelines for AI agents (use this at session start)").option("--cli", "Show CLI-specific guidelines (legacy)").option("--mcp", "Show MCP-specific guidelines (legacy)").option("--full", "Show full guidelines (all sections)").option("--compact", "Show compact guidelines (core + mistakes only)").option("--stage <stage>", "Show guidelines for specific stage: creation, execution, completion").option("--core", "Show core rules only").option("--commands", "Show commands reference only").option("--mistakes", "Show common mistakes only").action(
|
|
43797
|
+
async (options2) => {
|
|
43798
|
+
try {
|
|
43799
|
+
if (options2.cli || options2.mcp) {
|
|
43800
|
+
console.log(Guidelines.getFull());
|
|
43801
|
+
return;
|
|
43802
|
+
}
|
|
43803
|
+
if (options2.core) {
|
|
43804
|
+
console.log(Guidelines.core);
|
|
43805
|
+
return;
|
|
43806
|
+
}
|
|
43807
|
+
if (options2.commands) {
|
|
43808
|
+
console.log(Guidelines.commands);
|
|
43809
|
+
return;
|
|
43810
|
+
}
|
|
43811
|
+
if (options2.mistakes) {
|
|
43812
|
+
console.log(Guidelines.mistakes);
|
|
43813
|
+
return;
|
|
43814
|
+
}
|
|
43815
|
+
if (options2.compact) {
|
|
43816
|
+
console.log(Guidelines.getCompact());
|
|
43817
|
+
return;
|
|
43818
|
+
}
|
|
43819
|
+
if (options2.stage) {
|
|
43820
|
+
const stage = options2.stage;
|
|
43821
|
+
if (!["creation", "execution", "completion"].includes(stage)) {
|
|
43822
|
+
console.error("Error: Invalid stage. Use: creation, execution, or completion");
|
|
43823
|
+
process.exit(1);
|
|
43824
|
+
}
|
|
43825
|
+
console.log(Guidelines.getForStage(stage));
|
|
43826
|
+
return;
|
|
43827
|
+
}
|
|
43828
|
+
console.log(Guidelines.getFull());
|
|
43829
|
+
} catch (error48) {
|
|
43830
|
+
console.error("Error:", error48 instanceof Error ? error48.message : String(error48));
|
|
43831
|
+
process.exit(1);
|
|
43710
43832
|
}
|
|
43711
|
-
} catch (error48) {
|
|
43712
|
-
console.error("Error:", error48 instanceof Error ? error48.message : String(error48));
|
|
43713
|
-
process.exit(1);
|
|
43714
43833
|
}
|
|
43715
|
-
|
|
43834
|
+
);
|
|
43716
43835
|
agentsCommand.addCommand(guidelineCommand);
|
|
43717
43836
|
|
|
43718
43837
|
// src/commands/init.ts
|
|
@@ -43730,8 +43849,41 @@ function checkGitExists(projectRoot) {
|
|
|
43730
43849
|
process.exit(1);
|
|
43731
43850
|
}
|
|
43732
43851
|
}
|
|
43852
|
+
async function createMcpJsonFile(projectRoot) {
|
|
43853
|
+
const { writeFileSync: writeFileSync3, readFileSync: readFileSync4 } = await import("node:fs");
|
|
43854
|
+
const mcpJsonPath = join4(projectRoot, ".mcp.json");
|
|
43855
|
+
const mcpConfig = {
|
|
43856
|
+
mcpServers: {
|
|
43857
|
+
knowns: {
|
|
43858
|
+
command: "npx",
|
|
43859
|
+
args: ["-y", "knowns", "mcp"]
|
|
43860
|
+
}
|
|
43861
|
+
}
|
|
43862
|
+
};
|
|
43863
|
+
if (existsSync2(mcpJsonPath)) {
|
|
43864
|
+
try {
|
|
43865
|
+
const existing = JSON.parse(readFileSync4(mcpJsonPath, "utf-8"));
|
|
43866
|
+
if (existing?.mcpServers?.knowns) {
|
|
43867
|
+
console.log(source_default.gray(" .mcp.json already has knowns configuration"));
|
|
43868
|
+
return;
|
|
43869
|
+
}
|
|
43870
|
+
existing.mcpServers = {
|
|
43871
|
+
...existing.mcpServers,
|
|
43872
|
+
...mcpConfig.mcpServers
|
|
43873
|
+
};
|
|
43874
|
+
writeFileSync3(mcpJsonPath, JSON.stringify(existing, null, " "), "utf-8");
|
|
43875
|
+
console.log(source_default.green("\u2713 Added knowns to existing .mcp.json"));
|
|
43876
|
+
} catch {
|
|
43877
|
+
writeFileSync3(mcpJsonPath, JSON.stringify(mcpConfig, null, " "), "utf-8");
|
|
43878
|
+
console.log(source_default.green("\u2713 Created .mcp.json (replaced invalid file)"));
|
|
43879
|
+
}
|
|
43880
|
+
} else {
|
|
43881
|
+
writeFileSync3(mcpJsonPath, JSON.stringify(mcpConfig, null, " "), "utf-8");
|
|
43882
|
+
console.log(source_default.green("\u2713 Created .mcp.json for Claude Code MCP auto-discovery"));
|
|
43883
|
+
}
|
|
43884
|
+
}
|
|
43733
43885
|
async function updateGitignoreForIgnoredMode(projectRoot) {
|
|
43734
|
-
const { appendFileSync, readFileSync:
|
|
43886
|
+
const { appendFileSync, readFileSync: readFileSync4, writeFileSync: writeFileSync3 } = await import("node:fs");
|
|
43735
43887
|
const gitignorePath = join4(projectRoot, ".gitignore");
|
|
43736
43888
|
const knownsIgnorePattern = `
|
|
43737
43889
|
# knowns (ignore all except docs)
|
|
@@ -43740,7 +43892,7 @@ async function updateGitignoreForIgnoredMode(projectRoot) {
|
|
|
43740
43892
|
!.knowns/docs/**
|
|
43741
43893
|
`;
|
|
43742
43894
|
if (existsSync2(gitignorePath)) {
|
|
43743
|
-
const content =
|
|
43895
|
+
const content = readFileSync4(gitignorePath, "utf-8");
|
|
43744
43896
|
if (content.includes(".knowns/*")) {
|
|
43745
43897
|
console.log(source_default.gray(" .gitignore already has knowns pattern"));
|
|
43746
43898
|
return;
|
|
@@ -43748,7 +43900,7 @@ async function updateGitignoreForIgnoredMode(projectRoot) {
|
|
|
43748
43900
|
appendFileSync(gitignorePath, knownsIgnorePattern);
|
|
43749
43901
|
console.log(source_default.green("\u2713 Updated .gitignore with knowns pattern"));
|
|
43750
43902
|
} else {
|
|
43751
|
-
|
|
43903
|
+
writeFileSync3(gitignorePath, `${knownsIgnorePattern.trim()}
|
|
43752
43904
|
`, "utf-8");
|
|
43753
43905
|
console.log(source_default.green("\u2713 Created .gitignore with knowns pattern"));
|
|
43754
43906
|
}
|
|
@@ -43788,43 +43940,6 @@ async function runWizard() {
|
|
|
43788
43940
|
initial: 0
|
|
43789
43941
|
// git-tracked
|
|
43790
43942
|
},
|
|
43791
|
-
{
|
|
43792
|
-
type: "text",
|
|
43793
|
-
name: "defaultAssignee",
|
|
43794
|
-
message: "Default assignee (optional)",
|
|
43795
|
-
initial: "",
|
|
43796
|
-
format: (value) => value.trim() ? value.trim() : void 0
|
|
43797
|
-
},
|
|
43798
|
-
{
|
|
43799
|
-
type: "select",
|
|
43800
|
-
name: "defaultPriority",
|
|
43801
|
-
message: "Default priority for new tasks",
|
|
43802
|
-
choices: [
|
|
43803
|
-
{ title: "Low", value: "low" },
|
|
43804
|
-
{ title: "Medium", value: "medium" },
|
|
43805
|
-
{ title: "High", value: "high" }
|
|
43806
|
-
],
|
|
43807
|
-
initial: 1
|
|
43808
|
-
// medium
|
|
43809
|
-
},
|
|
43810
|
-
{
|
|
43811
|
-
type: "list",
|
|
43812
|
-
name: "defaultLabels",
|
|
43813
|
-
message: "Default labels (comma-separated, optional)",
|
|
43814
|
-
initial: "",
|
|
43815
|
-
separator: ","
|
|
43816
|
-
},
|
|
43817
|
-
{
|
|
43818
|
-
type: "select",
|
|
43819
|
-
name: "timeFormat",
|
|
43820
|
-
message: "Time format",
|
|
43821
|
-
choices: [
|
|
43822
|
-
{ title: "24-hour (14:30)", value: "24h" },
|
|
43823
|
-
{ title: "12-hour (2:30 PM)", value: "12h" }
|
|
43824
|
-
],
|
|
43825
|
-
initial: 0
|
|
43826
|
-
// 24h
|
|
43827
|
-
},
|
|
43828
43943
|
{
|
|
43829
43944
|
type: "select",
|
|
43830
43945
|
name: "guidelinesType",
|
|
@@ -43861,10 +43976,9 @@ async function runWizard() {
|
|
|
43861
43976
|
}
|
|
43862
43977
|
return {
|
|
43863
43978
|
name: response.name,
|
|
43864
|
-
|
|
43865
|
-
|
|
43866
|
-
|
|
43867
|
-
timeFormat: response.timeFormat,
|
|
43979
|
+
defaultPriority: "medium",
|
|
43980
|
+
defaultLabels: [],
|
|
43981
|
+
timeFormat: "24h",
|
|
43868
43982
|
gitTrackingMode: response.gitTrackingMode || "git-tracked",
|
|
43869
43983
|
guidelinesType: response.guidelinesType || "cli",
|
|
43870
43984
|
agentFiles: response.agentFiles || []
|
|
@@ -43907,57 +44021,35 @@ var initCommand = new Command("init").description("Initialize .knowns/ folder in
|
|
|
43907
44021
|
if (config2.gitTrackingMode === "git-ignored") {
|
|
43908
44022
|
await updateGitignoreForIgnoredMode(projectRoot);
|
|
43909
44023
|
}
|
|
44024
|
+
if (config2.guidelinesType === "mcp") {
|
|
44025
|
+
await createMcpJsonFile(projectRoot);
|
|
44026
|
+
}
|
|
43910
44027
|
const fileStore2 = new FileStore(projectRoot);
|
|
43911
44028
|
const project = await fileStore2.initProject(config2.name, {
|
|
43912
|
-
defaultAssignee: config2.defaultAssignee,
|
|
43913
44029
|
defaultPriority: config2.defaultPriority,
|
|
43914
44030
|
defaultLabels: config2.defaultLabels,
|
|
43915
44031
|
timeFormat: config2.timeFormat,
|
|
43916
44032
|
gitTrackingMode: config2.gitTrackingMode
|
|
43917
44033
|
});
|
|
43918
44034
|
console.log();
|
|
43919
|
-
console.log(source_default.green(
|
|
43920
|
-
console.log(source_default.gray(` Name: ${project.name}`));
|
|
43921
|
-
console.log(source_default.gray(` Location: ${knownsPath}`));
|
|
43922
|
-
console.log(
|
|
43923
|
-
source_default.gray(` Git Mode: ${config2.gitTrackingMode === "git-tracked" ? "Tracked (team)" : "Ignored (personal)"}`)
|
|
43924
|
-
);
|
|
43925
|
-
if (config2.defaultAssignee) {
|
|
43926
|
-
console.log(source_default.gray(` Default Assignee: ${config2.defaultAssignee}`));
|
|
43927
|
-
}
|
|
43928
|
-
console.log(source_default.gray(` Default Priority: ${config2.defaultPriority}`));
|
|
43929
|
-
if (config2.defaultLabels.length > 0) {
|
|
43930
|
-
console.log(source_default.gray(` Default Labels: ${config2.defaultLabels.join(", ")}`));
|
|
43931
|
-
}
|
|
43932
|
-
console.log(source_default.gray(` Time Format: ${config2.timeFormat}`));
|
|
43933
|
-
console.log();
|
|
44035
|
+
console.log(source_default.green(`\u2713 Project initialized: ${project.name}`));
|
|
43934
44036
|
if (config2.agentFiles.length > 0) {
|
|
43935
44037
|
const guidelines = getGuidelines(config2.guidelinesType);
|
|
43936
|
-
console.log(source_default.bold(`Updating AI instruction files (${config2.guidelinesType.toUpperCase()} version)...`));
|
|
43937
|
-
console.log();
|
|
43938
|
-
let syncedCount = 0;
|
|
43939
44038
|
for (const file3 of config2.agentFiles) {
|
|
43940
44039
|
try {
|
|
43941
44040
|
const result = await updateInstructionFile(file3.path, guidelines);
|
|
43942
44041
|
if (result.success) {
|
|
43943
|
-
syncedCount++;
|
|
43944
44042
|
const action = result.action === "created" ? "Created" : result.action === "appended" ? "Appended" : "Updated";
|
|
43945
|
-
console.log(source_default.green(`\u2713 ${action}
|
|
44043
|
+
console.log(source_default.green(`\u2713 ${action}: ${file3.path}`));
|
|
43946
44044
|
}
|
|
43947
|
-
} catch
|
|
43948
|
-
console.log(source_default.yellow(`\u26A0\uFE0F Skipped
|
|
44045
|
+
} catch {
|
|
44046
|
+
console.log(source_default.yellow(`\u26A0\uFE0F Skipped: ${file3.path}`));
|
|
43949
44047
|
}
|
|
43950
44048
|
}
|
|
43951
|
-
console.log();
|
|
43952
|
-
console.log(source_default.green(`\u2713 Synced guidelines to ${syncedCount} AI instruction file(s)`));
|
|
43953
|
-
} else {
|
|
43954
|
-
console.log(source_default.gray("Skipped AI instruction files (none selected)"));
|
|
43955
44049
|
}
|
|
43956
44050
|
console.log();
|
|
43957
|
-
console.log(source_default.cyan("
|
|
43958
|
-
console.log(source_default.gray('
|
|
43959
|
-
console.log(source_default.gray(" 2. List tasks: knowns task list"));
|
|
43960
|
-
console.log(source_default.gray(" 3. Open web UI: knowns browser"));
|
|
44051
|
+
console.log(source_default.cyan("Get started:"));
|
|
44052
|
+
console.log(source_default.gray(' knowns task create "My first task"'));
|
|
43961
44053
|
} catch (error48) {
|
|
43962
44054
|
console.error(source_default.red("\u2717 Failed to initialize project"));
|
|
43963
44055
|
if (error48 instanceof Error) {
|
|
@@ -62412,6 +62504,10 @@ var resetCommand = new Command("reset").description("Reset configuration to defa
|
|
|
62412
62504
|
});
|
|
62413
62505
|
var configCommand = new Command("config").description("Manage configuration settings").addCommand(listCommand3).addCommand(getCommand).addCommand(setCommand).addCommand(resetCommand);
|
|
62414
62506
|
|
|
62507
|
+
// src/commands/mcp.ts
|
|
62508
|
+
import { existsSync as existsSync18, readFileSync as readFileSync2, writeFileSync } from "node:fs";
|
|
62509
|
+
import { join as join22 } from "node:path";
|
|
62510
|
+
|
|
62415
62511
|
// src/mcp/server.ts
|
|
62416
62512
|
import { existsSync as existsSync17 } from "node:fs";
|
|
62417
62513
|
import { readFile as readFile15 } from "node:fs/promises";
|
|
@@ -70436,9 +70532,6 @@ async function handleSearchDocs(args2) {
|
|
|
70436
70532
|
var getGuidelineSchema = external_exports.object({
|
|
70437
70533
|
type: external_exports.enum(["unified", "cli", "mcp"]).optional().default("unified")
|
|
70438
70534
|
});
|
|
70439
|
-
function stripMarkers(content) {
|
|
70440
|
-
return content.replace(/<!-- KNOWNS GUIDELINES START -->\n?/g, "").replace(/<!-- KNOWNS GUIDELINES END -->\n?/g, "").trim();
|
|
70441
|
-
}
|
|
70442
70535
|
var guidelineTools = [
|
|
70443
70536
|
{
|
|
70444
70537
|
name: "get_guideline",
|
|
@@ -70457,17 +70550,7 @@ var guidelineTools = [
|
|
|
70457
70550
|
];
|
|
70458
70551
|
async function handleGetGuideline(args2) {
|
|
70459
70552
|
const input = getGuidelineSchema.parse(args2 || {});
|
|
70460
|
-
|
|
70461
|
-
switch (input.type) {
|
|
70462
|
-
case "cli":
|
|
70463
|
-
guidelines = stripMarkers(general_default);
|
|
70464
|
-
break;
|
|
70465
|
-
case "mcp":
|
|
70466
|
-
guidelines = stripMarkers(general_default2);
|
|
70467
|
-
break;
|
|
70468
|
-
default:
|
|
70469
|
-
guidelines = unified_default;
|
|
70470
|
-
}
|
|
70553
|
+
const guidelines = Guidelines.getFull();
|
|
70471
70554
|
return {
|
|
70472
70555
|
content: [
|
|
70473
70556
|
{
|
|
@@ -70655,6 +70738,89 @@ if (isStandaloneServer) {
|
|
|
70655
70738
|
}
|
|
70656
70739
|
|
|
70657
70740
|
// src/commands/mcp.ts
|
|
70741
|
+
function getMcpConfig() {
|
|
70742
|
+
return {
|
|
70743
|
+
command: "npx",
|
|
70744
|
+
args: ["-y", "knowns", "mcp"]
|
|
70745
|
+
};
|
|
70746
|
+
}
|
|
70747
|
+
async function setupClaudeCode() {
|
|
70748
|
+
const { spawnSync } = await import("node:child_process");
|
|
70749
|
+
const claudeCheck = spawnSync("claude", ["--version"], { stdio: "pipe" });
|
|
70750
|
+
if (claudeCheck.status !== 0) {
|
|
70751
|
+
console.log(source_default.yellow("\u26A0\uFE0F Claude Code CLI not found"));
|
|
70752
|
+
console.log(source_default.gray(" Install Claude Code first: https://claude.ai/code"));
|
|
70753
|
+
console.log(source_default.gray(" After installing, run: knowns mcp setup"));
|
|
70754
|
+
return false;
|
|
70755
|
+
}
|
|
70756
|
+
const config2 = getMcpConfig();
|
|
70757
|
+
const configJson = JSON.stringify(config2);
|
|
70758
|
+
const result = spawnSync("claude", ["mcp", "add-json", "knowns", configJson], {
|
|
70759
|
+
stdio: "inherit"
|
|
70760
|
+
});
|
|
70761
|
+
if (result.status === 0) {
|
|
70762
|
+
console.log(source_default.green("\u2713 Added knowns MCP server to Claude Code"));
|
|
70763
|
+
console.log(source_default.gray(" Restart Claude Code to activate the server"));
|
|
70764
|
+
return true;
|
|
70765
|
+
}
|
|
70766
|
+
const altResult = spawnSync("claude", ["mcp", "add", "knowns", "--", "npx", "-y", "knowns", "mcp"], {
|
|
70767
|
+
stdio: "inherit"
|
|
70768
|
+
});
|
|
70769
|
+
if (altResult.status === 0) {
|
|
70770
|
+
console.log(source_default.green("\u2713 Added knowns MCP server to Claude Code"));
|
|
70771
|
+
console.log(source_default.gray(" Restart Claude Code to activate the server"));
|
|
70772
|
+
return true;
|
|
70773
|
+
}
|
|
70774
|
+
console.log(source_default.red("\u2717 Failed to add MCP server to Claude Code"));
|
|
70775
|
+
console.log(source_default.gray(" Try adding manually with:"));
|
|
70776
|
+
console.log(source_default.cyan(` claude mcp add-json knowns '${configJson}'`));
|
|
70777
|
+
return false;
|
|
70778
|
+
}
|
|
70779
|
+
function createProjectMcpJson(projectRoot) {
|
|
70780
|
+
const mcpJsonPath = join22(projectRoot, ".mcp.json");
|
|
70781
|
+
const mcpConfig = {
|
|
70782
|
+
mcpServers: {
|
|
70783
|
+
knowns: getMcpConfig()
|
|
70784
|
+
}
|
|
70785
|
+
};
|
|
70786
|
+
if (existsSync18(mcpJsonPath)) {
|
|
70787
|
+
try {
|
|
70788
|
+
const existing = JSON.parse(readFileSync2(mcpJsonPath, "utf-8"));
|
|
70789
|
+
if (existing?.mcpServers?.knowns) {
|
|
70790
|
+
console.log(source_default.gray(" .mcp.json already has knowns configuration"));
|
|
70791
|
+
return true;
|
|
70792
|
+
}
|
|
70793
|
+
existing.mcpServers = {
|
|
70794
|
+
...existing.mcpServers,
|
|
70795
|
+
...mcpConfig.mcpServers
|
|
70796
|
+
};
|
|
70797
|
+
writeFileSync(mcpJsonPath, JSON.stringify(existing, null, " "), "utf-8");
|
|
70798
|
+
console.log(source_default.green("\u2713 Added knowns to existing .mcp.json"));
|
|
70799
|
+
} catch {
|
|
70800
|
+
writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, " "), "utf-8");
|
|
70801
|
+
console.log(source_default.green("\u2713 Created .mcp.json (replaced invalid file)"));
|
|
70802
|
+
}
|
|
70803
|
+
} else {
|
|
70804
|
+
writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, " "), "utf-8");
|
|
70805
|
+
console.log(source_default.green("\u2713 Created .mcp.json for Claude Code project-level auto-discovery"));
|
|
70806
|
+
}
|
|
70807
|
+
return true;
|
|
70808
|
+
}
|
|
70809
|
+
var setupCommand = new Command("setup").description("Setup knowns MCP server in Claude Code").option("--project", "Only create .mcp.json in project (skip Claude Code setup)").option("--global", "Only setup in Claude Code globally (skip .mcp.json)").action(async (options2) => {
|
|
70810
|
+
const projectRoot = findProjectRoot();
|
|
70811
|
+
const doProject = options2.project || !options2.project && !options2.global;
|
|
70812
|
+
const doGlobal = options2.global || !options2.project && !options2.global;
|
|
70813
|
+
if (doProject) {
|
|
70814
|
+
if (projectRoot) {
|
|
70815
|
+
createProjectMcpJson(projectRoot);
|
|
70816
|
+
} else {
|
|
70817
|
+
console.log(source_default.yellow("\u26A0\uFE0F Not in a Knowns project. Run 'knowns init' first."));
|
|
70818
|
+
}
|
|
70819
|
+
}
|
|
70820
|
+
if (doGlobal) {
|
|
70821
|
+
await setupClaudeCode();
|
|
70822
|
+
}
|
|
70823
|
+
});
|
|
70658
70824
|
var mcpCommand = new Command("mcp").description("Start MCP server for AI agent integration (Claude Desktop, etc.)").option("-v, --verbose", "Enable verbose logging").option("--info", "Show configuration instructions").action(async (options2) => {
|
|
70659
70825
|
if (options2.info) {
|
|
70660
70826
|
showConfigInfo();
|
|
@@ -70673,7 +70839,7 @@ var mcpCommand = new Command("mcp").description("Start MCP server for AI agent i
|
|
|
70673
70839
|
console.error(source_default.red("Error:"), error48 instanceof Error ? error48.message : error48);
|
|
70674
70840
|
process.exit(1);
|
|
70675
70841
|
}
|
|
70676
|
-
});
|
|
70842
|
+
}).addCommand(setupCommand);
|
|
70677
70843
|
function showConfigInfo() {
|
|
70678
70844
|
const configExample = {
|
|
70679
70845
|
mcpServers: {
|
|
@@ -70717,10 +70883,10 @@ function showConfigInfo() {
|
|
|
70717
70883
|
}
|
|
70718
70884
|
|
|
70719
70885
|
// src/utils/update-notifier.ts
|
|
70720
|
-
import { existsSync as
|
|
70886
|
+
import { existsSync as existsSync19, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
70721
70887
|
import { mkdir as mkdir10 } from "node:fs/promises";
|
|
70722
70888
|
import { homedir } from "node:os";
|
|
70723
|
-
import { dirname as dirname4, join as
|
|
70889
|
+
import { dirname as dirname4, join as join23 } from "node:path";
|
|
70724
70890
|
var DEFAULT_TTL_MS = 60 * 60 * 1e3;
|
|
70725
70891
|
var DEFAULT_TIMEOUT_MS = 2e3;
|
|
70726
70892
|
function detectPackageManager(cwd) {
|
|
@@ -70733,10 +70899,10 @@ function detectPackageManager(cwd) {
|
|
|
70733
70899
|
if (ua.startsWith("yarn/")) return "yarn";
|
|
70734
70900
|
if (ua.startsWith("bun/")) return "bun";
|
|
70735
70901
|
if (ua.startsWith("npm/")) return "npm";
|
|
70736
|
-
if (
|
|
70737
|
-
if (
|
|
70738
|
-
if (
|
|
70739
|
-
if (
|
|
70902
|
+
if (existsSync19(join23(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
70903
|
+
if (existsSync19(join23(cwd, "yarn.lock"))) return "yarn";
|
|
70904
|
+
if (existsSync19(join23(cwd, "bun.lock"))) return "bun";
|
|
70905
|
+
if (existsSync19(join23(cwd, "package-lock.json"))) return "npm";
|
|
70740
70906
|
return "npm";
|
|
70741
70907
|
}
|
|
70742
70908
|
function compareVersions(a, b) {
|
|
@@ -70760,11 +70926,11 @@ function shouldSkip(args2, force) {
|
|
|
70760
70926
|
}
|
|
70761
70927
|
function getGlobalCachePath(explicit) {
|
|
70762
70928
|
if (explicit) return explicit;
|
|
70763
|
-
return
|
|
70929
|
+
return join23(homedir(), ".knowns", "cli-cache.json");
|
|
70764
70930
|
}
|
|
70765
70931
|
function readCache(cachePath) {
|
|
70766
70932
|
try {
|
|
70767
|
-
const raw =
|
|
70933
|
+
const raw = readFileSync3(cachePath, "utf-8");
|
|
70768
70934
|
const data = JSON.parse(raw);
|
|
70769
70935
|
if (typeof data.lastChecked === "number" && typeof data.latestVersion === "string") {
|
|
70770
70936
|
return data;
|
|
@@ -70776,10 +70942,10 @@ function readCache(cachePath) {
|
|
|
70776
70942
|
}
|
|
70777
70943
|
async function writeCache(cachePath, data) {
|
|
70778
70944
|
const dir = dirname4(cachePath);
|
|
70779
|
-
if (dir && !
|
|
70945
|
+
if (dir && !existsSync19(dir)) {
|
|
70780
70946
|
await mkdir10(dir, { recursive: true });
|
|
70781
70947
|
}
|
|
70782
|
-
|
|
70948
|
+
writeFileSync2(cachePath, JSON.stringify(data, null, 2), "utf-8");
|
|
70783
70949
|
}
|
|
70784
70950
|
async function fetchLatestVersion(packageName) {
|
|
70785
70951
|
try {
|
|
@@ -70842,8 +71008,8 @@ async function notifyCliUpdate(options2) {
|
|
|
70842
71008
|
// package.json
|
|
70843
71009
|
var package_default = {
|
|
70844
71010
|
name: "knowns",
|
|
70845
|
-
version: "0.8.
|
|
70846
|
-
description: "
|
|
71011
|
+
version: "0.8.4",
|
|
71012
|
+
description: "AI-native task and documentation management for dev teams",
|
|
70847
71013
|
module: "index.ts",
|
|
70848
71014
|
type: "module",
|
|
70849
71015
|
bin: {
|
|
@@ -70874,7 +71040,7 @@ var package_default = {
|
|
|
70874
71040
|
type: "git",
|
|
70875
71041
|
url: "https://github.com/knowns-dev/knowns.git"
|
|
70876
71042
|
},
|
|
70877
|
-
homepage: "https://knowns.dev",
|
|
71043
|
+
homepage: "https://cli.knowns.dev",
|
|
70878
71044
|
bugs: {
|
|
70879
71045
|
url: "https://github.com/knowns-dev/knowns/issues"
|
|
70880
71046
|
},
|