internaltool-mcp 1.5.1 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +71 -27
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -473,7 +473,7 @@ Use this when a developer says "start task", "brief me on", or "what do I need t
473
473
  .replace(/[^a-z0-9]+/g, '-')
474
474
  .slice(0, 40)}`
475
475
 
476
- const hasReadme = !!(task.readmeMarkdown && task.readmeMarkdown.trim().length > 0)
476
+ const hasReadme = typeof task.readmeMarkdown === 'string' && task.readmeMarkdown.trim().length > 0
477
477
  const subtasks = (task.subtasks || []).map(s => ({
478
478
  title: s.title,
479
479
  done: s.done,
@@ -541,7 +541,12 @@ Use this when a developer says "start task", "brief me on", or "what do I need t
541
541
  })),
542
542
  movedToInProgress: moved,
543
543
  suggestedBranch,
544
- nextStep: `Use create_branch to create "${suggestedBranch}" on GitHub, then run:\n git fetch origin\n git checkout ${suggestedBranch}`,
544
+ preflightBeforeBranch: {
545
+ message: 'Before creating the branch, check your local git state first.',
546
+ commands: ['git status', 'git stash list'],
547
+ instruction: 'If you have uncommitted changes, stash or commit them before switching branches. Then call create_branch with your localState.',
548
+ },
549
+ nextStep: `Use create_branch to create "${suggestedBranch}" on GitHub — it will ask for your local git state first.`,
545
550
  })
546
551
  }
547
552
  )
@@ -797,10 +802,9 @@ Use this at the start of a session or when switching tasks.`,
797
802
  const res = await api.get('/api/users/me/tasks')
798
803
  if (!res?.success) return errorText('Could not fetch tasks')
799
804
 
800
- const PRIORITY_ORDER = { critical: 0, high: 1, medium: 2, low: 3 }
805
+ // Server already sorts by priority (critical low) then updatedAt just filter and annotate
801
806
  const tasks = (res.data.tasks || [])
802
807
  .filter(t => includeColumns.includes(t.column))
