contextgit 0.0.3 → 0.0.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/commands/claim.d.ts +2 -0
- package/dist/commands/claim.d.ts.map +1 -1
- package/dist/commands/claim.js +17 -7
- package/dist/commands/claim.js.map +1 -1
- package/dist/commands/commit.d.ts +4 -1
- package/dist/commands/commit.d.ts.map +1 -1
- package/dist/commands/commit.js +18 -6
- package/dist/commands/commit.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +69 -11
- package/dist/commands/init.js.map +1 -1
- package/package.json +6 -3
package/dist/commands/claim.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export default class ClaimCmd extends Command {
|
|
|
7
7
|
static flags: {
|
|
8
8
|
ttl: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
9
|
status: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
|
+
'for-agent-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
+
'thread-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
12
|
};
|
|
11
13
|
run(): Promise<void>;
|
|
12
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../../src/commands/claim.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAe,MAAM,aAAa,CAAA;AAIlD,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,OAAO;IAC3C,MAAM,CAAC,WAAW,SAA2E;IAE7F,MAAM,CAAC,IAAI;;MAKV;IAED,MAAM,CAAC,KAAK
|
|
1
|
+
{"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../../src/commands/claim.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAe,MAAM,aAAa,CAAA;AAIlD,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,OAAO;IAC3C,MAAM,CAAC,WAAW,SAA2E;IAE7F,MAAM,CAAC,IAAI;;MAKV;IAED,MAAM,CAAC,KAAK;;;;;MAkBX;IAEK,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAgC3B"}
|
package/dist/commands/claim.js
CHANGED
|
@@ -20,30 +20,40 @@ export default class ClaimCmd extends Command {
|
|
|
20
20
|
default: 'proposed',
|
|
21
21
|
options: ['proposed', 'active'],
|
|
22
22
|
}),
|
|
23
|
+
'for-agent-id': Flags.string({
|
|
24
|
+
description: 'Claim on behalf of this agent ID (pre-claiming by orchestrator)',
|
|
25
|
+
required: false,
|
|
26
|
+
}),
|
|
27
|
+
'thread-id': Flags.string({
|
|
28
|
+
description: 'Direct thread ID link for this claim',
|
|
29
|
+
required: false,
|
|
30
|
+
}),
|
|
23
31
|
};
|
|
24
32
|
async run() {
|
|
25
33
|
const { args, flags } = await this.parse(ClaimCmd);
|
|
26
34
|
const config = loadConfig();
|
|
27
35
|
const store = new LocalStore(config.projectId);
|
|
28
|
-
// Resolve current branch
|
|
29
|
-
const branch = await store.getBranchByGitName(config.projectId, 'main');
|
|
30
36
|
const branches = await store.listBranches(config.projectId);
|
|
31
37
|
const activeBranch = branches.find((b) => b.status === 'active') ?? branches[0];
|
|
32
38
|
if (!activeBranch) {
|
|
33
39
|
this.error('No branch found. Run contextgit init first.');
|
|
34
40
|
}
|
|
41
|
+
const agentId = flags['for-agent-id'] ?? `cli-${process.env.USER ?? 'unknown'}`;
|
|
35
42
|
const claim = await store.claimTask(config.projectId, activeBranch.id, {
|
|
36
43
|
task: args.task,
|
|
37
|
-
agentId
|
|
44
|
+
agentId,
|
|
38
45
|
role: config.agentRole ?? 'solo',
|
|
39
46
|
status: flags.status,
|
|
40
47
|
ttl: flags.ttl * 3_600_000,
|
|
48
|
+
threadId: flags['thread-id'],
|
|
41
49
|
});
|
|
42
50
|
this.log(`Claimed.`);
|
|
43
|
-
this.log(`ID:
|
|
44
|
-
this.log(`Task:
|
|
45
|
-
this.log(`
|
|
46
|
-
this.log(`
|
|
51
|
+
this.log(`ID: ${claim.id}`);
|
|
52
|
+
this.log(`Task: ${claim.task}`);
|
|
53
|
+
this.log(`Agent: ${claim.agentId}`);
|
|
54
|
+
this.log(`Thread ID: ${claim.threadId ?? '(none)'}`);
|
|
55
|
+
this.log(`Status: ${claim.status}`);
|
|
56
|
+
this.log(`TTL: ${flags.ttl}h`);
|
|
47
57
|
store.close();
|
|
48
58
|
}
|
|
49
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claim.js","sourceRoot":"","sources":["../../src/commands/claim.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAEhE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,OAAO;IAC3C,MAAM,CAAC,WAAW,GAAG,wEAAwE,CAAA;IAE7F,MAAM,CAAC,IAAI,GAAG;QACZ,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;YAChB,WAAW,EAAE,6CAA6C;YAC1D,QAAQ,EAAE,IAAI;SACf,CAAC;KACH,CAAA;IAED,MAAM,CAAC,KAAK,GAAG;QACb,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC;YACjB,WAAW,EAAE,qDAAqD;YAClE,OAAO,EAAE,CAAC;SACX,CAAC;QACF,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;YACnB,WAAW,EAAE,+EAA+E;YAC5F,OAAO,EAAE,UAAU;YACnB,OAAO,EA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AAC,CAAA;QAClC,IAAI,CAAC,GAAG,CAAC,cAAc,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;QACpC,IAAI,CAAC,GAAG,CAAC,cAAc,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;QACvC,IAAI,CAAC,GAAG,CAAC,cAAc,KAAK,CAAC,QAAQ,IAAI,QAAQ,EAAE,CAAC,CAAA;QACpD,IAAI,CAAC,GAAG,CAAC,cAAc,KAAK,CAAC,MAAM,EAAE,CAAC,CAAA;QACtC,IAAI,CAAC,GAAG,CAAC,cAAc,KAAK,CAAC,GAAG,GAAG,CAAC,CAAA;QAEpC,KAAK,CAAC,KAAK,EAAE,CAAA;IACf,CAAC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
export default class CommitCmd extends Command {
|
|
3
3
|
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
message: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
|
|
6
|
+
};
|
|
4
7
|
static flags: {
|
|
5
|
-
message: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
+
message: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
6
9
|
content: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
7
10
|
thread: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
11
|
close: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../../src/commands/commit.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../../src/commands/commit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAQ,OAAO,EAAS,MAAM,aAAa,CAAA;AAYlD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,OAAO;IAC5C,MAAM,CAAC,WAAW,SAA4B;IAG9C,MAAM,CAAC,IAAI;;MAKV;IAED,MAAM,CAAC,KAAK;;;;;;;MAgCX;IAEK,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAkC3B"}
|
package/dist/commands/commit.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// commit — record a context commit via engine.commit().
|
|
2
|
-
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import { Args, Command, Flags } from '@oclif/core';
|
|
3
3
|
import { simpleGit } from 'simple-git';
|
|
4
4
|
import { bootstrap } from '../bootstrap.js';
|
|
5
5
|
async function captureGitSha(cwd) {
|
|
@@ -12,11 +12,18 @@ async function captureGitSha(cwd) {
|
|
|
12
12
|
}
|
|
13
13
|
export default class CommitCmd extends Command {
|
|
14
14
|
static description = 'Record a context commit';
|
|
15
|
+
// Positional arg — mirrors git commit behaviour: contextgit commit "message"
|
|
16
|
+
static args = {
|
|
17
|
+
message: Args.string({
|
|
18
|
+
description: 'Short commit message (what was accomplished)',
|
|
19
|
+
required: false,
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
15
22
|
static flags = {
|
|
16
23
|
message: Flags.string({
|
|
17
24
|
char: 'm',
|
|
18
|
-
description: 'Short commit message
|
|
19
|
-
required:
|
|
25
|
+
description: 'Short commit message — alternative to positional arg',
|
|
26
|
+
required: false,
|
|
20
27
|
}),
|
|
21
28
|
content: Flags.string({
|
|
22
29
|
char: 'c',
|
|
@@ -46,7 +53,12 @@ export default class CommitCmd extends Command {
|
|
|
46
53
|
}),
|
|
47
54
|
};
|
|
48
55
|
async run() {
|
|
49
|
-
const { flags } = await this.parse(CommitCmd);
|
|
56
|
+
const { args, flags } = await this.parse(CommitCmd);
|
|
57
|
+
// Positional arg takes precedence; -m flag is the fallback for scripts/hooks
|
|
58
|
+
const message = args.message ?? flags.message;
|
|
59
|
+
if (!message) {
|
|
60
|
+
this.error('A commit message is required. Usage: contextgit commit "your message" or contextgit commit -m "your message"');
|
|
61
|
+
}
|
|
50
62
|
const ctx = await bootstrap();
|
|
51
63
|
const threads = {};
|
|
52
64
|
if (flags.thread?.length)
|
|
@@ -56,8 +68,8 @@ export default class CommitCmd extends Command {
|
|
|
56
68
|
}
|
|
57
69
|
const gitCommitSha = await captureGitSha(process.cwd());
|
|
58
70
|
const commit = await ctx.engine.commit({
|
|
59
|
-
message
|
|
60
|
-
content: flags.content ??
|
|
71
|
+
message,
|
|
72
|
+
content: flags.content ?? message,
|
|
61
73
|
gitCommitSha,
|
|
62
74
|
ciRunId: flags['ci-run-id'],
|
|
63
75
|
pipelineName: flags.pipeline,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commit.js","sourceRoot":"","sources":["../../src/commands/commit.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"commit.js","sourceRoot":"","sources":["../../src/commands/commit.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,KAAK,UAAU,aAAa,CAAC,GAAW;IACtC,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,OA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AAM,CAAC,OAAO,EAAE,CAAC,CAAA;IACxC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAA;AAgD5C,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACvC,MAAM,CAAC,WAAW,SAA0C;IAE5D,MAAM,CAAC,KAAK;;;MAWX;IAEK,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA0G3B"}
|
package/dist/commands/init.js
CHANGED
|
@@ -1,16 +1,48 @@
|
|
|
1
1
|
// init — create .contextgit/config.json + project + branch in LocalStore.
|
|
2
2
|
import { Command, Flags } from '@oclif/core';
|
|
3
3
|
import { writeFileSync, mkdirSync, existsSync, readFileSync } from 'fs';
|
|
4
|
+
import { createInterface } from 'readline';
|
|
4
5
|
import { join, basename } from 'path';
|
|
5
6
|
import { nanoid } from 'nanoid';
|
|
6
7
|
import { simpleGit } from 'simple-git';
|
|
7
8
|
import { LocalStore } from '@contextgit/store';
|
|
8
9
|
import { installGitHooks } from '../git-hooks.js';
|
|
9
10
|
const SYSTEM_PROMPT_FRAGMENT = `\
|
|
10
|
-
You have access to ContextGit memory tools.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
You have access to ContextGit memory tools.
|
|
12
|
+
|
|
13
|
+
## Session Start (do this every time)
|
|
14
|
+
Call context_get with scope=global immediately.
|
|
15
|
+
Do not ask questions first. Read the snapshot, then start working.
|
|
16
|
+
Start the highest priority item from the snapshot.
|
|
17
|
+
|
|
18
|
+
## What counts as one task (commit after each)
|
|
19
|
+
Match the grain of your plan:
|
|
20
|
+
- Numbered steps in a plan → each numbered step = one commit
|
|
21
|
+
- User stories → each accepted story = one commit
|
|
22
|
+
- No plan → each logical unit of change (one file, one feature, one fix) = one commit
|
|
23
|
+
|
|
24
|
+
Do NOT batch unrelated changes into one commit.
|
|
25
|
+
When in doubt, commit more often rather than less.
|
|
26
|
+
|
|
27
|
+
## After EVERY completed task
|
|
28
|
+
Immediately, without being asked:
|
|
29
|
+
\`\`\`
|
|
30
|
+
context_commit "what was built | key decisions | next task"
|
|
31
|
+
\`\`\`
|
|
32
|
+
Do not proceed to the next task until the current one is committed.
|
|
33
|
+
|
|
34
|
+
## When scope changes mid-session
|
|
35
|
+
1. Write a context_commit with replan: prefix BEFORE building new scope:
|
|
36
|
+
context_commit "replan: <what changed and why>"
|
|
37
|
+
2. Then build the new scope
|
|
38
|
+
3. Write a normal context_commit when done
|
|
39
|
+
|
|
40
|
+
## Session End (do this every time)
|
|
41
|
+
Call context_commit with:
|
|
42
|
+
- what was built
|
|
43
|
+
- key decisions and why
|
|
44
|
+
- open threads
|
|
45
|
+
- the first concrete task for the next session
|
|
14
46
|
`;
|
|
15
47
|
export default class Init extends Command {
|
|
16
48
|
static description = 'Initialize ContextGit in this project';
|
|
@@ -23,14 +55,17 @@ export default class Init extends Command {
|
|
|
23
55
|
hooks: Flags.boolean({
|
|
24
56
|
description: 'Install git hooks to auto-capture context on every git commit',
|
|
25
57
|
default: false,
|
|
58
|
+
allowNo: true, // --no-hooks to explicitly skip and suppress prompt
|
|
26
59
|
}),
|
|
27
60
|
};
|
|
28
61
|
async run() {
|
|
29
|
-
const { flags } = await this.parse(Init);
|
|
62
|
+
const { flags, argv } = await this.parse(Init);
|
|
30
63
|
const cwd = process.cwd();
|
|
31
64
|
const configDir = join(cwd, '.contextgit');
|
|
32
65
|
const configPath = join(configDir, 'config.json');
|
|
33
66
|
const promptPath = join(configDir, 'system-prompt.md');
|
|
67
|
+
// True if the user explicitly passed --hooks or --no-hooks
|
|
68
|
+
const hooksExplicit = argv.some(a => String(a).startsWith('--hooks') || String(a) === '--no-hooks');
|
|
34
69
|
// ── Self-heal: config exists but DB may be empty ───────────────────────────
|
|
35
70
|
if (existsSync(configPath)) {
|
|
36
71
|
let existing;
|
|
@@ -44,6 +79,11 @@ export default class Init extends Command {
|
|
|
44
79
|
const gitBranch = await detectGitBranch(cwd);
|
|
45
80
|
const branch = await store.getBranchByGitName(existing.projectId, gitBranch);
|
|
46
81
|
if (branch) {
|
|
82
|
+
// BUG-2 fix: --hooks on already-initialized project always installs
|
|
83
|
+
if (flags.hooks) {
|
|
84
|
+
installGitHooks(cwd);
|
|
85
|
+
this.log('Git hooks installed (.git/hooks/post-commit, post-checkout, post-merge)');
|
|
86
|
+
}
|
|
47
87
|
this.log('ContextGit already initialized. Config found at .contextgit/config.json');
|
|
48
88
|
return;
|
|
49
89
|
}
|
|
@@ -58,7 +98,6 @@ export default class Init extends Command {
|
|
|
58
98
|
writeSystemPrompt(promptPath);
|
|
59
99
|
this.log(`Recreated project "${existing.project}" (${existing.projectId}) for branch: ${gitBranch}`);
|
|
60
100
|
this.log(`System prompt: .contextgit/system-prompt.md`);
|
|
61
|
-
this.log(SYSTEM_PROMPT_FRAGMENT);
|
|
62
101
|
if (flags.hooks) {
|
|
63
102
|
installGitHooks(cwd);
|
|
64
103
|
this.log('Git hooks installed (.git/hooks/post-commit, post-checkout, post-merge)');
|
|
@@ -68,7 +107,6 @@ export default class Init extends Command {
|
|
|
68
107
|
// ── Fresh init ─────────────────────────────────────────────────────────────
|
|
69
108
|
const projectName = flags.name ?? basename(cwd);
|
|
70
109
|
const projectId = nanoid();
|
|
71
|
-
// Open store (creates DB + runs migrations).
|
|
72
110
|
const store = new LocalStore(projectId);
|
|
73
111
|
await store.createProject({ id: projectId, name: projectName });
|
|
74
112
|
const gitBranch = await detectGitBranch(cwd);
|
|
@@ -77,7 +115,6 @@ export default class Init extends Command {
|
|
|
77
115
|
name: `Context: ${gitBranch}`,
|
|
78
116
|
gitBranch,
|
|
79
117
|
});
|
|
80
|
-
// Write config
|
|
81
118
|
mkdirSync(configDir, { recursive: true });
|
|
82
119
|
const config = {
|
|
83
120
|
project: projectName,
|
|
@@ -97,15 +134,21 @@ export default class Init extends Command {
|
|
|
97
134
|
this.log(`Config: .contextgit/config.json`);
|
|
98
135
|
this.log(`DB: ~/.contextgit/projects/${projectId}.db`);
|
|
99
136
|
this.log(``);
|
|
100
|
-
|
|
137
|
+
// BUG-3 fix: prompt for hooks unless user was explicit about it
|
|
138
|
+
let installHooks = flags.hooks;
|
|
139
|
+
if (!hooksExplicit) {
|
|
140
|
+
installHooks = await promptYesNo('Install git hooks to auto-capture context on every git commit? (Y/n) ');
|
|
141
|
+
}
|
|
142
|
+
if (installHooks) {
|
|
101
143
|
installGitHooks(cwd);
|
|
102
144
|
this.log(`Git hooks installed (.git/hooks/post-commit, post-checkout, post-merge)`);
|
|
103
145
|
}
|
|
104
146
|
else {
|
|
105
|
-
this.log(`
|
|
147
|
+
this.log(`Skipped hooks. Run "contextgit init --hooks" anytime to install them.`);
|
|
106
148
|
}
|
|
107
149
|
this.log(``);
|
|
108
|
-
this.log(`
|
|
150
|
+
this.log(`System prompt written to .contextgit/system-prompt.md`);
|
|
151
|
+
this.log(`Add its contents to your Claude Code MCP config to enable ContextGit.`);
|
|
109
152
|
this.log(``);
|
|
110
153
|
this.log(SYSTEM_PROMPT_FRAGMENT);
|
|
111
154
|
}
|
|
@@ -123,4 +166,19 @@ async function detectGitBranch(cwd) {
|
|
|
123
166
|
function writeSystemPrompt(promptPath) {
|
|
124
167
|
writeFileSync(promptPath, SYSTEM_PROMPT_FRAGMENT);
|
|
125
168
|
}
|
|
169
|
+
/** Prompt the user with a yes/no question. Defaults to yes on empty input. */
|
|
170
|
+
function promptYesNo(question) {
|
|
171
|
+
return new Promise(resolve => {
|
|
172
|
+
// Non-interactive environment (CI, piped stdin) — default to yes
|
|
173
|
+
if (!process.stdin.isTTY) {
|
|
174
|
+
resolve(true);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
178
|
+
rl.question(question, answer => {
|
|
179
|
+
rl.close();
|
|
180
|
+
resolve(answer.trim().toLowerCase() !== 'n');
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
126
184
|
//# sourceMappingURL=init.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AACvE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,sBAAsB,GAAG
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,mBA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A;AACnD,CAAC;AAED,8EAA8E;AAC9E,SAAS,WAAW,CAAC,QAAgB;IACnC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;QAC3B,iEAAiE;QACjE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,CAAA;YACb,OAAM;QACR,CAAC;QACD,MAAM,EAAE,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;QAC5E,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE;YAC7B,EAAE,CAAC,KAAK,EAAE,CAAA;YACV,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,CAAA;QAC9C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "contextgit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"contextgit": "./bin/run.js"
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
"dirname": "contextgit",
|
|
11
11
|
"commands": "./dist/commands"
|
|
12
12
|
},
|
|
13
|
-
"files": [
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"bin"
|
|
16
|
+
],
|
|
14
17
|
"scripts": {
|
|
15
18
|
"build": "tsc",
|
|
16
19
|
"typecheck": "tsc --noEmit"
|
|
@@ -27,4 +30,4 @@
|
|
|
27
30
|
"@types/node": "^20.0.0",
|
|
28
31
|
"typescript": "^5.4.0"
|
|
29
32
|
}
|
|
30
|
-
}
|
|
33
|
+
}
|