@pal-code/workflow 0.0.19 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/package.json +2 -2
- package/src/gitignore.ts +56 -0
- package/src/index.ts +12 -0
package/README.md
CHANGED
|
@@ -177,6 +177,18 @@ That file is shared by every repo on the machine, so the pattern never travels.
|
|
|
177
177
|
`ripgrep` and `biome` inherit it through git, so nothing greps or lints your
|
|
178
178
|
scratch either.
|
|
179
179
|
|
|
180
|
+
On startup the extension runs `git check-ignore` on the directory and prints a
|
|
181
|
+
one-line advisory naming the command above when it is **not** ignored. Nothing
|
|
182
|
+
is rewritten for you — a global exclude affects every repo on the machine, so
|
|
183
|
+
that stays a deliberate act. Check it yourself with:
|
|
184
|
+
|
|
185
|
+
```sh
|
|
186
|
+
git check-ignore -v .work # empty output = not ignored
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
A global exclude never affects files git already tracks; if `.work` was
|
|
190
|
+
committed before, untrack it with `git rm -r --cached .work`.
|
|
191
|
+
|
|
180
192
|
One consequence worth knowing: pal's `grep_search` passes `--hidden` but not
|
|
181
193
|
`--no-ignore`, so it will **not** find `.work` content by searching. Address it
|
|
182
194
|
by path (`work_status`, or `read .work/TODO.md`) instead.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pal-code/workflow",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"description": "Task continuity for pal — work folders with handoff READMEs, a durable backlog, and session-length guardrails",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"!src/**/*.test.ts"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@pal-code/core": "0.0.
|
|
18
|
+
"@pal-code/core": "0.0.20"
|
|
19
19
|
},
|
|
20
20
|
"engines": {
|
|
21
21
|
"bun": ">=1.1.0"
|
package/src/gitignore.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Is a scratch directory ignored by git, machine-wide?
|
|
3
|
+
*
|
|
4
|
+
* Both `@pal-code/memory` and `@pal-code/workflow` write into a directory that
|
|
5
|
+
* must never be committed, and both READMEs tell the user to add it to
|
|
6
|
+
* `~/.config/git/ignore` — but nothing ever checked that they did. The failure
|
|
7
|
+
* is silent and ugly: the files show up in `git status` and can be committed by
|
|
8
|
+
* accident.
|
|
9
|
+
*
|
|
10
|
+
* Detection only. Rewriting someone's global git config from inside an editor
|
|
11
|
+
* would affect every repo on the machine, so the extension reports the exact
|
|
12
|
+
* command instead and lets the user decide.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import {execFileSync} from 'node:child_process';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Run `git check-ignore -q <dir>` and report whether it is ignored.
|
|
19
|
+
*
|
|
20
|
+
* Returns `undefined` when the answer is unknowable — not a git repo, git not
|
|
21
|
+
* installed, or the directory does not exist yet. Callers must treat
|
|
22
|
+
* `undefined` as "say nothing" rather than as "not ignored", so a non-git
|
|
23
|
+
* project never produces a spurious advisory.
|
|
24
|
+
*/
|
|
25
|
+
export function isDirGitIgnored(dir: string, cwd: string = process.cwd()): boolean | undefined {
|
|
26
|
+
try {
|
|
27
|
+
execFileSync('git', ['check-ignore', '-q', dir], {
|
|
28
|
+
cwd,
|
|
29
|
+
stdio: 'ignore',
|
|
30
|
+
timeout: 2000,
|
|
31
|
+
});
|
|
32
|
+
// exit 0 → the path IS ignored
|
|
33
|
+
return true;
|
|
34
|
+
} catch (err) {
|
|
35
|
+
// exit 1 → not ignored; anything else (no git, no repo) → unknown.
|
|
36
|
+
const code = (err as {status?: number}).status;
|
|
37
|
+
if (code === 1) return false;
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The one-line advisory for an unignored scratch directory, or undefined when
|
|
44
|
+
* there is nothing to say.
|
|
45
|
+
*
|
|
46
|
+
* @param dir Directory as the user sees it, e.g. `.work`.
|
|
47
|
+
* @param cwd Project root the check runs in.
|
|
48
|
+
*/
|
|
49
|
+
export function unignoredDirNotice(dir: string, cwd: string = process.cwd()): string | undefined {
|
|
50
|
+
const ignored = isDirGitIgnored(dir, cwd);
|
|
51
|
+
if (ignored !== false) return undefined;
|
|
52
|
+
return (
|
|
53
|
+
`${dir} is not ignored by git — it will show up in git status and can be committed by accident. ` +
|
|
54
|
+
`Hide it machine-wide: printf '${dir}/\\n' >> ~/.config/git/ignore`
|
|
55
|
+
);
|
|
56
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
removeItem,
|
|
37
37
|
setItemStatus,
|
|
38
38
|
} from './backlog.js';
|
|
39
|
+
import {unignoredDirNotice} from './gitignore.js';
|
|
39
40
|
import {evaluate, formatReport, readFacts} from './health.js';
|
|
40
41
|
import {createWork, isValidSlug, listWork, loadWork, setWorkStatus, updateWork} from './work.js';
|
|
41
42
|
import type {WorkStatus} from './doc.js';
|
|
@@ -393,6 +394,17 @@ export default {
|
|
|
393
394
|
return isAvailable() ? [workStartDef, workStatusDef, workUpdateDef, backlogDef, healthDef] : [];
|
|
394
395
|
},
|
|
395
396
|
prompt: PROMPT,
|
|
397
|
+
/**
|
|
398
|
+
* Warn once at startup when the work directory would be tracked by git.
|
|
399
|
+
*
|
|
400
|
+
* Workflow has no `setup()` — `.work/` is created by `work_start`, not on
|
|
401
|
+
* load — so this is the extension's only load-time hook.
|
|
402
|
+
*/
|
|
403
|
+
setupNotice: () => {
|
|
404
|
+
const settings = settingsFor();
|
|
405
|
+
if (!existsSync(workRoot(settings))) return undefined;
|
|
406
|
+
return unignoredDirNotice(settings.dir);
|
|
407
|
+
},
|
|
396
408
|
handlers,
|
|
397
409
|
} satisfies ToolExtension;
|
|
398
410
|
|