803
- .sort((a, b) => (PRIORITY_ORDER[a.priority] ?? 99) - (PRIORITY_ORDER[b.priority] ?? 99))
804
808
  .map(t => {
805
809
  let suggestedAction = null
806
810
  if (t.column === 'todo') {
@@ -848,7 +852,7 @@ Use this when returning to a task after a break, or when Claude needs the full p
848
852
 
849
853
  let coachingPrompt = null
850
854
  if (task.column === 'in_progress' && !task.github?.headBranch) {
851
- coachingPrompt = 'No branch created yet. Use create_branch before writing code.'
855
+ coachingPrompt = 'No branch yet. Before create_branch: run "git status" in your terminal first — stash or commit any local changes, then call create_branch with your localState.'
852
856
  } else if (task.column === 'in_progress' && task.github?.headBranch) {
853
857
  coachingPrompt = `Branch: ${task.github.headBranch}. When commits are pushed, use raise_pr to open a PR.`
854
858
  } else if (task.column === 'in_review') {
@@ -886,19 +890,28 @@ Use this when returning to a task after a break, or when Claude needs the full p
886
890
  fix/TASK-XXX-short-description (for bug fixes / patches)
887
891
 
888
892
  WHEN TO USE: Immediately after a task moves to in_progress.
889
- Claude will suggest this automatically after kickoff_task.
890
893
 
891
- Set confirmed=false first to preview the branch name, then confirmed=true to create it.
892
- After creation, run locally:
893
- git fetch origin
894
- git checkout <branchName>`,
894
+ THREE-STEP FLOW do not skip steps:
895
+ 1. confirmed=false → preview branch name + get pre-flight git commands to run locally
896
+ 2. Run the pre-flight commands → check local state, stash if needed, report back with localState
897
+ 3. confirmed=true + localState → branch is created on GitHub
898
+
899
+ localState must be one of:
900
+ "clean" — git status shows nothing to commit, working tree clean
901
+ "stashed" — had changes, ran git stash, now clean
902
+ "committed" — had changes, did a WIP commit, now clean
903
+
904
+ Never skip the localState check — switching branches with uncommitted changes
905
+ can cause conflicts or silently carry changes onto the new branch.`,
895
906
  {
896
- taskId: z.string().describe("Task's MongoDB ObjectId"),
897
- projectId: z.string().describe("Project's MongoDB ObjectId"),
898
- fromRef: z.string().optional().describe("Base ref to branch from (default: project's default branch)"),
899
- confirmed: z.boolean().optional().default(false).describe('Set true to create the branch after reviewing the preview'),
907
+ taskId: z.string().describe("Task's MongoDB ObjectId"),
908
+ projectId: z.string().describe("Project's MongoDB ObjectId"),
909
+ fromRef: z.string().optional().describe("Base ref to branch from (default: project's default branch)"),
910
+ confirmed: z.boolean().optional().default(false).describe('Set true only after running pre-flight commands and setting localState'),
911
+ localState: z.enum(['clean', 'stashed', 'committed']).optional()
912
+ .describe('Your local git state AFTER running git status. Required when confirmed=true.'),
900
913
  },
901
- async ({ taskId, projectId, fromRef, confirmed = false }) => {
914
+ async ({ taskId, projectId, fromRef, confirmed = false, localState }) => {
902
915
  if (scopedProjectId && projectId !== scopedProjectId) {
903
916
  return errorText(`Access denied: session is scoped to project ${scopedProjectId}`)
904
917
  }
@@ -916,33 +929,64 @@ After creation, run locally:
916
929
  .slice(0, 35)
917
930
  const branchName = `${prefix}/${task.key.toLowerCase()}-${slug}`
918
931
 
919
- // Preview
932
+ // Step 1 — preview + pre-flight commands
920
933
  if (!confirmed) {
921
934
  return text({
922
935
  preview: {
923
936
  action: 'create_branch',
924
937
  branchName,
925
- fromRef: fromRef || '(project default branch)',
926
- repo: '(resolved from project)',
938
+ basedOn: fromRef || '(project default branch)',
927
939
  task: { key: task.key, title: task.title },
928
940
  },
929
- requiresConfirmation: true,
930
- message: `Will create branch "${branchName}" on GitHub. Call create_branch again with confirmed=true to proceed.`,
941
+ preflightRequired: true,
942
+ preflightCommands: [
943
+ 'git status',
944
+ 'git stash list',
945
+ 'git diff --stat',
946
+ ],
947
+ preflightInstructions: [
948
+ 'Run the three commands above in your terminal right now.',
949
+ 'If "git status" shows modified/untracked files: run "git stash push -m \\"wip: switching to ' + branchName + '\\"" then set localState="stashed"',
950
+ 'If working tree is already clean: set localState="clean"',
951
+ 'If you prefer a WIP commit: run "git add . && git commit -m \\"chore: wip\\"" then set localState="committed"',
952
+ ],
953
+ message: `Check your local git state first. Run the pre-flight commands above, handle any uncommitted changes, then call create_branch again with confirmed=true and localState=<clean|stashed|committed>.`,
931
954
  })
932
955
  }
933
956
 
957
+ // Step 2 — localState gate: block if developer skipped the check
958
+ if (!localState) {
959
+ return text({
960
+ blocked: true,
961
+ reason: 'localState is required when confirmed=true.',
962
+ message: 'You must run "git status" first and tell me your local state. Set localState to "clean", "stashed", or "committed" depending on what you found.',
963
+ preflightCommands: ['git status', 'git stash list'],
964
+ })
965
+ }
966
+
967
+ // Step 3 — create branch on GitHub
934
968
  try {
935
969
  const res = await api.post(`/api/projects/${projectId}/github/branches`, { branchName, fromRef })
936
970
  if (!res?.success) return errorText(res?.message || 'Could not create branch')
971
+
972
+ const checkoutSteps = [
973
+ 'git fetch origin',
974
+ `git checkout ${branchName}`,
975
+ ]
976
+
977
+ // If stashed, remind to check stash still makes sense on the new branch
978
+ const stashReminder = localState === 'stashed'
979
+ ? 'You stashed changes before switching. After checkout, decide: does your stash belong on this branch? If yes: git stash pop. If it belongs to a different branch, leave it and pop it there.'
980
+ : null
981
+
937
982
  return text({
938
983
  branchName,
939
- url: res.data.url,
940
- message: 'Branch created on GitHub.',
941
- gitSteps: [
942
- 'git fetch origin',
943
- `git checkout ${branchName}`,
944
- ],
945
- nextStep: 'Start coding! When your commits are ready to review, use raise_pr to open a pull request.',
984
+ url: res.data.url,
985
+ localState,
986
+ message: `Branch "${branchName}" created on GitHub.`,
987
+ gitSteps: checkoutSteps,
988
+ stashReminder,
989
+ nextStep: 'Run the git steps above to switch locally, then start coding. When commits are pushed, use raise_pr.',
946
990
  })
947
991
  } catch (e) {
948
992
  return errorText(e.message)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "internaltool-mcp",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "MCP server for InternalTool — connect AI assistants (Claude Code, Cursor) to your project and task management platform",
5
5
  "type": "module",
6
6
  "main": "index.js",